11// SPDX-License-Identifier: BSD-3-Clause
22// Copyright (c) 2026, The OpenROAD Authors
33
4- // These STL headers are intentionally pre-included before exposing protected
5- // STA fields below. Otherwise the access-specifier macro can leak into
6- // transitive standard-library includes on some toolchains.
7- // NOLINTBEGIN(misc-include-cleaner)
8- #include < array>
9- #include < functional>
10- #include < map>
11- #include < optional>
12- #include < ostream>
13- #include < ranges>
14- #include < set>
15- #include < sstream>
16- #include < string_view>
17- #include < type_traits>
18- #include < unordered_set>
19- #include < utility>
20- #include < vector>
21- // NOLINTEND(misc-include-cleaner)
22-
23- #include < cstddef>
24- #include < memory>
25-
26- // Expose STA invalidation sets so the tests can verify the side effect of
27- // EstimateParasitics::updateParasitics() without adding production accessors.
28- #define private public
29- #define protected public
30- #include " sta/GraphDelayCalc.hh"
31- #include " sta/Search.hh"
32- #undef protected
33- #undef private
34-
354#include " db_sta/dbNetwork.hh"
365#include " est/EstimateParasitics.h"
376#include " gtest/gtest.h"
387#include " odb/db.h"
398#include " rsz/Resizer.hh"
40- #include " sta/Graph.hh"
419#include " sta/Liberty.hh"
4210#include " sta/Mode.hh"
4311#include " sta/Network.hh"
4412#include " sta/NetworkClass.hh"
45- #include " sta/SdcClass .hh"
13+ #include " sta/Search .hh"
4614#include " sta/Units.hh"
4715#include " tst/IntegratedFixture.h"
4816
@@ -127,58 +95,6 @@ class TestEstimateParasitics : public tst::IntegratedFixture
12795 ASSERT_NE (dff_x2, nullptr );
12896 ASSERT_TRUE (resizer_.replaceCell (inst, dff_x2));
12997 }
130-
131- void clearTimingInvalidations () const
132- {
133- sta_->graphDelayCalc ()->invalid_delays_ .clear ();
134- sta_->graphDelayCalc ()->invalid_check_edges_ .clear ();
135- sta_->graphDelayCalc ()->invalid_latch_edges_ .clear ();
136- sta_->search ()->invalid_arrivals_ .clear ();
137- sta_->search ()->invalid_requireds_ .clear ();
138- sta_->search ()->invalid_tns_ .clear ();
139- }
140-
141- size_t timingInvalidationCount () const
142- {
143- return sta_->graphDelayCalc ()->invalid_delays_ .size ()
144- + sta_->graphDelayCalc ()->invalid_check_edges_ .size ()
145- + sta_->graphDelayCalc ()->invalid_latch_edges_ .size ()
146- + sta_->search ()->invalid_arrivals_ .size ()
147- + sta_->search ()->invalid_requireds_ .size ()
148- + sta_->search ()->invalid_tns_ .size ();
149- }
150-
151- void expectNoConnectedPinInvalidated (const sta::Net* net) const
152- {
153- std::unique_ptr<sta::NetConnectedPinIterator> pin_iter{
154- sta_->network ()->connectedPinIterator (net)};
155- while (pin_iter->hasNext ()) {
156- const sta::Pin* pin = pin_iter->next ();
157- sta::Vertex* vertex = nullptr ;
158- sta::Vertex* bidirect_drvr_vertex = nullptr ;
159- sta_->graph ()->pinVertices (pin, vertex, bidirect_drvr_vertex);
160- expectNoVertexInvalidated (vertex, pin);
161- expectNoVertexInvalidated (bidirect_drvr_vertex, pin);
162- }
163- }
164-
165- private:
166- void expectNoVertexInvalidated (sta::Vertex* vertex, const sta::Pin* pin) const
167- {
168- if (vertex == nullptr ) {
169- return ;
170- }
171-
172- EXPECT_EQ (sta_->graphDelayCalc ()->invalid_delays_ .find (vertex),
173- sta_->graphDelayCalc ()->invalid_delays_ .end ())
174- << db_network_->pathName (pin);
175- EXPECT_EQ (sta_->search ()->invalid_arrivals_ .find (vertex),
176- sta_->search ()->invalid_arrivals_ .end ())
177- << db_network_->pathName (pin);
178- EXPECT_EQ (sta_->search ()->invalid_requireds_ .find (vertex),
179- sta_->search ()->invalid_requireds_ .end ())
180- << db_network_->pathName (pin);
181- }
18298};
18399
184100// Verifies that an ideal clock net can be present in the incremental
@@ -206,8 +122,7 @@ TEST_F(TestEstimateParasitics, IdealClockNetSkipsStaInvalidation)
206122 // Clear any ordinary resize-related STA invalidation so the assertions below
207123 // measure only updateParasitics() side effects.
208124 sta_->updateTiming (true );
209- clearTimingInvalidations ();
210- ASSERT_EQ (timingInvalidationCount (), 0U );
125+ ASSERT_TRUE (sta_->search ()->arrivalsValid ());
211126
212127 // Seed the exact condition under test: an ideal clock net is pending in
213128 // EstimateParasitics' incremental invalidation set.
@@ -220,8 +135,7 @@ TEST_F(TestEstimateParasitics, IdealClockNetSkipsStaInvalidation)
220135
221136 // A regression calls sta_->delaysInvalidFromFanin(clk_net), which invalidates
222137 // the top clock port and every ideal CK load vertex.
223- EXPECT_EQ (timingInvalidationCount (), 0U );
224- expectNoConnectedPinInvalidated (clk_net);
138+ EXPECT_TRUE (sta_->search ()->arrivalsValid ());
225139 ep_.setIncrementalParasiticsEnabled (false );
226140}
227141
@@ -265,8 +179,7 @@ TEST_F(TestEstimateParasitics, ScanClockIdealOnlyInTestMode)
265179 ASSERT_NE (scan_clk_net, nullptr );
266180
267181 // Isolate the invalidation caused by updateParasitics().
268- clearTimingInvalidations ();
269- ASSERT_EQ (timingInvalidationCount (), 0U );
182+ ASSERT_TRUE (sta_->search ()->arrivalsValid ());
270183
271184 // Seed the scan clock net as invalid. A buggy all-modes ideal-clock check
272185 // treats this net as non-ideal because function mode has no scan clock.
@@ -279,8 +192,7 @@ TEST_F(TestEstimateParasitics, ScanClockIdealOnlyInTestMode)
279192
280193 // If non-clock modes are not ignored, updateParasitics() invalidates the
281194 // scan clock port and scan_reg/CK through delaysInvalidFromFanin().
282- EXPECT_EQ (timingInvalidationCount (), 0U );
283- expectNoConnectedPinInvalidated (scan_clk_net);
195+ EXPECT_TRUE (sta_->search ()->arrivalsValid ());
284196 ep_.setIncrementalParasiticsEnabled (false );
285197}
286198
0 commit comments