Skip to content

Commit fb1f150

Browse files
committed
Added dbNetwork::libertyCell(Cell*).
- Fixes #8353 Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 1f974c3 commit fb1f150

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/dbSta/include/db_sta/dbNetwork.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class dbNetwork : public ConcreteNetwork
103103
Point location(const Pin* pin) const;
104104
bool isPlaced(const Pin* pin) const;
105105

106+
LibertyCell* libertyCell(Cell* cell) const override;
107+
const LibertyCell* libertyCell(const Cell* cell) const override;
106108
LibertyCell* libertyCell(dbInst* inst);
107109
LibertyPort* libertyPort(const Pin*) const override;
108110
dbInst* staToDb(const Instance* instance) const;

src/dbSta/src/dbNetwork.cc

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,19 +2961,23 @@ void dbNetwork::staToDb(const Cell* cell,
29612961
//
29622962
dbMaster* dbNetwork::staToDb(const Cell* cell) const
29632963
{
2964-
const ConcreteCell* ccell = reinterpret_cast<const ConcreteCell*>(cell);
2965-
auto master = reinterpret_cast<dbMaster*>(ccell->extCell());
2966-
assert(!master || master->getObjectType() == odb::dbMasterObj);
2964+
if (isConcreteCell(cell)) {
2965+
const ConcreteCell* ccell = reinterpret_cast<const ConcreteCell*>(cell);
2966+
auto master = reinterpret_cast<dbMaster*>(ccell->extCell());
2967+
assert(!master || master->getObjectType() == odb::dbMasterObj);
2968+
return master;
2969+
}
2970+
2971+
dbMaster* master = nullptr;
2972+
dbModule* module = nullptr;
2973+
staToDb(cell, master, module);
29672974
return master;
29682975
}
29692976

29702977
// called only on db cells.
29712978
dbMaster* dbNetwork::staToDb(const LibertyCell* cell) const
29722979
{
2973-
const ConcreteCell* ccell = cell;
2974-
auto master = reinterpret_cast<dbMaster*>(ccell->extCell());
2975-
assert(!master || master->getObjectType() == odb::dbMasterObj);
2976-
return master;
2980+
return staToDb(reinterpret_cast<const Cell*>(cell));
29772981
}
29782982

29792983
dbMTerm* dbNetwork::staToDb(const Port* port) const
@@ -3172,6 +3176,26 @@ PortDirection* dbNetwork::dbToSta(const dbSigType& sig_type,
31723176

31733177
////////////////////////////////////////////////////////////////
31743178

3179+
LibertyCell* dbNetwork::libertyCell(Cell* cell) const
3180+
{
3181+
if (isConcreteCell(cell) == false) {
3182+
dbMaster* master = nullptr;
3183+
dbModule* module = nullptr;
3184+
staToDb(cell, master, module);
3185+
if (master) {
3186+
cell = reinterpret_cast<Cell*>(master->staCell());
3187+
} else if (module) {
3188+
return nullptr; // dbModule does not have the corresponding LibertyCell
3189+
}
3190+
}
3191+
return ConcreteNetwork::libertyCell(cell);
3192+
}
3193+
3194+
const LibertyCell* dbNetwork::libertyCell(const Cell* cell) const
3195+
{
3196+
return libertyCell(const_cast<Cell*>(cell));
3197+
}
3198+
31753199
LibertyCell* dbNetwork::libertyCell(dbInst* inst)
31763200
{
31773201
return libertyCell(dbToSta(inst));

0 commit comments

Comments
 (0)