Skip to content

Commit a56edf2

Browse files
authored
Merge pull request #345 from The-OpenROAD-Project-staging/sta_statetable_mbff_regression
Restore statetable check in hasSequentials and add MBFF regression test
2 parents defec0b + 097daeb commit a56edf2

2 files changed

Lines changed: 52 additions & 5 deletions

File tree

liberty/Liberty.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,8 @@ LibertyCell::outputPortSequential(LibertyPort *port)
14891489
bool
14901490
LibertyCell::hasSequentials() const
14911491
{
1492-
return !sequentials_.empty();
1492+
return !sequentials_.empty()
1493+
|| statetable_ != nullptr;
14931494
}
14941495

14951496
void
@@ -2477,10 +2478,8 @@ bool
24772478
LibertyPort::less(const LibertyPort *port1,
24782479
const LibertyPort *port2)
24792480
{
2480-
if (port1 == nullptr && port2 != nullptr)
2481-
return true;
2482-
if (port1 != nullptr && port2 == nullptr)
2483-
return false;
2481+
if (port1 == nullptr || port2 == nullptr)
2482+
return port1 == nullptr && port2 != nullptr;
24842483
const std::string &name1 = port1->name();
24852484
const std::string &name2 = port2->name();
24862485
if (name1 == name2) {

liberty/test/cpp/TestLibertyStaCallbacks.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,4 +4308,52 @@ library(test_r11_ccs) {
43084308
}() ));
43094309
}
43104310

4311+
// Regression: hasSequentials must return true for cells that define
4312+
// sequential behavior via a statetable group (no ff/latch).
4313+
// Multi-bit flip-flops (MBFFs) and clock-gated cells commonly use
4314+
// statetable instead of ff/latch groups. Without the statetable_
4315+
// check in hasSequentials(), these cells are misclassified as
4316+
// combinational — breaking power categorization, resizer guards,
4317+
// and dbSta cell-type mapping.
4318+
TEST_F(StaLibertyTest, HasSequentialsStatetableMBFF) {
4319+
const char *content = R"(
4320+
library(test_mbff_statetable) {
4321+
delay_model : table_lookup ;
4322+
time_unit : "1ns" ;
4323+
voltage_unit : "1V" ;
4324+
current_unit : "1mA" ;
4325+
capacitive_load_unit(1, ff) ;
4326+
cell(MBFF2) {
4327+
area : 6.0 ;
4328+
pin(D0) { direction : input ; capacitance : 0.01 ; }
4329+
pin(D1) { direction : input ; capacitance : 0.01 ; }
4330+
pin(CLK) { direction : input ; capacitance : 0.01 ; clock : true ; }
4331+
pin(Q0) { direction : output ; function : "IQ0" ; }
4332+
pin(Q1) { direction : output ; function : "IQ1" ; }
4333+
statetable("D0 D1 CLK", "IQ0 IQ1") {
4334+
table : "- - ~R : - - : N N ,\
4335+
H - R : - - : H N ,\
4336+
L - R : - - : L N ,\
4337+
- H R : - - : N H ,\
4338+
- L R : - - : N L" ;
4339+
}
4340+
}
4341+
}
4342+
)";
4343+
LibertyLibrary *lib = writeAndReadLibReturn(sta_, content);
4344+
ASSERT_NE(lib, nullptr);
4345+
LibertyCell *mbff = lib->findLibertyCell("MBFF2");
4346+
ASSERT_NE(mbff, nullptr);
4347+
4348+
// The cell has no ff/latch group, so sequentials_ is empty.
4349+
EXPECT_TRUE(mbff->sequentials().empty());
4350+
// But it has a statetable, so it IS sequential.
4351+
EXPECT_NE(mbff->statetable(), nullptr);
4352+
// hasSequentials() must return true for statetable-only cells.
4353+
EXPECT_TRUE(mbff->hasSequentials())
4354+
<< "MBFF2 uses statetable (no ff/latch) but hasSequentials() "
4355+
"returned false — statetable cells are misclassified as "
4356+
"combinational";
4357+
}
4358+
43114359
} // namespace sta

0 commit comments

Comments
 (0)