Skip to content

Commit e9e67a7

Browse files
authored
Merge pull request #8936 from gadfort/odb-bpin-callback
odb: add callback to BPin when adding or removing boxes so the gui and psm get updated
2 parents 1d77285 + eefbaee commit e9e67a7

File tree

9 files changed

+72
-0
lines changed

9 files changed

+72
-0
lines changed

src/gui/src/search.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ void Search::inDbBPinCreate(odb::dbBPin* pin)
6161
clearShapes();
6262
}
6363

64+
void Search::inDbBPinAddBox(odb::dbBox* box)
65+
{
66+
clearShapes();
67+
}
68+
69+
void Search::inDbBPinRemoveBox(odb::dbBox* box)
70+
{
71+
clearShapes();
72+
}
73+
6474
void Search::inDbBPinDestroy(odb::dbBPin* pin)
6575
{
6676
clearShapes();

src/gui/src/search.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ class Search : public QObject, public odb::dbBlockCallBackObj
226226
const odb::dbPlacementStatus& status) override;
227227
void inDbPostMoveInst(odb::dbInst* inst) override;
228228
void inDbBPinCreate(odb::dbBPin* pin) override;
229+
void inDbBPinAddBox(odb::dbBox* box) override;
230+
void inDbBPinRemoveBox(odb::dbBox* box) override;
229231
void inDbBPinDestroy(odb::dbBPin* pin) override;
230232
void inDbFillCreate(odb::dbFill* fill) override;
231233
void inDbWireCreate(odb::dbWire* wire) override;

src/odb/include/odb/dbBlockCallBackObj.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class dbBlockCallBackObj
125125

126126
// dbBPin Start
127127
virtual void inDbBPinCreate(dbBPin*) {}
128+
virtual void inDbBPinAddBox(dbBox*) {}
129+
virtual void inDbBPinRemoveBox(dbBox*) {}
128130
virtual void inDbBPinDestroy(dbBPin*) {}
129131
// dbBPin End
130132

src/odb/src/db/dbBPin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ void _dbBPin::removeBox(_dbBox* box)
291291
{
292292
_dbBlock* block = (_dbBlock*) getOwner();
293293

294+
for (auto callback : block->_callbacks) {
295+
callback->inDbBPinRemoveBox((dbBox*) box);
296+
}
297+
294298
dbId<_dbBox> boxid = box->getOID();
295299
if (boxid == boxes_) {
296300
// at head of list, need to move head

src/odb/src/db/dbBox.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ dbBox* dbBox::create(dbBPin* bpin_,
721721
bpin->boxes_ = box->getOID();
722722

723723
block->add_rect(box->shape_.rect);
724+
725+
for (auto callback : block->_callbacks) {
726+
callback->inDbBPinAddBox((dbBox*) box);
727+
}
728+
724729
return (dbBox*) box;
725730
}
726731

src/odb/test/cpp/CallBack.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,28 @@ class CallBack : public dbBlockCallBackObj
175175
events.push_back("Create BPin for " + pin->getBTerm()->getName());
176176
}
177177
}
178+
179+
void inDbBPinAddBox(dbBox* box) override
180+
{
181+
if (!_pause) {
182+
char buffer[100];
183+
sprintf(buffer,
184+
"Create BPin box (%d,%d) (%d,%d)",
185+
box->xMin(),
186+
box->yMin(),
187+
box->xMax(),
188+
box->yMax());
189+
events.emplace_back(buffer);
190+
}
191+
}
192+
193+
void inDbBPinRemoveBox(dbBox* box) override
194+
{
195+
if (!_pause) {
196+
events.emplace_back("Destroy bpin box");
197+
}
198+
}
199+
178200
void inDbBPinDestroy(dbBPin*) override
179201
{
180202
if (!_pause) {

src/odb/test/cpp/TestCallBacks.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ TEST_F(CallbackFixture, test_bpin)
122122
EXPECT_EQ(cb_.events.size(), 1);
123123
EXPECT_EQ(cb_.events[0], "Create BPin for IN1");
124124
cb_.clearEvents();
125+
dbBox* box
126+
= dbBox::create(pin, db_->getTech()->findLayer("L1"), 0, 0, 100, 100);
127+
EXPECT_EQ(cb_.events.size(), 1);
128+
EXPECT_EQ(cb_.events[0], "Create BPin box (0,0) (100,100)");
129+
cb_.clearEvents();
130+
dbBox::destroy(box);
131+
EXPECT_EQ(cb_.events.size(), 1);
132+
EXPECT_EQ(cb_.events[0], "Destroy bpin box");
133+
cb_.clearEvents();
125134
dbBPin::destroy(pin);
126135
EXPECT_EQ(cb_.events.size(), 1);
127136
EXPECT_EQ(cb_.events[0], "Destroy BPin");

src/psm/include/psm/pdnsim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class PDNSim : public odb::dbBlockCallBackObj
103103
void inDbNetDestroy(odb::dbNet*) override;
104104
void inDbBTermPostConnect(odb::dbBTerm*) override;
105105
void inDbBTermPostDisConnect(odb::dbBTerm*, odb::dbNet*) override;
106+
void inDbBPinCreate(odb::dbBPin*) override;
107+
void inDbBPinAddBox(odb::dbBox*) override;
108+
void inDbBPinRemoveBox(odb::dbBox*) override;
106109
void inDbBPinDestroy(odb::dbBPin*) override;
107110
void inDbSWireAddSBox(odb::dbSBox*) override;
108111
void inDbSWireRemoveSBox(odb::dbSBox*) override;

src/psm/src/pdnsim.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ void PDNSim::inDbBTermPostDisConnect(odb::dbBTerm*, odb::dbNet*)
232232
clearSolvers();
233233
}
234234

235+
void PDNSim::inDbBPinCreate(odb::dbBPin*)
236+
{
237+
clearSolvers();
238+
}
239+
240+
void PDNSim::inDbBPinAddBox(odb::dbBox*)
241+
{
242+
clearSolvers();
243+
}
244+
245+
void PDNSim::inDbBPinRemoveBox(odb::dbBox*)
246+
{
247+
clearSolvers();
248+
}
249+
235250
void PDNSim::inDbBPinDestroy(odb::dbBPin*)
236251
{
237252
clearSolvers();

0 commit comments

Comments
 (0)