newcelltypes: extend testing

This commit is contained in:
Emil J. Tywoniak 2025-11-27 03:32:41 +01:00
parent b340537796
commit 8f627d43fc
1 changed files with 12 additions and 6 deletions

View File

@ -14,24 +14,30 @@ TEST(CellTypesTest, basic)
log_files.push_back(stdout);
CellTypes older;
NewCellTypes newer;
log("setup nullptr\n");
older.setup(nullptr);
newer.setup(nullptr);
log("setup type bleh\n");
older.setup_type(ID(bleh), {ID::G}, {ID::H, ID::I}, false, true);
newer.setup_type(ID(bleh), {ID::G}, {ID::H, ID::I}, false, true);
EXPECT_EQ(older.cell_known(ID(aaaaa)), newer.cell_known(ID(aaaaa)));
EXPECT_EQ(older.cell_known(ID($and)), newer.cell_known(ID($and)));
auto check_port = [&](auto type, auto port) {
EXPECT_EQ(older.cell_port_dir(type, port), newer.cell_port_dir(type, port));
EXPECT_EQ(older.cell_input(type, port), newer.cell_input(type, port));
EXPECT_EQ(older.cell_output(type, port), newer.cell_output(type, port));
};
for (size_t i = 0; i < static_cast<size_t>(RTLIL::StaticId::STATIC_ID_END); i++) {
IdString type;
type.index_ = i;
if (older.cell_known(type) != newer.cell_known(type))
std::cout << i << " " << type.str() << "\n";
EXPECT_EQ(older.cell_known(type), newer.cell_known(type));
if (older.cell_evaluable(type) != newer.cell_evaluable(type))
std::cout << type.str() << "\n";
EXPECT_EQ(older.cell_evaluable(type), newer.cell_evaluable(type));
for (auto port : StaticCellTypes::builder.cells.data()->inputs.ports)
check_port(type, port);
for (auto port : StaticCellTypes::builder.cells.data()->outputs.ports)
check_port(type, port);
if (RTLIL::builtin_ff_cell_types().count(type) != StaticCellTypes::categories.is_ff(type))
std::cout << i << " " << type.str() << "\n";
EXPECT_EQ(RTLIL::builtin_ff_cell_types().count(type), StaticCellTypes::categories.is_ff(type));
}
yosys_shutdown();