66#include < iterator>
77#include < memory>
88#include < string>
9- #include < vector>
109
11- #include " ../../../odb/src/db/dbAccessPoint.h"
12- #include " AbstractGraphicsFactory.h"
1310#include " db_sta/dbSta.hh"
14- #include " dr/AbstractDRGraphics.h"
15- #include " drt/TritonRoute.h"
16- #include " dst/Distributed.h"
1711#include " gtest/gtest.h"
1812#include " odb/db.h"
19- #include " pa/AbstractPAGraphics.h"
2013#include " sta/NetworkClass.hh"
2114#include " sta/VerilogWriter.hh"
22- #include " ta/AbstractTAGraphics.h"
2315#include " tst/IntegratedFixture.h"
2416#include " utl/Logger.h"
2517
@@ -40,116 +32,6 @@ class BufRemTest3 : public tst::IntegratedFixture
4032 bool debug_ = false ; // Set to true to generate debug output
4133};
4234
43- // Dummy GraphicsFactory for drt.initGraphics(). Needed for drt.pinAccess()
44- class NullGraphicsFactory : public drt ::AbstractGraphicsFactory
45- {
46- public:
47- void reset (drt::frDebugSettings*,
48- drt::frDesign*,
49- odb::dbDatabase*,
50- utl::Logger*,
51- drt::RouterConfiguration*) override
52- {
53- }
54-
55- bool guiActive () override { return false ; }
56-
57- std::unique_ptr<drt::AbstractDRGraphics> makeUniqueDRGraphics () override
58- {
59- return nullptr ;
60- }
61-
62- std::unique_ptr<drt::AbstractTAGraphics> makeUniqueTAGraphics () override
63- {
64- return nullptr ;
65- }
66-
67- std::unique_ptr<drt::AbstractPAGraphics> makeUniquePAGraphics () override
68- {
69- return nullptr ;
70- }
71- };
72-
73- static void addTrackGrid (odb::dbBlock* block, const char * layer_name)
74- {
75- odb::dbTechLayer* layer = block->getTech ()->findLayer (layer_name);
76- ASSERT_NE (layer, nullptr );
77- odb::dbTrackGrid* grid = block->findTrackGrid (layer);
78- if (grid == nullptr ) {
79- grid = odb::dbTrackGrid::create (block, layer);
80- }
81- ASSERT_NE (grid, nullptr );
82- grid->addGridPatternX (0 , 200 , 190 );
83- grid->addGridPatternY (0 , 200 , 190 );
84- }
85-
86- static void addBPinShape (odb::dbBlock* block,
87- const char * bterm_name,
88- const int x,
89- const int y)
90- {
91- odb::dbBTerm* bterm = block->findBTerm (bterm_name);
92- ASSERT_NE (bterm, nullptr );
93- odb::dbTechLayer* layer = block->getTech ()->findLayer (" metal2" );
94- ASSERT_NE (layer, nullptr );
95- odb::dbBPin* bpin = odb::dbBPin::create (bterm);
96- ASSERT_NE (bpin, nullptr );
97- odb::dbBox* box = odb::dbBox::create (bpin, layer, x, y, x + 190 , y + 190 );
98- ASSERT_NE (box, nullptr );
99- bpin->setPlacementStatus (odb::dbPlacementStatus::PLACED );
100- }
101-
102- // Reproduce the failing sizeup,buffer ECO sequence.
103- // 1. DRT pinAccess first sets a preferred AP and its back-reference.
104- // 2. A sizeup-like swapMaster then changes the current MTerm/MPin context
105- // before Resizer removes the buffer.
106- // 3. Buffer destruction must clear the AP back-reference.
107- TEST_F (BufRemTest3, RemoveBufferAfterSwapMaster)
108- {
109- readVerilogAndSetup (" TestBufferRemoval3_9.v" );
110-
111- block_->setDieArea (odb::Rect (0 , 0 , 40000 , 40000 ));
112- for (const char * layer_name :
113- {" metal1" , " metal2" , " metal3" , " metal4" , " metal5" }) {
114- addTrackGrid (block_, layer_name);
115- }
116- addBPinShape (block_, " clk" , 0 , 2000 );
117- addBPinShape (block_, " in" , 0 , 4000 );
118- addBPinShape (block_, " out" , 2000 , 4000 );
119-
120- odb::dbInst* buf_inst = block_->findInst (" buf1" );
121- ASSERT_NE (buf_inst, nullptr );
122- buf_inst->setLocation (0 , 0 );
123- buf_inst->setPlacementStatus (odb::dbPlacementStatus::PLACED );
124-
125- dst::Distributed dist (&logger_);
126- drt::TritonRoute drt (db_.get (), &logger_, &service_registry_, &dist, &stt_);
127- drt.initGraphics (std::make_unique<NullGraphicsFactory>());
128- drt.pinAccess ();
129-
130- odb::dbITerm* buf_a = buf_inst->findITerm (" A" );
131- ASSERT_NE (buf_a, nullptr );
132- const std::vector<odb::dbAccessPoint*> pref_aps
133- = buf_a->getPrefAccessPoints ();
134- ASSERT_FALSE (pref_aps.empty ());
135- odb::_dbAccessPoint* ap_impl
136- = static_cast <odb::_dbAccessPoint*>(pref_aps[0 ]->getImpl ());
137- ASSERT_EQ (ap_impl->iterms_ .size (), 1U );
138-
139- odb::dbMaster* sized_master = db_->findMaster (" BUF_X4" );
140- ASSERT_NE (sized_master, nullptr );
141- ASSERT_TRUE (buf_inst->swapMaster (sized_master));
142-
143- sta::Instance* sta_buf = db_network_->dbToSta (buf_inst);
144- ASSERT_NE (sta_buf, nullptr );
145- sta::InstanceSeq insts;
146- insts.emplace_back (sta_buf);
147- resizer_.removeBuffers (insts);
148-
149- EXPECT_EQ (block_->findInst (" buf1" ), nullptr );
150- EXPECT_TRUE (ap_impl->iterms_ .empty ());
151- }
152-
15335TEST_F (BufRemTest3, RemoveBufferCase9)
15436{
15537 std::string test_name = " TestBufferRemoval3_9" ;
0 commit comments