mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-18 20:03:39 +00:00
cutpoint.cc: Fold -instances into -blackbox
Replace `cutpoint -blackbox` behaviour with `cutpoint -blackbox -instances` behaviour. Drop `-instances` flag. Add `-noscopeinfo` flag. Use `RTLIL::Selection::boxed_module()` helper to shortcut blackbox check. Update `cutpoint_blackbox.ys` tests to match.
This commit is contained in:
parent
779a1fddf6
commit
87d3b09988
2 changed files with 29 additions and 81 deletions
|
@ -37,19 +37,20 @@ struct CutpointPass : public Pass {
|
||||||
log(" set cutpoint nets to undef (x). the default behavior is to create\n");
|
log(" set cutpoint nets to undef (x). the default behavior is to create\n");
|
||||||
log(" an $anyseq cell and drive the cutpoint net from that\n");
|
log(" an $anyseq cell and drive the cutpoint net from that\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -noscopeinfo\n");
|
||||||
|
log(" do not create '$scopeinfo' cells that preserve attributes of cells that\n");
|
||||||
|
log(" were removed by this pass\n");
|
||||||
|
log("\n");
|
||||||
log(" cutpoint -blackbox [options]\n");
|
log(" cutpoint -blackbox [options]\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log("Replace the contents of all blackboxes in the design with a formal cut point.\n");
|
log("Replace all instances of blackboxes in the design with a formal cut point.\n");
|
||||||
log("\n");
|
|
||||||
log(" -instances\n");
|
|
||||||
log(" replace instances of blackboxes instead of the modules\n");
|
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||||
{
|
{
|
||||||
bool flag_undef = false;
|
bool flag_undef = false;
|
||||||
|
bool flag_scopeinfo = true;
|
||||||
bool flag_blackbox = false;
|
bool flag_blackbox = false;
|
||||||
bool flag_instances = false;
|
|
||||||
|
|
||||||
log_header(design, "Executing CUTPOINT pass.\n");
|
log_header(design, "Executing CUTPOINT pass.\n");
|
||||||
|
|
||||||
|
@ -60,61 +61,31 @@ struct CutpointPass : public Pass {
|
||||||
flag_undef = true;
|
flag_undef = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[argidx] == "-blackbox") {
|
if (args[argidx] == "-noscopeinfo") {
|
||||||
flag_blackbox = true;
|
flag_scopeinfo = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (args[argidx] == "-instances") {
|
if (args[argidx] == "-blackbox") {
|
||||||
flag_instances = true;
|
flag_blackbox = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
extra_args(args, argidx, design);
|
extra_args(args, argidx, design);
|
||||||
|
|
||||||
if (flag_instances && !flag_blackbox) {
|
|
||||||
log_cmd_error("-instances flag only valid with -blackbox!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flag_blackbox) {
|
if (flag_blackbox) {
|
||||||
if (!design->full_selection())
|
if (!design->full_selection())
|
||||||
log_cmd_error("This command only operates on fully selected designs!\n");
|
log_cmd_error("This command only operates on fully selected designs!\n");
|
||||||
design->push_empty_selection();
|
design->push_empty_selection();
|
||||||
|
auto &selection = design->selection();
|
||||||
for (auto module : design->modules())
|
for (auto module : design->modules())
|
||||||
if (flag_instances) {
|
for (auto cell : module->cells())
|
||||||
for (auto cell : module->cells()) {
|
if (selection.boxed_module(cell->type))
|
||||||
auto mod = design->module(cell->type);
|
selection.select(module, cell);
|
||||||
if (mod != nullptr && mod->get_blackbox_attribute())
|
|
||||||
design->select(module, cell);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (module->get_blackbox_attribute())
|
|
||||||
design->select(module);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto module : design->all_selected_modules())
|
for (auto module : design->all_selected_modules())
|
||||||
{
|
{
|
||||||
if (module->is_selected_whole() && !flag_instances) {
|
|
||||||
log("Making all outputs of module %s cut points, removing module contents.\n", log_id(module));
|
|
||||||
module->new_connections(std::vector<RTLIL::SigSig>());
|
|
||||||
for (auto cell : vector<Cell*>(module->cells()))
|
|
||||||
module->remove(cell);
|
|
||||||
vector<Wire*> output_wires;
|
|
||||||
for (auto wire : module->wires())
|
|
||||||
if (wire->port_output)
|
|
||||||
output_wires.push_back(wire);
|
|
||||||
for (auto wire : output_wires)
|
|
||||||
module->connect(wire, flag_undef ? Const(State::Sx, GetSize(wire)) : module->Anyseq(NEW_ID, GetSize(wire)));
|
|
||||||
if (module->get_blackbox_attribute()) {
|
|
||||||
module->set_bool_attribute(ID::blackbox, false);
|
|
||||||
module->set_bool_attribute(ID::whitebox, false);
|
|
||||||
auto scopeinfo = module->addCell(NEW_ID, ID($scopeinfo));
|
|
||||||
scopeinfo->setParam(ID::TYPE, RTLIL::Const("blackbox"));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SigMap sigmap(module);
|
SigMap sigmap(module);
|
||||||
pool<SigBit> cutpoint_bits;
|
pool<SigBit> cutpoint_bits;
|
||||||
|
|
||||||
|
@ -129,7 +100,7 @@ struct CutpointPass : public Pass {
|
||||||
|
|
||||||
RTLIL::Cell *scopeinfo = nullptr;
|
RTLIL::Cell *scopeinfo = nullptr;
|
||||||
auto cell_name = cell->name;
|
auto cell_name = cell->name;
|
||||||
if (flag_instances && cell_name.isPublic()) {
|
if (flag_scopeinfo && cell_name.isPublic()) {
|
||||||
auto scopeinfo = module->addCell(NEW_ID, ID($scopeinfo));
|
auto scopeinfo = module->addCell(NEW_ID, ID($scopeinfo));
|
||||||
scopeinfo->setParam(ID::TYPE, RTLIL::Const("blackbox"));
|
scopeinfo->setParam(ID::TYPE, RTLIL::Const("blackbox"));
|
||||||
|
|
||||||
|
|
|
@ -28,20 +28,25 @@ EOT
|
||||||
hierarchy -top top
|
hierarchy -top top
|
||||||
design -save hier
|
design -save hier
|
||||||
|
|
||||||
select -assert-count 0 t:$anyseq
|
select -assert-none t:$anyseq
|
||||||
select -assert-count 3 =t:?b
|
select -assert-count 3 =t:?b
|
||||||
cutpoint -blackbox
|
cutpoint -blackbox
|
||||||
|
|
||||||
select -assert-count 3 =t:?b
|
select -assert-none =t:?b
|
||||||
select -assert-count 2 r:SOME_PARAM
|
select -assert-none r:SOME_PARAM
|
||||||
select -assert-count 1 r:SOME_PARAM=1
|
|
||||||
|
|
||||||
flatten
|
|
||||||
select -assert-count 3 t:$anyseq
|
select -assert-count 3 t:$anyseq
|
||||||
|
select -assert-count 3 t:$scopeinfo
|
||||||
|
select -assert-count 3 t:$scopeinfo r:TYPE=blackbox %i
|
||||||
select -assert-count 3 t:$scopeinfo n:*cutpoint.cc* %i
|
select -assert-count 3 t:$scopeinfo n:*cutpoint.cc* %i
|
||||||
|
|
||||||
# cutpoint -blackbox === cutpoint =A:whitebox =A:blackbox %u
|
# -noscopeinfo works with -blackbox
|
||||||
# (simplified to =A:*box)
|
design -load hier
|
||||||
|
cutpoint -blackbox -noscopeinfo
|
||||||
|
select -assert-none t:$scopeinfo
|
||||||
|
|
||||||
|
# cutpoint -blackbox === cutpoint =A:whitebox =A:blackbox %u %C
|
||||||
|
# (simplified to =A:*box %C)
|
||||||
design -load hier
|
design -load hier
|
||||||
cutpoint -blackbox
|
cutpoint -blackbox
|
||||||
rename -enumerate -pattern A_% t:$scopeinfo
|
rename -enumerate -pattern A_% t:$scopeinfo
|
||||||
|
@ -50,33 +55,6 @@ rename -enumerate -pattern C_% w:*Anyseq*
|
||||||
design -save gold
|
design -save gold
|
||||||
select -write cutpoint.gold.sel =*
|
select -write cutpoint.gold.sel =*
|
||||||
|
|
||||||
design -load hier
|
|
||||||
cutpoint =A:*box
|
|
||||||
rename -enumerate -pattern A_% t:$scopeinfo
|
|
||||||
rename -enumerate -pattern B_% t:$anyseq
|
|
||||||
rename -enumerate -pattern C_% w:*Anyseq*
|
|
||||||
design -save gate
|
|
||||||
select -write cutpoint.gate.sel
|
|
||||||
select -read cutpoint.gold.sel
|
|
||||||
# nothing in gate but not gold
|
|
||||||
select -assert-none % %n
|
|
||||||
|
|
||||||
design -load gold
|
|
||||||
select -read cutpoint.gate.sel
|
|
||||||
# nothing in gold but not gate
|
|
||||||
select -assert-none % %n
|
|
||||||
|
|
||||||
# cutpoint -blackbox -instances !== cutpoint =A:whitebox =A:blackbox %u %C
|
|
||||||
# (simplified to =A:*box %C)
|
|
||||||
# because cutpoint -blackbox -instances adds $scopeinfo cells
|
|
||||||
design -load hier
|
|
||||||
cutpoint -blackbox -instances
|
|
||||||
rename -enumerate -pattern A_% t:$scopeinfo
|
|
||||||
rename -enumerate -pattern B_% t:$anyseq
|
|
||||||
rename -enumerate -pattern C_% w:*Anyseq*
|
|
||||||
design -save gold
|
|
||||||
select -write cutpoint.gold.sel =*
|
|
||||||
|
|
||||||
design -load hier
|
design -load hier
|
||||||
cutpoint =A:*box %C
|
cutpoint =A:*box %C
|
||||||
rename -enumerate -pattern A_% t:$scopeinfo
|
rename -enumerate -pattern A_% t:$scopeinfo
|
||||||
|
@ -90,6 +68,5 @@ select -assert-none % %n
|
||||||
|
|
||||||
design -load gold
|
design -load gold
|
||||||
select -read cutpoint.gate.sel
|
select -read cutpoint.gate.sel
|
||||||
# 3 $scopeinfo in gold but not gate
|
# nothing in gold but not gate
|
||||||
select -assert-count 3 % %n
|
select -assert-none % %n
|
||||||
select -assert-count 3 t:$scopeinfo
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue