Skip to content

Commit c71fb38

Browse files
authored
Merge pull request #9146 from gadfort/odb-callbacks
odb: add callback for bpin placement status
2 parents 35df4fb + e1951bc commit c71fb38

File tree

6 files changed

+70
-1
lines changed

6 files changed

+70
-1
lines changed

src/gui/src/search.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ void Search::inDbBPinDestroy(odb::dbBPin* pin)
7676
clearShapes();
7777
}
7878

79+
void Search::inDbBPinPlacementStatusBefore(odb::dbBPin* pin,
80+
const odb::dbPlacementStatus& status)
81+
{
82+
clearShapes();
83+
}
84+
7985
void Search::inDbFillCreate(odb::dbFill* fill)
8086
{
8187
clearFills();

src/gui/src/search.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ class Search : public QObject, public odb::dbBlockCallBackObj
229229
void inDbBPinAddBox(odb::dbBox* box) override;
230230
void inDbBPinRemoveBox(odb::dbBox* box) override;
231231
void inDbBPinDestroy(odb::dbBPin* pin) override;
232+
void inDbBPinPlacementStatusBefore(
233+
odb::dbBPin* pin,
234+
const odb::dbPlacementStatus& status) override;
232235
void inDbFillCreate(odb::dbFill* fill) override;
233236
void inDbWireCreate(odb::dbWire* wire) override;
234237
void inDbWireDestroy(odb::dbWire* wire) override;

src/odb/include/odb/dbBlockCallBackObj.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class dbBlockCallBackObj
127127
virtual void inDbBPinAddBox(dbBox*) {}
128128
virtual void inDbBPinRemoveBox(dbBox*) {}
129129
virtual void inDbBPinDestroy(dbBPin*) {}
130+
virtual void inDbBPinPlacementStatusBefore(dbBPin*, const dbPlacementStatus&)
131+
{
132+
}
130133
// dbBPin End
131134

132135
// dbBlockage Start

src/odb/src/db/dbBPin.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,18 @@ dbPlacementStatus dbBPin::getPlacementStatus() const
154154
void dbBPin::setPlacementStatus(dbPlacementStatus status)
155155
{
156156
_dbBPin* bpin = (_dbBPin*) this;
157-
bpin->flags_.status = status.getValue();
157+
158+
if (bpin->flags_.status == status) {
159+
return;
160+
}
161+
158162
_dbBlock* block = (_dbBlock*) bpin->getOwner();
163+
164+
for (auto callback : block->callbacks_) {
165+
callback->inDbBPinPlacementStatusBefore(this, status);
166+
}
167+
168+
bpin->flags_.status = status.getValue();
159169
block->flags_.valid_bbox = 0;
160170
}
161171

src/odb/test/cpp/CallBack.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ class CallBack : public dbBlockCallBackObj
6666
events.push_back("PostMove inst " + inst->getName());
6767
}
6868
}
69+
void inDbInstPlacementStatusBefore(dbInst* inst,
70+
const dbPlacementStatus& status) override
71+
{
72+
if (!_pause) {
73+
char buffer[100];
74+
sprintf(buffer,
75+
"Change inst status: %s -> %s",
76+
inst->getConstName(),
77+
status.getString());
78+
events.emplace_back(buffer);
79+
}
80+
}
6981
// dbInst End
7082

7183
// dbNet Start
@@ -203,6 +215,20 @@ class CallBack : public dbBlockCallBackObj
203215
events.emplace_back("Destroy BPin");
204216
}
205217
}
218+
219+
void inDbBPinPlacementStatusBefore(dbBPin* pin,
220+
const dbPlacementStatus& status) override
221+
{
222+
if (!_pause) {
223+
char buffer[100];
224+
const std::string name = pin->getName();
225+
sprintf(buffer,
226+
"Change BPin status: %s -> %s",
227+
name.c_str(),
228+
status.getString());
229+
events.emplace_back(buffer);
230+
}
231+
}
206232
// dbBPin End
207233

208234
// dbBlockage Start

src/odb/test/cpp/TestCallBacks.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ TEST_F(CallbackFixture, test_inst_and_iterm)
5151
EXPECT_EQ(cb_.events[0], "PreMove inst i1");
5252
EXPECT_EQ(cb_.events[1], "PostMove inst i1");
5353
cb_.clearEvents();
54+
i1->setPlacementStatus(dbPlacementStatus::FIRM);
55+
EXPECT_EQ(cb_.events.size(), 1);
56+
EXPECT_EQ(cb_.events[0], "Change inst status: i1 -> FIRM");
57+
cb_.clearEvents();
58+
i1->setPlacementStatus(dbPlacementStatus::FIRM);
59+
EXPECT_EQ(cb_.events.size(), 0);
60+
i1->setPlacementStatus(dbPlacementStatus::NONE);
61+
EXPECT_EQ(cb_.events.size(), 1);
62+
EXPECT_EQ(cb_.events[0], "Change inst status: i1 -> NONE");
63+
cb_.clearEvents();
5464
i1->findITerm("a")->connect(n1);
5565
EXPECT_EQ(cb_.events.size(), 2);
5666
EXPECT_EQ(cb_.events[0], "PreConnect iterm to net n1");
@@ -122,6 +132,17 @@ TEST_F(CallbackFixture, test_bpin)
122132
EXPECT_EQ(cb_.events.size(), 1);
123133
EXPECT_EQ(cb_.events[0], "Create BPin for IN1");
124134
cb_.clearEvents();
135+
pin->setPlacementStatus(dbPlacementStatus::FIRM);
136+
EXPECT_EQ(cb_.events.size(), 1);
137+
EXPECT_EQ(cb_.events[0], "Change BPin status: <dbBPin:1> -> FIRM");
138+
cb_.clearEvents();
139+
pin->setPlacementStatus(dbPlacementStatus::FIRM);
140+
EXPECT_EQ(cb_.events.size(), 0);
141+
cb_.clearEvents();
142+
pin->setPlacementStatus(dbPlacementStatus::NONE);
143+
EXPECT_EQ(cb_.events.size(), 1);
144+
EXPECT_EQ(cb_.events[0], "Change BPin status: <dbBPin:1> -> NONE");
145+
cb_.clearEvents();
125146
dbBox* box
126147
= dbBox::create(pin, db_->getTech()->findLayer("L1"), 0, 0, 100, 100);
127148
EXPECT_EQ(cb_.events.size(), 1);

0 commit comments

Comments
 (0)