mirror of
https://github.com/YosysHQ/yosys
synced 2025-05-12 10:14:43 +00:00
setundef: Add -blackbox option
If used, all instances of blackboxes in a module will be removed via `cutpoint -undef`. The undef wires can then be handled as usual by `setundef`. e.g. `setundef -blackbox -anyseq` will remove instances of blackboxes and replace their outputs with `$anyseq` cells.
This commit is contained in:
parent
4bd6061709
commit
15b142371c
1 changed files with 29 additions and 0 deletions
|
@ -147,6 +147,10 @@ struct SetundefPass : public Pass {
|
||||||
log(" -params\n");
|
log(" -params\n");
|
||||||
log(" replace undef in cell parameters\n");
|
log(" replace undef in cell parameters\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
|
log(" -blackbox\n");
|
||||||
|
log(" remove instances of blackbox modules in selection and treat their\n");
|
||||||
|
log(" outputs as undef by calling `cutpoint -undef`\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
|
||||||
{
|
{
|
||||||
|
@ -155,6 +159,7 @@ struct SetundefPass : public Pass {
|
||||||
bool expose_mode = false;
|
bool expose_mode = false;
|
||||||
bool init_mode = false;
|
bool init_mode = false;
|
||||||
bool params_mode = false;
|
bool params_mode = false;
|
||||||
|
bool blackbox_mode = false;
|
||||||
SetundefWorker worker;
|
SetundefWorker worker;
|
||||||
|
|
||||||
log_header(design, "Executing SETUNDEF pass (replace undef values with defined constants).\n");
|
log_header(design, "Executing SETUNDEF pass (replace undef values with defined constants).\n");
|
||||||
|
@ -208,6 +213,10 @@ struct SetundefPass : public Pass {
|
||||||
params_mode = true;
|
params_mode = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (args[argidx] == "-blackbox") {
|
||||||
|
blackbox_mode = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (args[argidx] == "-random" && argidx+1 < args.size()) {
|
if (args[argidx] == "-random" && argidx+1 < args.size()) {
|
||||||
got_value++;
|
got_value++;
|
||||||
worker.next_bit_mode = MODE_RANDOM;
|
worker.next_bit_mode = MODE_RANDOM;
|
||||||
|
@ -227,6 +236,13 @@ struct SetundefPass : public Pass {
|
||||||
worker.next_bit_state = 0;
|
worker.next_bit_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!got_value && blackbox_mode) {
|
||||||
|
log("Using default as -undef with -blackbox.\n");
|
||||||
|
got_value++;
|
||||||
|
worker.next_bit_mode = MODE_UNDEF;
|
||||||
|
worker.next_bit_state = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (expose_mode && !undriven_mode)
|
if (expose_mode && !undriven_mode)
|
||||||
log_cmd_error("Option -expose must be used with option -undriven.\n");
|
log_cmd_error("Option -expose must be used with option -undriven.\n");
|
||||||
if (!got_value)
|
if (!got_value)
|
||||||
|
@ -239,6 +255,19 @@ struct SetundefPass : public Pass {
|
||||||
|
|
||||||
for (auto module : design->selected_modules())
|
for (auto module : design->selected_modules())
|
||||||
{
|
{
|
||||||
|
if (blackbox_mode)
|
||||||
|
{
|
||||||
|
RTLIL::Selection module_boxes(false);
|
||||||
|
for (auto *cell : module->selected_cells()) {
|
||||||
|
auto mod = design->module(cell->type);
|
||||||
|
if (mod != nullptr && mod->get_blackbox_attribute())
|
||||||
|
module_boxes.select(module, cell);
|
||||||
|
}
|
||||||
|
log_push();
|
||||||
|
call_on_selection(design, module_boxes, "cutpoint -undef");
|
||||||
|
log_pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (params_mode)
|
if (params_mode)
|
||||||
{
|
{
|
||||||
for (auto *cell : module->selected_cells()) {
|
for (auto *cell : module->selected_cells()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue