Skip to content

Commit c6efacc

Browse files
authored
Merge pull request #10665 from Logikable/mbff
mbff: Use getLibertyCell (now testCell) instead of libertyCell.
2 parents 6cb8403 + 9174447 commit c6efacc

4 files changed

Lines changed: 26 additions & 17 deletions

File tree

src/dbSta/include/db_sta/dbNetwork.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class dbNetwork : public ConcreteNetwork
9393

9494
LibertyCell* libertyCell(Cell* cell) const override;
9595
const LibertyCell* libertyCell(const Cell* cell) const override;
96+
const LibertyCell* testCell(const Cell* cell) const;
9697
LibertyCell* libertyCell(odb::dbInst* inst);
9798
LibertyPort* libertyPort(const Pin*) const override;
9899
odb::dbInst* staToDb(const Instance* instance) const;
@@ -521,7 +522,6 @@ class dbNetwork : public ConcreteNetwork
521522
static constexpr unsigned DBIDTAG_WIDTH = 0x4;
522523

523524
private:
524-
const LibertyCell* getLibertyCell(const Cell* cell) const;
525525
void addDriverToCacheIfPresent(const Net* net, const Pin* drvr);
526526
void removeDriverFromCache(const Net* net);
527527
void removeDriverFromCache(const Net* net, const Pin* drvr);

src/dbSta/src/dbNetwork.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,7 +3496,7 @@ LibertyCell* dbNetwork::libertyCell(dbInst* inst)
34963496
return libertyCell(dbToSta(inst));
34973497
}
34983498

3499-
const LibertyCell* dbNetwork::getLibertyCell(const Cell* cell) const
3499+
const LibertyCell* dbNetwork::testCell(const Cell* cell) const
35003500
{
35013501
const LibertyCell* lib_cell = libertyCell(cell);
35023502
if (!lib_cell) {
@@ -5280,7 +5280,7 @@ bool dbNetwork::isClockPin(odb::dbITerm* iterm) const
52805280
bool dbNetwork::clockOn(odb::dbInst* inst) const
52815281
{
52825282
const Cell* cell = dbToSta(inst->getMaster());
5283-
const LibertyCell* lib_cell = getLibertyCell(cell);
5283+
const LibertyCell* lib_cell = testCell(cell);
52845284
if (!lib_cell) {
52855285
return false;
52865286
}
@@ -5359,7 +5359,7 @@ int dbNetwork::getNumD(odb::dbInst* inst) const
53595359
{
53605360
int cnt_d = 0;
53615361
const Cell* cell = dbToSta(inst->getMaster());
5362-
const LibertyCell* lib_cell = getLibertyCell(cell);
5362+
const LibertyCell* lib_cell = testCell(cell);
53635363
if (lib_cell == nullptr) {
53645364
return 0;
53655365
}
@@ -5423,7 +5423,7 @@ bool dbNetwork::isInvertingQPin(odb::dbITerm* iterm) const
54235423
{
54245424
odb::dbInst* inst = iterm->getInst();
54255425
const Cell* cell = dbToSta(inst->getMaster());
5426-
const LibertyCell* lib_cell = getLibertyCell(cell);
5426+
const LibertyCell* lib_cell = testCell(cell);
54275427
if (!lib_cell) {
54285428
return false;
54295429
}
@@ -5473,7 +5473,7 @@ int dbNetwork::getNumQ(odb::dbInst* inst) const
54735473
bool dbNetwork::hasClear(odb::dbInst* inst) const
54745474
{
54755475
const Cell* cell = dbToSta(inst->getMaster());
5476-
const LibertyCell* lib_cell = getLibertyCell(cell);
5476+
const LibertyCell* lib_cell = testCell(cell);
54775477
if (!lib_cell) {
54785478
return false;
54795479
}
@@ -5507,7 +5507,7 @@ bool dbNetwork::isClearPin(odb::dbITerm* iterm) const
55075507
bool dbNetwork::hasPreset(odb::dbInst* inst) const
55085508
{
55095509
const Cell* cell = dbToSta(inst->getMaster());
5510-
const LibertyCell* lib_cell = getLibertyCell(cell);
5510+
const LibertyCell* lib_cell = testCell(cell);
55115511
if (!lib_cell) {
55125512
return false;
55135513
}
@@ -5542,15 +5542,15 @@ bool dbNetwork::isPresetPin(odb::dbITerm* iterm) const
55425542
bool dbNetwork::isScanCell(odb::dbInst* inst) const
55435543
{
55445544
const Cell* cell = dbToSta(inst->getMaster());
5545-
const LibertyCell* lib_cell = getLibertyCell(cell);
5545+
const LibertyCell* lib_cell = testCell(cell);
55465546
return lib_cell && getLibertyScanIn(lib_cell)
55475547
&& getLibertyScanEnable(lib_cell);
55485548
}
55495549

55505550
bool dbNetwork::isScanIn(odb::dbITerm* iterm) const
55515551
{
55525552
const Cell* cell = dbToSta(iterm->getInst()->getMaster());
5553-
const LibertyCell* lib_cell = getLibertyCell(cell);
5553+
const LibertyCell* lib_cell = testCell(cell);
55545554
if (lib_cell && getLibertyScanIn(lib_cell)) {
55555555
odb::dbMTerm* mterm = staToDb(getLibertyScanIn(lib_cell));
55565556
return iterm->getInst()->getITerm(mterm) == iterm;
@@ -5561,7 +5561,7 @@ bool dbNetwork::isScanIn(odb::dbITerm* iterm) const
55615561
odb::dbITerm* dbNetwork::getScanIn(odb::dbInst* inst) const
55625562
{
55635563
const Cell* cell = dbToSta(inst->getMaster());
5564-
const LibertyCell* lib_cell = getLibertyCell(cell);
5564+
const LibertyCell* lib_cell = testCell(cell);
55655565
if (lib_cell && getLibertyScanIn(lib_cell)) {
55665566
odb::dbMTerm* mterm = staToDb(getLibertyScanIn(lib_cell));
55675567
return inst->getITerm(mterm);
@@ -5572,7 +5572,7 @@ odb::dbITerm* dbNetwork::getScanIn(odb::dbInst* inst) const
55725572
bool dbNetwork::isScanEnable(odb::dbITerm* iterm) const
55735573
{
55745574
const Cell* cell = dbToSta(iterm->getInst()->getMaster());
5575-
const LibertyCell* lib_cell = getLibertyCell(cell);
5575+
const LibertyCell* lib_cell = testCell(cell);
55765576
if (lib_cell && getLibertyScanEnable(lib_cell)) {
55775577
odb::dbMTerm* mterm = staToDb(getLibertyScanEnable(lib_cell));
55785578
return (iterm->getInst()->getITerm(mterm) == iterm);
@@ -5583,7 +5583,7 @@ bool dbNetwork::isScanEnable(odb::dbITerm* iterm) const
55835583
odb::dbITerm* dbNetwork::getScanEnable(odb::dbInst* inst) const
55845584
{
55855585
const Cell* cell = dbToSta(inst->getMaster());
5586-
const LibertyCell* lib_cell = getLibertyCell(cell);
5586+
const LibertyCell* lib_cell = testCell(cell);
55875587
if (lib_cell && getLibertyScanEnable(lib_cell)) {
55885588
odb::dbMTerm* mterm = staToDb(getLibertyScanEnable(lib_cell));
55895589
return inst->getITerm(mterm);
@@ -5602,7 +5602,7 @@ bool dbNetwork::isValidFlop(odb::dbInst* FF) const
56025602
if (cell == nullptr) {
56035603
return false;
56045604
}
5605-
const LibertyCell* lib_cell = getLibertyCell(cell);
5605+
const LibertyCell* lib_cell = testCell(cell);
56065606
if (lib_cell == nullptr || !lib_cell->hasSequentials()) {
56075607
return false;
56085608
}
@@ -5642,7 +5642,7 @@ bool dbNetwork::isValidTray(odb::dbInst* tray) const
56425642
if (cell == nullptr) {
56435643
return false;
56445644
}
5645-
const LibertyCell* lib_cell = getLibertyCell(cell);
5645+
const LibertyCell* lib_cell = testCell(cell);
56465646
if (lib_cell == nullptr || !lib_cell->hasSequentials()) {
56475647
return false;
56485648
}

src/gpl/src/mbff.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ MBFF::PortName MBFF::PortType(const sta::LibertyPort* lib_port, dbInst* inst)
207207
}
208208

209209
const sta::Cell* cell = network_->dbToSta(inst->getMaster());
210-
const sta::LibertyCell* lib_cell = network_->libertyCell(cell);
210+
const sta::LibertyCell* lib_cell = network_->testCell(cell);
211211
for (const sta::Sequential& seq : lib_cell->sequentials()) {
212212
// function
213213
if (sta::LibertyPort::equiv(lib_port, seq.output())) {
@@ -280,7 +280,7 @@ MBFF::Mask MBFF::GetArrayMask(dbInst* inst, const bool isTray)
280280
}
281281

282282
const sta::Cell* cell = network_->dbToSta(inst->getMaster());
283-
const sta::LibertyCell* lib_cell = network_->libertyCell(cell);
283+
const sta::LibertyCell* lib_cell = network_->testCell(cell);
284284
const auto& seqs = lib_cell->sequentials();
285285
if (!seqs.empty()) {
286286
ret.func_idx = GetMatchingFunc(seqs.front().data(), inst, isTray);
@@ -294,7 +294,7 @@ MBFF::Mask MBFF::GetArrayMask(dbInst* inst, const bool isTray)
294294
MBFF::DataToOutputsMap MBFF::GetPinMapping(dbInst* tray)
295295
{
296296
const sta::Cell* cell = network_->dbToSta(tray->getMaster());
297-
const sta::LibertyCell* lib_cell = network_->libertyCell(cell);
297+
const sta::LibertyCell* lib_cell = network_->testCell(cell);
298298
sta::LibertyCellPortIterator port_itr(lib_cell);
299299

300300
std::vector<const sta::LibertyPort*> d_pins;

src/gpl/test/mbff_test.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MBFFTestPeer
3131
{
3232
return uut->network_->isValidTray(tray);
3333
}
34+
static void ReadLibs(MBFF* uut) { uut->ReadLibs(); }
3435
};
3536

3637
namespace {
@@ -146,5 +147,13 @@ TEST_F(MBFFTestFixture, FlopsCanBeIdentifiedAsATrayAndNot)
146147
mbff_.get(), CreateTmpCell("test_tray", "test0", "MBFF2SECLPS")));
147148
}
148149

150+
TEST_F(MBFFTestFixture, ReadLibsSuccessfullyProcessesTestCells)
151+
{
152+
// In test0.lib, cells like MBFF2SE have their sequential definition
153+
// nested inside a test_cell block. Without consistent Liberty cell views,
154+
// GetPinMapping returns empty vectors and triggers an out-of-bounds crash.
155+
EXPECT_NO_FATAL_FAILURE(MBFFTestPeer::ReadLibs(mbff_.get()));
156+
}
157+
149158
} // namespace
150159
} // namespace gpl

0 commit comments

Comments
 (0)