diff --git a/src/dft/src/architect/CMakeLists.txt b/src/dft/src/architect/CMakeLists.txt index 206ead24f3d..32f423f0468 100644 --- a/src/dft/src/architect/CMakeLists.txt +++ b/src/dft/src/architect/CMakeLists.txt @@ -7,20 +7,15 @@ add_library(dft_architect_lib target_link_libraries(dft_architect_lib PRIVATE - utl_lib - dft_utils_lib - dft_cells_lib + dft_base_scan_cell_lib dft_clock_domain_lib dft_config_lib - dft_utils_lib + dft_utils_scan_pin_lib ) target_link_libraries(dft_architect_lib PRIVATE odb - dbSta - OpenSTA - utl ) target_include_directories(dft_architect_lib diff --git a/src/dft/src/cells/CMakeLists.txt b/src/dft/src/cells/CMakeLists.txt index 45451dffae0..dbd15a59873 100644 --- a/src/dft/src/cells/CMakeLists.txt +++ b/src/dft/src/cells/CMakeLists.txt @@ -1,7 +1,6 @@ add_library(dft_cells_lib # Keep sorted OneBitScanCell.cpp - ScanCell.cpp ScanCellFactory.cpp ) @@ -20,3 +19,20 @@ target_include_directories(dft_cells_lib PUBLIC ${CMAKE_CURRENT_LIST_DIR} ) + +add_library(dft_base_scan_cell_lib + ScanCell.cpp +) + +target_link_libraries(dft_base_scan_cell_lib + PRIVATE + odb + dft_clock_domain_lib + dft_config_lib + dft_utils_scan_pin_lib +) + +target_include_directories(dft_base_scan_cell_lib + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/src/dft/src/config/CMakeLists.txt b/src/dft/src/config/CMakeLists.txt index cc1555d2b80..eac4849c0b9 100644 --- a/src/dft/src/config/CMakeLists.txt +++ b/src/dft/src/config/CMakeLists.txt @@ -12,8 +12,6 @@ target_include_directories(dft_config_lib target_link_libraries(dft_config_lib PRIVATE odb - dbSta - OpenSTA utl_lib - dft_utils_lib + dft_utils_formatting_lib ) diff --git a/src/dft/src/config/ScanArchitectConfig.cpp b/src/dft/src/config/ScanArchitectConfig.cpp index ef25174e36c..8b11ba932e3 100644 --- a/src/dft/src/config/ScanArchitectConfig.cpp +++ b/src/dft/src/config/ScanArchitectConfig.cpp @@ -32,7 +32,7 @@ #include "ScanArchitectConfig.hh" -#include "Utils.hh" +#include "Formatting.hh" namespace dft { diff --git a/src/dft/src/utils/CMakeLists.txt b/src/dft/src/utils/CMakeLists.txt index df00812f346..4c9fd6d8f05 100644 --- a/src/dft/src/utils/CMakeLists.txt +++ b/src/dft/src/utils/CMakeLists.txt @@ -2,7 +2,6 @@ add_library(dft_utils_lib # Keep sorted Utils.cpp - ScanPin.cpp ) target_link_libraries(dft_utils_lib @@ -16,3 +15,26 @@ target_include_directories(dft_utils_lib PUBLIC ${CMAKE_CURRENT_LIST_DIR} ) + + +add_library(dft_utils_scan_pin_lib + ScanPin.cpp +) + +target_link_libraries(dft_utils_scan_pin_lib + PRIVATE + odb +) + +target_include_directories(dft_utils_scan_pin_lib + PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) + + +add_library(dft_utils_formatting_lib INTERFACE) + +target_include_directories(dft_utils_formatting_lib + INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/src/dft/src/utils/Formatting.hh b/src/dft/src/utils/Formatting.hh new file mode 100644 index 00000000000..42c47b930c5 --- /dev/null +++ b/src/dft/src/utils/Formatting.hh @@ -0,0 +1,18 @@ +#include + +#include +#include + +namespace dft::utils { + +// Helper to format optional values for the config reports +template +std::string FormatForReport(const std::optional& opt) +{ + if (opt.has_value()) { + return fmt::format("{}", opt.value()); + } + return "Undefined"; +} + +} // namespace dft::utils diff --git a/src/dft/src/utils/Utils.hh b/src/dft/src/utils/Utils.hh index 2009d988354..1c7fb4f7116 100644 --- a/src/dft/src/utils/Utils.hh +++ b/src/dft/src/utils/Utils.hh @@ -61,14 +61,4 @@ std::vector GetClockPin(odb::dbInst* inst); // Returns a sta::Clock of the given iterm std::optional GetClock(sta::dbSta* sta, odb::dbITerm* iterm); -// Helper to format optional values for the config reports -template -std::string FormatForReport(const std::optional& opt) -{ - if (opt.has_value()) { - return fmt::format("{}", opt.value()); - } - return "Undefined"; -} - } // namespace dft::utils diff --git a/src/dft/test/cpp/CMakeLists.txt b/src/dft/test/cpp/CMakeLists.txt index 730b05d686c..58559d4e66d 100644 --- a/src/dft/test/cpp/CMakeLists.txt +++ b/src/dft/test/cpp/CMakeLists.txt @@ -1,31 +1,27 @@ -find_package(Boost) include("openroad") - -set(DFT_HOME ${PROJECT_SOURCE_DIR}) - set(TEST_LIBS - utl_lib - dbSta_lib + gtest + gmock + gtest_main odb - dft_cells_lib + dft_base_scan_cell_lib dft_config_lib dft_architect_lib dft_clock_domain_lib - dft_utils_lib + dft_utils_scan_pin_lib ) +add_executable(TestScanArchitect TestScanArchitect.cpp) +target_link_libraries(TestScanArchitect ${TEST_LIBS}) +gtest_discover_tests(TestScanArchitect WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_executable(TestScanArchitectHeuristic TestScanArchitectHeuristic.cpp ScanCellMock.cpp) target_link_libraries(TestScanArchitectHeuristic ${TEST_LIBS}) -target_include_directories(TestScanArchitectHeuristic - PRIVATE - ${DFT_HOME}/src -) +gtest_discover_tests(TestScanArchitectHeuristic WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) -add_executable(TestScanArchitect TestScanArchitect.cpp) -target_link_libraries(TestScanArchitect ${TEST_LIBS}) -target_include_directories(TestScanArchitect - PRIVATE - ${DFT_HOME}/src +add_dependencies(build_and_test + TestScanArchitect + TestScanArchitectHeuristic ) diff --git a/src/dft/test/cpp/TestScanArchitect.cpp b/src/dft/test/cpp/TestScanArchitect.cpp index 55c844e02c1..bc757a0bc1d 100644 --- a/src/dft/test/cpp/TestScanArchitect.cpp +++ b/src/dft/test/cpp/TestScanArchitect.cpp @@ -1,18 +1,14 @@ -#define BOOST_TEST_MODULE TestScanArchitect -#include #include #include #include #include "ScanArchitect.hh" #include "ScanArchitectConfig.hh" +#include "gtest/gtest.h" +namespace dft { namespace { -BOOST_AUTO_TEST_SUITE(test_suite) - -using namespace dft; - bool operator!=(const ScanArchitect::HashDomainLimits& lhs, const ScanArchitect::HashDomainLimits& rhs) { @@ -44,41 +40,40 @@ ScanArchitect::HashDomainLimits CreateTestHashDomainLimits(uint64_t chain_count, } // Check if we are correctly calculating the limits of the hash domains -BOOST_AUTO_TEST_CASE(test_calculate_chain_count_and_max_length) +TEST(TestScanArchitect, CalculatesChainCountAndMaxLength) { // For 1 hash domain (1) with 10 bits and a max length of 5, we need to have a // chain count of 2 in that hash domain (1) - BOOST_TEST(CompareUnordered( + EXPECT_TRUE(CompareUnordered( ScanArchitect::inferChainCountFromMaxLength({{1, 10}}, 5), {{1, CreateTestHashDomainLimits(2, 5)}})); // Unbalance cases // We create 2 chains with max_length of 4 - BOOST_TEST( + EXPECT_TRUE( CompareUnordered(ScanArchitect::inferChainCountFromMaxLength({{1, 9}}, 5), {{1, CreateTestHashDomainLimits(2, 5)}})); // We create 2 chains with max_length of 3 - BOOST_TEST( + EXPECT_TRUE( CompareUnordered(ScanArchitect::inferChainCountFromMaxLength({{1, 6}}, 5), {{1, CreateTestHashDomainLimits(2, 3)}})); // Two hash domains, balance case - BOOST_TEST(CompareUnordered( + EXPECT_TRUE(CompareUnordered( ScanArchitect::inferChainCountFromMaxLength({{1, 10}, {2, 10}}, 5), {{1, CreateTestHashDomainLimits(2, 5)}, {2, CreateTestHashDomainLimits(2, 5)}})); // Unbalance - BOOST_TEST(CompareUnordered( + EXPECT_TRUE(CompareUnordered( ScanArchitect::inferChainCountFromMaxLength({{1, 10}, {2, 9}}, 5), {{1, CreateTestHashDomainLimits(2, 5)}, {2, CreateTestHashDomainLimits(2, 5)}})); //// Two hash domains with different number of cells - BOOST_TEST(CompareUnordered( + EXPECT_TRUE(CompareUnordered( ScanArchitect::inferChainCountFromMaxLength({{1, 10}, {2, 15}}, 5), {{1, CreateTestHashDomainLimits(2, 5)}, {2, CreateTestHashDomainLimits(3, 5)}})); } -BOOST_AUTO_TEST_SUITE_END() - } // namespace +} // namespace dft diff --git a/src/dft/test/cpp/TestScanArchitectHeuristic.cpp b/src/dft/test/cpp/TestScanArchitectHeuristic.cpp index fbd5c204e2f..26f86f6aac4 100644 --- a/src/dft/test/cpp/TestScanArchitectHeuristic.cpp +++ b/src/dft/test/cpp/TestScanArchitectHeuristic.cpp @@ -1,5 +1,3 @@ -#define BOOST_TEST_MODULE TestScanReplace -#include #include #include @@ -7,15 +5,12 @@ #include "ScanArchitect.hh" #include "ScanArchitectConfig.hh" #include "ScanCellMock.hh" +#include "gtest/gtest.h" +namespace dft::test { namespace { -using namespace dft; -using namespace dft::test; -BOOST_AUTO_TEST_SUITE(test_suite) - -// Check if we can architect a simple two chain design with clock no mix -BOOST_AUTO_TEST_CASE(test_one_clock_domain_no_mix) +TEST(TestScanArchitectHeuristic, ArchitectWithOneClockDomainNoMix) { utl::Logger* logger = new utl::Logger(); @@ -48,12 +43,12 @@ BOOST_AUTO_TEST_CASE(test_one_clock_domain_no_mix) = scan_architect->getScanChains(); // There should be 2 chains - BOOST_TEST(scan_chains.size() == 2); + EXPECT_EQ(scan_chains.size(), 2); // All the scan cells should be in the chains std::unordered_set scan_cells_in_chains_names; for (const std::unique_ptr& scan_chain : scan_chains) { - BOOST_TEST(!scan_chain->empty()); // All the chains should have cells + EXPECT_FALSE(scan_chain->empty()); // All the chains should have cells for (const auto& scan_cell : scan_chain->getScanCells()) { scan_cells_in_chains_names.insert(scan_cell->getName()); } @@ -62,13 +57,11 @@ BOOST_AUTO_TEST_CASE(test_one_clock_domain_no_mix) for (const std::string& name : scan_cell_names) { const bool test = scan_cells_in_chains_names.find(name) != scan_cells_in_chains_names.end(); - BOOST_TEST(test); // Was the cell included? + EXPECT_TRUE(test); // Was the cell included? } } -// Check if we can architect a simple four chain design, with two clocks and no -// clock mixing -BOOST_AUTO_TEST_CASE(test_two_clock_domain_no_mix) +TEST(TestScanArchitectHeuristic, ArchitectWithTwoClockDomainNoMix) { utl::Logger* logger = new utl::Logger(); @@ -114,7 +107,7 @@ BOOST_AUTO_TEST_CASE(test_two_clock_domain_no_mix) = scan_architect->getScanChains(); // There should be 4 chains - BOOST_TEST(scan_chains.size() == 4); + EXPECT_EQ(scan_chains.size(), 4); uint64_t total_bits = 0; for (const auto& scan_chain : scan_chains) { @@ -122,12 +115,10 @@ BOOST_AUTO_TEST_CASE(test_two_clock_domain_no_mix) total_bits += scan_cell->getBits(); } } - BOOST_TEST(total_bits == 20 + 15); + EXPECT_EQ(total_bits, 20 + 15); } -// Check if we can architect a simple four chain design, with two clocks and no -// clock mixing -BOOST_AUTO_TEST_CASE(test_two_edges_no_mix) +TEST(TestScanArchitectHeuristic, ArchitectWithTwoEdgesNoMix) { utl::Logger* logger = new utl::Logger(); @@ -173,7 +164,7 @@ BOOST_AUTO_TEST_CASE(test_two_edges_no_mix) = scan_architect->getScanChains(); // There should be 4 chains - BOOST_TEST(scan_chains.size() == 4); + EXPECT_EQ(scan_chains.size(), 4); uint64_t total_bits_rising = 0; uint64_t total_bits_falling = 0; @@ -189,10 +180,9 @@ BOOST_AUTO_TEST_CASE(test_two_edges_no_mix) } } } - BOOST_TEST(total_bits_rising == 20); - BOOST_TEST(total_bits_falling == 15); + EXPECT_EQ(total_bits_rising, 20); + EXPECT_EQ(total_bits_falling, 15); } -BOOST_AUTO_TEST_SUITE_END() - } // namespace +} // namespace dft::test diff --git a/src/dft/test/regression_tests.tcl b/src/dft/test/regression_tests.tcl index 816fb50f1c3..2682ce1ec37 100644 --- a/src/dft/test/regression_tests.tcl +++ b/src/dft/test/regression_tests.tcl @@ -5,8 +5,3 @@ record_tests { scan_architect_no_mix_sky130 scan_architect_clock_mix_sky130 } - - -record_pass_fail_tests { - cpp_tests -}