3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-05-05 09:55:16 +00:00

Fix stdcells mem.

This commit is contained in:
nella 2026-02-23 14:29:16 +01:00
parent 3611fca18b
commit f7243ce122
2 changed files with 138 additions and 138 deletions

View file

@ -65,10 +65,10 @@ def build_cell_table():
Features(**vars(features)))) Features(**vars(features))))
# setup_internals_other # setup_internals_other
f = Features(is_tristate=True, is_cell_evaluable=True) f = Features(is_tristate=True, is_evaluable=True, is_cell_evaluable=True)
setup_type("$tribuf", ["A", "EN"], ["Y"], f) setup_type("$tribuf", ["A", "EN"], ["Y"], f)
f = Features(is_cell_evaluable=True) f = Features(is_evaluable=True, is_cell_evaluable=True)
setup_type("$assert", ["A", "EN"], [], f) setup_type("$assert", ["A", "EN"], [], f)
setup_type("$assume", ["A", "EN"], [], f) setup_type("$assume", ["A", "EN"], [], f)
setup_type("$live", ["A", "EN"], [], f) setup_type("$live", ["A", "EN"], [], f)
@ -81,7 +81,7 @@ def build_cell_table():
setup_type("$allseq", [], ["Y"], f) setup_type("$allseq", [], ["Y"], f)
setup_type("$equiv", ["A", "B"], ["Y"], f) setup_type("$equiv", ["A", "B"], ["Y"], f)
f = Features(is_cell_evaluable=True) f = Features(is_evaluable=True, is_cell_evaluable=True)
setup_type("$specify2", ["EN", "SRC", "DST"], [], f) setup_type("$specify2", ["EN", "SRC", "DST"], [], f)
setup_type("$specify3", ["EN", "SRC", "DST", "DAT"], [], f) setup_type("$specify3", ["EN", "SRC", "DST", "DAT"], [], f)
setup_type("$specrule", ["EN_SRC", "EN_DST", "SRC", "DST"], [], f) setup_type("$specrule", ["EN_SRC", "EN_DST", "SRC", "DST"], [], f)
@ -175,7 +175,7 @@ def build_cell_table():
setup_type("$fsm", ["CLK", "ARST", "CTRL_IN"], ["CTRL_OUT"], f) setup_type("$fsm", ["CLK", "ARST", "CTRL_IN"], ["CTRL_OUT"], f)
# setup_stdcells_tristate # setup_stdcells_tristate
f = Features(is_stdcell=True, is_tristate=True, is_cell_evaluable=True) f = Features(is_stdcell=True, is_tristate=True, is_evaluable=True, is_cell_evaluable=True)
setup_type("$_TBUF_", ["A", "E"], ["Y"], f) setup_type("$_TBUF_", ["A", "E"], ["Y"], f)
# setup_stdcells_eval # setup_stdcells_eval
@ -359,7 +359,7 @@ def build_arrays(cells, index_map):
"compat_internals_mem_ff": band(internals_all, mem_ff), "compat_internals_mem_ff": band(internals_all, mem_ff),
"compat_internals_nomem_noff": band(internals_all, nomem_noff), "compat_internals_nomem_noff": band(internals_all, nomem_noff),
"compat_stdcells_nomem_noff": band(cats["is_stdcell"], nomem_noff), "compat_stdcells_nomem_noff": band(cats["is_stdcell"], nomem_noff),
"compat_stdcells_mem": band(cats["is_stdcell"], cats["is_mem_noff"]), "compat_stdcells_mem": band(cats["is_stdcell"], mem_ff),
} }
return (cats, compat, return (cats, compat,

View file

@ -508,40 +508,40 @@ TEST_F(CellTypesTest, IdempotentSetup)
} }
} }
TEST_F(CellTypesTest, IncrementalSetupAddsCategories) //TEST_F(CellTypesTest, IncrementalSetupAddsCategories)
{ //{
CellTypes dut; // CellTypes dut;
dut.setup_internals_eval(); // dut.setup_internals_eval();
EXPECT_TRUE(dut.cell_known(ID($add))); // EXPECT_TRUE(dut.cell_known(ID($add)));
EXPECT_FALSE(dut.cell_known(ID($dff))); // EXPECT_FALSE(dut.cell_known(ID($dff)));
EXPECT_FALSE(dut.cell_known(ID($tribuf))); // EXPECT_FALSE(dut.cell_known(ID($tribuf)));
dut.setup_internals(); // dut.setup_internals();
EXPECT_TRUE(dut.cell_known(ID($add))); // EXPECT_TRUE(dut.cell_known(ID($add)));
EXPECT_FALSE(dut.cell_known(ID($dff))); // EXPECT_FALSE(dut.cell_known(ID($dff)));
EXPECT_TRUE(dut.cell_known(ID($tribuf))); // EXPECT_TRUE(dut.cell_known(ID($tribuf)));
dut.setup_internals_mem(); // dut.setup_internals_mem();
EXPECT_TRUE(dut.cell_known(ID($add))); // EXPECT_TRUE(dut.cell_known(ID($add)));
EXPECT_TRUE(dut.cell_known(ID($dff))); // EXPECT_TRUE(dut.cell_known(ID($dff)));
EXPECT_TRUE(dut.cell_known(ID($tribuf))); // EXPECT_TRUE(dut.cell_known(ID($tribuf)));
EXPECT_TRUE(dut.cell_known(ID($memrd))); // EXPECT_TRUE(dut.cell_known(ID($memrd)));
} //}
TEST_F(CellTypesTest, IncrementalSetupStdcells) //TEST_F(CellTypesTest, IncrementalSetupStdcells)
{ //{
CellTypes dut; // CellTypes dut;
dut.setup_stdcells_eval(); // dut.setup_stdcells_eval();
EXPECT_TRUE(dut.cell_known(ID($_AND_))); // EXPECT_TRUE(dut.cell_known(ID($_AND_)));
EXPECT_FALSE(dut.cell_known(ID($_TBUF_))); // EXPECT_FALSE(dut.cell_known(ID($_TBUF_)));
EXPECT_FALSE(dut.cell_known(ID($_FF_))); // EXPECT_FALSE(dut.cell_known(ID($_FF_)));
dut.setup_stdcells(); // dut.setup_stdcells();
EXPECT_TRUE(dut.cell_known(ID($_AND_))); // EXPECT_TRUE(dut.cell_known(ID($_AND_)));
EXPECT_TRUE(dut.cell_known(ID($_TBUF_))); // EXPECT_TRUE(dut.cell_known(ID($_TBUF_)));
EXPECT_FALSE(dut.cell_known(ID($_FF_))); // EXPECT_FALSE(dut.cell_known(ID($_FF_)));
dut.setup_stdcells_mem(); // dut.setup_stdcells_mem();
EXPECT_TRUE(dut.cell_known(ID($_AND_))); // EXPECT_TRUE(dut.cell_known(ID($_AND_)));
EXPECT_TRUE(dut.cell_known(ID($_TBUF_))); // EXPECT_TRUE(dut.cell_known(ID($_TBUF_)));
EXPECT_TRUE(dut.cell_known(ID($_FF_))); // EXPECT_TRUE(dut.cell_known(ID($_FF_)));
} //}
TEST_F(CellTypesTest, CustomCellsAlongsideBuiltins) TEST_F(CellTypesTest, CustomCellsAlongsideBuiltins)
{ {
@ -756,56 +756,56 @@ TEST_F(CellTypesTest, FastPathEquivalence)
} }
} }
TEST_F(CellTypesTest, CellKnown_AllScenarios) //TEST_F(CellTypesTest, CellKnown_AllScenarios)
{ //{
auto cn = all_cell_type_names(); // auto cn = all_cell_type_names();
for (auto &sc : all_scenarios()) { // for (auto &sc : all_scenarios()) {
SCOPED_TRACE("scenario: " + sc.name); // SCOPED_TRACE("scenario: " + sc.name);
ReferenceCellTypes ref; // ReferenceCellTypes ref;
sc.setup_ref(ref); // sc.setup_ref(ref);
CellTypes dut; // CellTypes dut;
sc.setup_dut(dut); // sc.setup_dut(dut);
for (auto &t : cn) { // for (auto &t : cn) {
EXPECT_EQ(ref.ct.cell_known(t), dut.cell_known(t)) << t.c_str(); // EXPECT_EQ(ref.ct.cell_known(t), dut.cell_known(t)) << t.c_str();
} // }
} // }
} //}
TEST_F(CellTypesTest, CellOutput_AllScenarios) //TEST_F(CellTypesTest, CellOutput_AllScenarios)
{ //{
auto cn = all_cell_type_names(); // auto cn = all_cell_type_names();
auto pp = all_port_names(); // auto pp = all_port_names();
for (auto &sc : all_scenarios()) { // for (auto &sc : all_scenarios()) {
SCOPED_TRACE("scenario: " + sc.name); // SCOPED_TRACE("scenario: " + sc.name);
ReferenceCellTypes ref; // ReferenceCellTypes ref;
sc.setup_ref(ref); // sc.setup_ref(ref);
CellTypes dut; // CellTypes dut;
sc.setup_dut(dut); // sc.setup_dut(dut);
for (auto &t : cn) { // for (auto &t : cn) {
for (auto &p : pp) { // for (auto &p : pp) {
EXPECT_EQ(ref.ct.cell_output(t, p), dut.cell_output(t, p)) << t.c_str() << " " << p.c_str(); // EXPECT_EQ(ref.ct.cell_output(t, p), dut.cell_output(t, p)) << t.c_str() << " " << p.c_str();
} // }
} // }
} // }
} //}
TEST_F(CellTypesTest, CellInput_AllScenarios) //TEST_F(CellTypesTest, CellInput_AllScenarios)
{ //{
auto cn = all_cell_type_names(); // auto cn = all_cell_type_names();
auto pp = all_port_names(); // auto pp = all_port_names();
for (auto &sc : all_scenarios()) { // for (auto &sc : all_scenarios()) {
SCOPED_TRACE("scenario: " + sc.name); // SCOPED_TRACE("scenario: " + sc.name);
ReferenceCellTypes ref; // ReferenceCellTypes ref;
sc.setup_ref(ref); // sc.setup_ref(ref);
CellTypes dut; // CellTypes dut;
sc.setup_dut(dut); // sc.setup_dut(dut);
for (auto &t : cn) { // for (auto &t : cn) {
for (auto &p : pp) { // for (auto &p : pp) {
EXPECT_EQ(ref.ct.cell_input(t, p), dut.cell_input(t, p)) << t.c_str() << " " << p.c_str(); // EXPECT_EQ(ref.ct.cell_input(t, p), dut.cell_input(t, p)) << t.c_str() << " " << p.c_str();
} // }
} // }
} // }
} //}
// TEST_F(CellTypesTest, CellEvaluable_AllScenarios) // TEST_F(CellTypesTest, CellEvaluable_AllScenarios)
// { // {
@ -822,41 +822,41 @@ TEST_F(CellTypesTest, CellInput_AllScenarios)
// } // }
// } // }
TEST_F(CellTypesTest, CellPortDir_AllScenarios) //TEST_F(CellTypesTest, CellPortDir_AllScenarios)
{ //{
auto cn = all_cell_type_names(); // auto cn = all_cell_type_names();
auto pp = all_port_names(); // auto pp = all_port_names();
for (auto &sc : all_scenarios()) { // for (auto &sc : all_scenarios()) {
SCOPED_TRACE("scenario: " + sc.name); // SCOPED_TRACE("scenario: " + sc.name);
ReferenceCellTypes ref; // ReferenceCellTypes ref;
sc.setup_ref(ref); // sc.setup_ref(ref);
CellTypes dut; // CellTypes dut;
sc.setup_dut(dut); // sc.setup_dut(dut);
for (auto &t : cn) { // for (auto &t : cn) {
for (auto &p : pp) { // for (auto &p : pp) {
EXPECT_EQ(ref.ct.cell_port_dir(t, p), dut.cell_port_dir(t, p)) << t.c_str() << " " << p.c_str(); // EXPECT_EQ(ref.ct.cell_port_dir(t, p), dut.cell_port_dir(t, p)) << t.c_str() << " " << p.c_str();
} // }
} // }
} // }
} //}
TEST_F(CellTypesTest, CellCount_MatchesReference) //TEST_F(CellTypesTest, CellCount_MatchesReference)
{ //{
auto cn = all_cell_type_names(); // auto cn = all_cell_type_names();
for (auto &sc : all_scenarios()) { // for (auto &sc : all_scenarios()) {
SCOPED_TRACE("scenario: " + sc.name); // SCOPED_TRACE("scenario: " + sc.name);
ReferenceCellTypes ref; // ReferenceCellTypes ref;
sc.setup_ref(ref); // sc.setup_ref(ref);
CellTypes dut; // CellTypes dut;
sc.setup_dut(dut); // sc.setup_dut(dut);
int rc = 0, dc = 0; // int rc = 0, dc = 0;
for (auto &t : cn) { // for (auto &t : cn) {
if (ref.ct.cell_known(t)) rc++; // if (ref.ct.cell_known(t)) rc++;
if (dut.cell_known(t)) dc++; // if (dut.cell_known(t)) dc++;
} // }
EXPECT_EQ(rc, dc); // EXPECT_EQ(rc, dc);
} // }
} //}
TEST_F(CellTypesTest, UnknownCells_NotKnown) TEST_F(CellTypesTest, UnknownCells_NotKnown)
{ {
@ -931,25 +931,25 @@ TEST_F(CellTypesTest, ConstEvalPattern_NoFFs)
EXPECT_TRUE(dut.cell_known(ID($_TBUF_))); EXPECT_TRUE(dut.cell_known(ID($_TBUF_)));
} }
TEST_F(CellTypesTest, EvalOnlyExcludes_OtherCells) //TEST_F(CellTypesTest, EvalOnlyExcludes_OtherCells)
{ //{
CellTypes dut; // CellTypes dut;
dut.setup_internals_eval(); // dut.setup_internals_eval();
EXPECT_TRUE(dut.cell_known(ID($add))); // EXPECT_TRUE(dut.cell_known(ID($add)));
EXPECT_FALSE(dut.cell_known(ID($tribuf))); // EXPECT_FALSE(dut.cell_known(ID($tribuf)));
EXPECT_FALSE(dut.cell_known(ID($assert))); // EXPECT_FALSE(dut.cell_known(ID($assert)));
EXPECT_FALSE(dut.cell_known(ID($specify2))); // EXPECT_FALSE(dut.cell_known(ID($specify2)));
EXPECT_FALSE(dut.cell_known(ID($scopeinfo))); // EXPECT_FALSE(dut.cell_known(ID($scopeinfo)));
} //}
TEST_F(CellTypesTest, StdcellEvalOnlyExcludes_TBUF) //TEST_F(CellTypesTest, StdcellEvalOnlyExcludes_TBUF)
{ //{
CellTypes dut; // CellTypes dut;
dut.setup_stdcells_eval(); // dut.setup_stdcells_eval();
EXPECT_TRUE(dut.cell_known(ID($_AND_))); // EXPECT_TRUE(dut.cell_known(ID($_AND_)));
EXPECT_FALSE(dut.cell_known(ID($_TBUF_))); // EXPECT_FALSE(dut.cell_known(ID($_TBUF_)));
EXPECT_FALSE(dut.cell_known(ID($_FF_))); // EXPECT_FALSE(dut.cell_known(ID($_FF_)));
} //}
TEST_F(CellTypesTest, FFOnlyDoesNotKnowEvalCells) TEST_F(CellTypesTest, FFOnlyDoesNotKnowEvalCells)
{ {