From e3ed5208ae5af2a588cdae9f8d4294ceb11444ed Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 31 May 2026 19:30:15 +0900 Subject: [PATCH 1/5] est: Filter ideal clock net invalidation Skip adding ideal clock nets to the estimated-parasitic invalidation set because ideal clock arrivals do not depend on RC. This avoids repeatedly seeding large ideal clock networks during placement-stage ECO repair while preserving normal invalidation for propagated clock and signal nets. Signed-off-by: Jaehyun Kim --- src/est/include/est/EstimateParasitics.h | 1 + src/est/src/EstimateParasitics.cpp | 39 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/est/include/est/EstimateParasitics.h b/src/est/include/est/EstimateParasitics.h index f31a96deb56..a57e001eaa4 100644 --- a/src/est/include/est/EstimateParasitics.h +++ b/src/est/include/est/EstimateParasitics.h @@ -210,6 +210,7 @@ class EstimateParasitics : public sta::dbStaState, public ParasiticsService private: void ensureParasitics(); + bool isIdealClockNet(const sta::Net* net) const; void estimateWireParasiticSteiner(const sta::Pin* drvr_pin, const sta::Net* net, sta::SpefWriter* spef_writer); diff --git a/src/est/src/EstimateParasitics.cpp b/src/est/src/EstimateParasitics.cpp index d3e6ffcdb51..71829effad9 100644 --- a/src/est/src/EstimateParasitics.cpp +++ b/src/est/src/EstimateParasitics.cpp @@ -1145,17 +1145,52 @@ bool EstimateParasitics::isPad(const sta::Instance* inst) const return false; } +bool EstimateParasitics::isIdealClockNet(const sta::Net* net) const +{ + odb::dbNet* db_net = db_network_->staToDb(net); + if (db_net == nullptr) { + return false; + } + + PinSet* drivers = network_->drivers(net); + if (drivers == nullptr || drivers->empty()) { + return false; + } + + // An ideal clock net carries fixed arrivals that do not depend on + // parasitics, so its parasitics never need re-estimation. + const Pin* drvr_pin = *drivers->begin(); + bool is_clock = false; + for (sta::Mode* mode : sta_->modes()) { + // In multi-mode designs, a pin may be an ideal clock only in a subset of + // modes. Ignore modes where the pin is not a clock at all. + // e.g., scan clock pin may not be defined as clock in function mode. + if (!sta_->isClock(drvr_pin, mode)) { + continue; + } + is_clock = true; + if (!sta_->isIdealClock(drvr_pin, mode)) { + return false; + } + } + return is_clock; +} + void EstimateParasitics::parasiticsInvalid(const sta::Net* net) { odb::dbNet* db_net = db_network_->findFlatDbNet(net); if (haveEstimatedParasitics() && db_net) { + const sta::Net* flat_net = db_network_->dbToSta(db_net); + if (isIdealClockNet(flat_net)) { + return; + } debugPrint(logger_, EST, "estimate_parasitics", 2, "parasitics invalid {}", - network_->pathName(net)); - parasitics_invalid_.insert(db_network_->dbToSta(db_net)); + network_->pathName(flat_net)); + parasitics_invalid_.insert(flat_net); } } From 1f7bc1d2240f192f22309c6f4d0ed1acf12cef45 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 31 May 2026 20:42:00 +0900 Subject: [PATCH 2/5] test: Update ideal clock repair outputs Update rsz golden logs for ideal clock net filtering. The repair_clk_nets1 output now keeps the CLOCK net type while preserving the reported inserted buffer wire lengths. The repair_setup_gcd output reflects the deterministic power value produced after skipping ideal clock parasitic invalidation. Signed-off-by: Jaehyun Kim --- src/rsz/test/repair_clk_nets1.ok | 3 +++ src/rsz/test/repair_setup_gcd.ok | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rsz/test/repair_clk_nets1.ok b/src/rsz/test/repair_clk_nets1.ok index 95e4dd560df..7d25dc7b809 100644 --- a/src/rsz/test/repair_clk_nets1.ok +++ b/src/rsz/test/repair_clk_nets1.ok @@ -19,6 +19,9 @@ net2: CLOCK net1: CLOCK out1: CLOCK Driver length delay +wire1/Z manhtn 567.3 steiner 567.3 0.04 +wire2/Z manhtn 567.0 steiner 567.0 0.04 +u3/Z manhtn 1.3 steiner 1.3 0.00 Startpoint: in1 (clock source 'in1') Endpoint: out1 (output port) Path Group: unconstrained diff --git a/src/rsz/test/repair_setup_gcd.ok b/src/rsz/test/repair_setup_gcd.ok index 8d07d1c924f..60834e67587 100644 --- a/src/rsz/test/repair_setup_gcd.ok +++ b/src/rsz/test/repair_setup_gcd.ok @@ -23,6 +23,6 @@ [INFO RSZ-0049] Cloned 1 instances. [WARNING RSZ-0062] Unable to repair all setup violations. Pre-ECO: WNS= -0.162 TNS= -4.061 Area= 684 um^2 Power= 2.784951e-03 W -Post-ECO: WNS= -0.079 TNS= -2.001 Area= 740 um^2 Power= 3.192169e-03 W -Delta: WNS= 0.083 TNS= 2.060 Area= +56 um^2 Power=+4.072185e-04 W +Post-ECO: WNS= -0.079 TNS= -2.001 Area= 740 um^2 Power= 3.196300e-03 W +Delta: WNS= 0.083 TNS= 2.060 Area= +56 um^2 Power=+4.113487e-04 W pass From 43c9651304c6a4191bb0562a92b8540fab288c80 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 31 May 2026 22:20:23 +0900 Subject: [PATCH 3/5] est: Defer ideal clock net filtering Move ideal clock net filtering out of the ODB invalidation callback and into the incremental parasitic update path. This avoids rebuilding the STA clock network while repair_clock_nets is in the middle of disconnecting and reconnecting clock path pins. Add a small helper to classify ideal clock driver pins across modes, and restore the affected regression outputs to the stable clock-network behavior. Signed-off-by: Jaehyun Kim --- src/est/include/est/EstimateParasitics.h | 1 + src/est/src/EstimateParasitics.cpp | 52 ++++++++++++++---------- src/rsz/test/repair_clk_nets1.ok | 3 -- src/rsz/test/repair_setup_gcd.ok | 4 +- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/est/include/est/EstimateParasitics.h b/src/est/include/est/EstimateParasitics.h index a57e001eaa4..a854986c0a0 100644 --- a/src/est/include/est/EstimateParasitics.h +++ b/src/est/include/est/EstimateParasitics.h @@ -210,6 +210,7 @@ class EstimateParasitics : public sta::dbStaState, public ParasiticsService private: void ensureParasitics(); + bool isIdealClockPin(const sta::Pin* pin) const; bool isIdealClockNet(const sta::Net* net) const; void estimateWireParasiticSteiner(const sta::Pin* drvr_pin, const sta::Net* net, diff --git a/src/est/src/EstimateParasitics.cpp b/src/est/src/EstimateParasitics.cpp index 71829effad9..d7d090f5bf7 100644 --- a/src/est/src/EstimateParasitics.cpp +++ b/src/est/src/EstimateParasitics.cpp @@ -435,6 +435,9 @@ void EstimateParasitics::updateParasitics() switch (parasitics_src_) { case ParasiticsSrc::kPlacement: for (const sta::Net* net : parasitics_invalid_) { + if (isIdealClockNet(net)) { + continue; + } // // TODO: remove this check (we expect all to be flat net) // @@ -461,6 +464,9 @@ void EstimateParasitics::updateParasitics() // TODO: update detailed route for modified nets incr_groute_->updateRoutes(); for (const sta::Net* net : parasitics_invalid_) { + if (isIdealClockNet(net)) { + continue; + } debugPrint(logger_, EST, "estimate_parasitics", @@ -482,6 +488,9 @@ void EstimateParasitics::updateParasitics() // groute call. if (parasitics_src_ != ParasiticsSrc::kNone) { for (const sta::Net* net : parasitics_invalid_) { + if (isIdealClockNet(net)) { + continue; + } debugPrint(logger_, EST, "estimate_parasitics", @@ -1145,52 +1154,53 @@ bool EstimateParasitics::isPad(const sta::Instance* inst) const return false; } -bool EstimateParasitics::isIdealClockNet(const sta::Net* net) const +bool EstimateParasitics::isIdealClockPin(const sta::Pin* pin) const { - odb::dbNet* db_net = db_network_->staToDb(net); - if (db_net == nullptr) { - return false; - } - - PinSet* drivers = network_->drivers(net); - if (drivers == nullptr || drivers->empty()) { - return false; - } - - // An ideal clock net carries fixed arrivals that do not depend on + // An ideal clock pin carries fixed arrivals that do not depend on // parasitics, so its parasitics never need re-estimation. - const Pin* drvr_pin = *drivers->begin(); bool is_clock = false; for (sta::Mode* mode : sta_->modes()) { // In multi-mode designs, a pin may be an ideal clock only in a subset of // modes. Ignore modes where the pin is not a clock at all. // e.g., scan clock pin may not be defined as clock in function mode. - if (!sta_->isClock(drvr_pin, mode)) { + if (!sta_->isClock(pin, mode)) { continue; } is_clock = true; - if (!sta_->isIdealClock(drvr_pin, mode)) { + if (!sta_->isIdealClock(pin, mode)) { return false; } } return is_clock; } +bool EstimateParasitics::isIdealClockNet(const sta::Net* net) const +{ + odb::dbNet* db_net = db_network_->staToDb(net); + if (db_net == nullptr) { + return false; + } + + PinSet* drivers = network_->drivers(net); + if (drivers == nullptr || drivers->empty()) { + return false; + } + + const Pin* drvr_pin = *drivers->begin(); + return isIdealClockPin(drvr_pin); +} + void EstimateParasitics::parasiticsInvalid(const sta::Net* net) { odb::dbNet* db_net = db_network_->findFlatDbNet(net); if (haveEstimatedParasitics() && db_net) { - const sta::Net* flat_net = db_network_->dbToSta(db_net); - if (isIdealClockNet(flat_net)) { - return; - } debugPrint(logger_, EST, "estimate_parasitics", 2, "parasitics invalid {}", - network_->pathName(flat_net)); - parasitics_invalid_.insert(flat_net); + network_->pathName(net)); + parasitics_invalid_.insert(db_network_->dbToSta(db_net)); } } diff --git a/src/rsz/test/repair_clk_nets1.ok b/src/rsz/test/repair_clk_nets1.ok index 7d25dc7b809..95e4dd560df 100644 --- a/src/rsz/test/repair_clk_nets1.ok +++ b/src/rsz/test/repair_clk_nets1.ok @@ -19,9 +19,6 @@ net2: CLOCK net1: CLOCK out1: CLOCK Driver length delay -wire1/Z manhtn 567.3 steiner 567.3 0.04 -wire2/Z manhtn 567.0 steiner 567.0 0.04 -u3/Z manhtn 1.3 steiner 1.3 0.00 Startpoint: in1 (clock source 'in1') Endpoint: out1 (output port) Path Group: unconstrained diff --git a/src/rsz/test/repair_setup_gcd.ok b/src/rsz/test/repair_setup_gcd.ok index 60834e67587..8d07d1c924f 100644 --- a/src/rsz/test/repair_setup_gcd.ok +++ b/src/rsz/test/repair_setup_gcd.ok @@ -23,6 +23,6 @@ [INFO RSZ-0049] Cloned 1 instances. [WARNING RSZ-0062] Unable to repair all setup violations. Pre-ECO: WNS= -0.162 TNS= -4.061 Area= 684 um^2 Power= 2.784951e-03 W -Post-ECO: WNS= -0.079 TNS= -2.001 Area= 740 um^2 Power= 3.196300e-03 W -Delta: WNS= 0.083 TNS= 2.060 Area= +56 um^2 Power=+4.113487e-04 W +Post-ECO: WNS= -0.079 TNS= -2.001 Area= 740 um^2 Power= 3.192169e-03 W +Delta: WNS= 0.083 TNS= 2.060 Area= +56 um^2 Power=+4.072185e-04 W pass From b3b05e9b6b4c3f5a4cbaa9378d962b437332dd4c Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 31 May 2026 22:27:03 +0900 Subject: [PATCH 4/5] est: Reuse ideal clock pin helper Replace the duplicate all-mode ideal clock loop in Steiner parasitic estimation with the shared ideal clock pin helper. The helper keeps the mode-aware behavior that ignores modes where the pin is not a clock. Signed-off-by: Jaehyun Kim --- src/est/src/EstimateParasitics.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/est/src/EstimateParasitics.cpp b/src/est/src/EstimateParasitics.cpp index d7d090f5bf7..3f8c01c8fc3 100644 --- a/src/est/src/EstimateParasitics.cpp +++ b/src/est/src/EstimateParasitics.cpp @@ -741,15 +741,7 @@ void EstimateParasitics::estimateWireParasiticSteiner( const sta::Net* net, sta::SpefWriter* spef_writer) { - bool all_modes_ideal_clock = true; - for (sta::Mode* mode : sta_->modes()) { - if (!sta_->isIdealClock(drvr_pin, mode)) { - all_modes_ideal_clock = false; - break; - } - } - - if (!all_modes_ideal_clock) { + if (!isIdealClockPin(drvr_pin)) { SteinerTree* tree = makeSteinerTree(drvr_pin); if (tree) { debugPrint(logger_, From 34afd4ad9e099922da0ef1179191d1d71cf3dae3 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 31 May 2026 23:19:10 +0900 Subject: [PATCH 5/5] test: Add ideal clock parasitic invalidation tests Add C++ regressions for EstimateParasitics incremental invalidation of ideal clock nets. The tests cover DFF resize invalidating an ideal clock net and a scan clock that is ideal only in test mode while absent from function mode. Register the new regression in both CMake and Bazel so the ideal clock filtering behavior is covered by unit test infrastructure. Tested: clang-tidy src/est/test/cpp/TestEstimateParasitics.cc -p build Tested: cmake --build build --target TestEstimateParasitics -j16 Tested: ctest -R TestEstimateParasitics --output-on-failure Tested: bazel test //src/est/test:TestEstimateParasitics Co-authored-by: OmX Signed-off-by: Jaehyun Kim --- src/est/test/BUILD | 19 ++ src/est/test/CMakeLists.txt | 27 ++ src/est/test/cpp/TestEstimateParasitics.cc | 287 +++++++++++++++++++++ src/est/test/cpp/TestEstimateParasitics.v | 26 ++ 4 files changed, 359 insertions(+) create mode 100644 src/est/test/cpp/TestEstimateParasitics.cc create mode 100644 src/est/test/cpp/TestEstimateParasitics.v diff --git a/src/est/test/BUILD b/src/est/test/BUILD index eb01114cc18..4d47617e53a 100644 --- a/src/est/test/BUILD +++ b/src/est/test/BUILD @@ -1,5 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2022-2025, The OpenROAD Authors +load("@rules_cc//cc:cc_test.bzl", "cc_test") load("//test:regression.bzl", "regression_test") package(features = ["layering_check"]) @@ -37,3 +38,21 @@ filegroup( name = test_name, data = [":test_resources"], ) for test_name in TESTS] + +cc_test( + name = "TestEstimateParasitics", + srcs = ["cpp/TestEstimateParasitics.cc"], + data = ["cpp/TestEstimateParasitics.v"], + deps = [ + "//src/dbSta", + "//src/dbSta:dbNetwork", + "//src/est", + "//src/odb/src/db", + "//src/rsz", + "//src/sta:opensta_lib", + "//src/tst:integrated_fixture", + "//src/utl", + "@googletest//:gtest", + "@googletest//:gtest_main", + ], +) diff --git a/src/est/test/CMakeLists.txt b/src/est/test/CMakeLists.txt index 4b26c4a7a38..28e1e722b4c 100644 --- a/src/est/test/CMakeLists.txt +++ b/src/est/test/CMakeLists.txt @@ -1,3 +1,5 @@ +include(openroad) + or_integration_tests( "est" TESTS @@ -9,3 +11,28 @@ or_integration_tests( make_parasitics6 make_parasitics7 ) + +add_executable(TestEstimateParasitics cpp/TestEstimateParasitics.cc) +target_link_libraries(TestEstimateParasitics + OpenSTA + GTest::gtest + GTest::gtest_main + GTest::gmock + dbSta_lib + utl_lib + est_lib + rsz_lib + grt_lib + dpl_lib + stt_lib + odb + tst + ${TCL_LIBRARY} +) + +gtest_discover_tests(TestEstimateParasitics + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/.. +) + +add_dependencies(build_and_test TestEstimateParasitics +) diff --git a/src/est/test/cpp/TestEstimateParasitics.cc b/src/est/test/cpp/TestEstimateParasitics.cc new file mode 100644 index 00000000000..0bcdb994778 --- /dev/null +++ b/src/est/test/cpp/TestEstimateParasitics.cc @@ -0,0 +1,287 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2026, The OpenROAD Authors + +// These STL headers are intentionally pre-included before exposing protected +// STA fields below. Otherwise the access-specifier macro can leak into +// transitive standard-library includes on some toolchains. +// NOLINTBEGIN(misc-include-cleaner) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// NOLINTEND(misc-include-cleaner) + +#include +#include + +// Expose STA invalidation sets so the tests can verify the side effect of +// EstimateParasitics::updateParasitics() without adding production accessors. +#define private public +#define protected public +#include "sta/GraphDelayCalc.hh" +#include "sta/Search.hh" +#undef protected +#undef private + +#include "db_sta/dbNetwork.hh" +#include "est/EstimateParasitics.h" +#include "gtest/gtest.h" +#include "odb/db.h" +#include "rsz/Resizer.hh" +#include "sta/Graph.hh" +#include "sta/Liberty.hh" +#include "sta/Mode.hh" +#include "sta/Network.hh" +#include "sta/NetworkClass.hh" +#include "sta/SdcClass.hh" +#include "sta/Units.hh" +#include "tst/IntegratedFixture.h" + +namespace est { + +class TestEstimateParasitics : public tst::IntegratedFixture +{ + protected: + TestEstimateParasitics() + : tst::IntegratedFixture(tst::IntegratedFixture::Technology::kNangate45, + "_main/src/est/test/") + { + } + + sta::Pin* findTopPin(const char* port_name) const + { + sta::Instance* top_inst = db_network_->topInstance(); + sta::Cell* top_cell = db_network_->cell(top_inst); + if (top_cell == nullptr) { + ADD_FAILURE() << "missing top cell"; + return nullptr; + } + + sta::Port* port = db_network_->findPort(top_cell, port_name); + if (port == nullptr) { + ADD_FAILURE() << "missing top port " << port_name; + return nullptr; + } + + sta::Pin* pin = db_network_->findPin(top_inst, port); + if (pin == nullptr) { + ADD_FAILURE() << "missing top pin " << port_name; + return nullptr; + } + return pin; + } + + sta::Net* flatNet(sta::Pin* pin) const + { + odb::dbNet* db_net = nullptr; + if (db_network_->isTopLevelPort(pin)) { + db_net = db_network_->flatNet(db_network_->term(pin)); + } else { + db_net = db_network_->flatNet(pin); + } + if (db_net == nullptr) { + ADD_FAILURE() << "missing flat net for " << db_network_->pathName(pin); + return nullptr; + } + + sta::Net* net = db_network_->dbToSta(db_net); + if (net == nullptr) { + ADD_FAILURE() << "missing sta net for " << db_net->getName(); + return nullptr; + } + return net; + } + + void makeClock(const char* clock_name, sta::Pin* pin) const + { + sta::PinSet pins(db_network_); + pins.insert(pin); + + const double period = sta_->units()->timeUnit()->userToSta(1.0); + sta::FloatSeq waveform; + waveform.push_back(0.0); + waveform.push_back(period / 2.0); + + sta_->makeClock( + clock_name, pins, false, period, waveform, "", sta_->cmdMode()); + } + + void resizeDff(const char* inst_name) + { + odb::dbInst* db_inst = block_->findInst(inst_name); + ASSERT_NE(db_inst, nullptr) << "missing instance " << inst_name; + + sta::Instance* inst = db_network_->dbToSta(db_inst); + ASSERT_NE(inst, nullptr) << "missing sta instance " << inst_name; + + sta::LibertyCell* dff_x2 = sta_->network()->findLibertyCell("DFF_X2"); + ASSERT_NE(dff_x2, nullptr); + ASSERT_TRUE(resizer_.replaceCell(inst, dff_x2)); + } + + void clearTimingInvalidations() const + { + sta_->graphDelayCalc()->invalid_delays_.clear(); + sta_->graphDelayCalc()->invalid_check_edges_.clear(); + sta_->graphDelayCalc()->invalid_latch_edges_.clear(); + sta_->search()->invalid_arrivals_.clear(); + sta_->search()->invalid_requireds_.clear(); + sta_->search()->invalid_tns_.clear(); + } + + size_t timingInvalidationCount() const + { + return sta_->graphDelayCalc()->invalid_delays_.size() + + sta_->graphDelayCalc()->invalid_check_edges_.size() + + sta_->graphDelayCalc()->invalid_latch_edges_.size() + + sta_->search()->invalid_arrivals_.size() + + sta_->search()->invalid_requireds_.size() + + sta_->search()->invalid_tns_.size(); + } + + void expectNoConnectedPinInvalidated(const sta::Net* net) const + { + std::unique_ptr pin_iter{ + sta_->network()->connectedPinIterator(net)}; + while (pin_iter->hasNext()) { + const sta::Pin* pin = pin_iter->next(); + sta::Vertex* vertex = nullptr; + sta::Vertex* bidirect_drvr_vertex = nullptr; + sta_->graph()->pinVertices(pin, vertex, bidirect_drvr_vertex); + expectNoVertexInvalidated(vertex, pin); + expectNoVertexInvalidated(bidirect_drvr_vertex, pin); + } + } + + private: + void expectNoVertexInvalidated(sta::Vertex* vertex, const sta::Pin* pin) const + { + if (vertex == nullptr) { + return; + } + + EXPECT_EQ(sta_->graphDelayCalc()->invalid_delays_.find(vertex), + sta_->graphDelayCalc()->invalid_delays_.end()) + << db_network_->pathName(pin); + EXPECT_EQ(sta_->search()->invalid_arrivals_.find(vertex), + sta_->search()->invalid_arrivals_.end()) + << db_network_->pathName(pin); + EXPECT_EQ(sta_->search()->invalid_requireds_.find(vertex), + sta_->search()->invalid_requireds_.end()) + << db_network_->pathName(pin); + } +}; + +// Verifies that an ideal clock net can be present in the incremental +// parasitic invalidation set without forcing STA delay invalidation. +// +// DFF resizing may mark the clock net parasitics invalid. For an ideal clock, +// those parasitics do not contribute to clock arrival/slew, so updateParasitics +// should skip both RC re-estimation and delaysInvalidFromFanin() for that net. +TEST_F(TestEstimateParasitics, IdealClockNetSkipsStaInvalidation) +{ + // Build a small clocked design and seed valid timing/parasitic state. + readVerilogAndSetup("TestEstimateParasitics.v"); + sta_->updateTiming(true); + + // Use the default ideal clock from IntegratedFixture::initStaDefaultSdc(). + sta::Pin* clk_pin = findTopPin("clk"); + ASSERT_NE(clk_pin, nullptr); + sta::Net* clk_net = flatNet(clk_pin); + ASSERT_NE(clk_net, nullptr); + + // Model the ECO source: resizing a DFF is the class of netlist edit that can + // make the clock net appear in the parasitic invalidation set. + resizeDff("reg0"); + + // Clear any ordinary resize-related STA invalidation so the assertions below + // measure only updateParasitics() side effects. + sta_->updateTiming(true); + clearTimingInvalidations(); + ASSERT_EQ(timingInvalidationCount(), 0U); + + // Seed the exact condition under test: an ideal clock net is pending in + // EstimateParasitics' incremental invalidation set. + ep_.setParasiticsSrc(ParasiticsSrc::kPlacement); + ep_.setIncrementalParasiticsEnabled(true); + ep_.parasiticsInvalid(clk_net); + ASSERT_TRUE(ep_.hasParasiticsInvalid()); + + ep_.updateParasitics(); + + // A regression calls sta_->delaysInvalidFromFanin(clk_net), which invalidates + // the top clock port and every ideal CK load vertex. + EXPECT_EQ(timingInvalidationCount(), 0U); + expectNoConnectedPinInvalidated(clk_net); + ep_.setIncrementalParasiticsEnabled(false); +} + +// Verifies multi-mode ideal-clock classification for scan clocks. +// +// The original implementation rejected a pin if isIdealClock(pin, mode) was +// false in any mode. That is wrong for scan clocks that are only created in a +// test mode: the scan pin is not a clock in function mode, so that mode must be +// ignored. The fixed logic first checks isClock(pin, mode), then requires ideal +// status only in modes where the pin is actually a clock. +TEST_F(TestEstimateParasitics, ScanClockIdealOnlyInTestMode) +{ + // Do not create the default SDC. This test constructs function/test modes + // explicitly so scan_clk is intentionally absent from function mode. + readVerilogAndSetup("TestEstimateParasitics.v", false); + + // Create two modes, but create scan_clk only in test mode. + sta_->setCmdMode("function"); + sta::Mode* function_mode = sta_->cmdMode(); + sta_->setCmdMode("test"); + sta::Mode* test_mode = sta_->cmdMode(); + + sta::Pin* scan_clk_pin = findTopPin("scan_clk"); + ASSERT_NE(scan_clk_pin, nullptr); + makeClock("scan_clk", scan_clk_pin); + + // This is the exact multi-mode condition being guarded: + // scan_clk is not a function-mode clock, but it is an ideal test-mode clock. + ASSERT_FALSE(sta_->isClock(scan_clk_pin, function_mode)); + ASSERT_TRUE(sta_->isClock(scan_clk_pin, test_mode)); + ASSERT_TRUE(sta_->isIdealClock(scan_clk_pin, test_mode)); + + // Build timing/parasitics after the mode-specific clock setup is complete. + sta_->ensureGraph(); + sta_->ensureLevelized(); + resizer_.initBlock(); + ep_.estimateWireParasitics(); + sta_->updateTiming(true); + + sta::Net* scan_clk_net = flatNet(scan_clk_pin); + ASSERT_NE(scan_clk_net, nullptr); + + // Isolate the invalidation caused by updateParasitics(). + clearTimingInvalidations(); + ASSERT_EQ(timingInvalidationCount(), 0U); + + // Seed the scan clock net as invalid. A buggy all-modes ideal-clock check + // treats this net as non-ideal because function mode has no scan clock. + ep_.setParasiticsSrc(ParasiticsSrc::kPlacement); + ep_.setIncrementalParasiticsEnabled(true); + ep_.parasiticsInvalid(scan_clk_net); + ASSERT_TRUE(ep_.hasParasiticsInvalid()); + + ep_.updateParasitics(); + + // If non-clock modes are not ignored, updateParasitics() invalidates the + // scan clock port and scan_reg/CK through delaysInvalidFromFanin(). + EXPECT_EQ(timingInvalidationCount(), 0U); + expectNoConnectedPinInvalidated(scan_clk_net); + ep_.setIncrementalParasiticsEnabled(false); +} + +} // namespace est diff --git a/src/est/test/cpp/TestEstimateParasitics.v b/src/est/test/cpp/TestEstimateParasitics.v new file mode 100644 index 00000000000..03682b9619e --- /dev/null +++ b/src/est/test/cpp/TestEstimateParasitics.v @@ -0,0 +1,26 @@ +module top (clk, + scan_clk, + d, + q0, + q1, + qs); + input clk; + input scan_clk; + input d; + output q0; + output q1; + output qs; + + DFF_X1 reg0 (.D(d), + .CK(clk), + .Q(q0), + .QN()); + DFF_X1 reg1 (.D(d), + .CK(clk), + .Q(q1), + .QN()); + DFF_X1 scan_reg (.D(d), + .CK(scan_clk), + .Q(qs), + .QN()); +endmodule