3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-10-09 09:21:58 +00:00

abc_new: Avoid bufnorm helper cell churn

We were performing the helper passes `abc9_ops -replace_zbufs` and
`abc9_ops -restore_zbufs` for every module, but those passes act on the
full design (and can't be applied entirely selectively due to entering
and leaving bufnorm).

This lead to an explosive creation of a lot of redundant bufnorm helper
cells that would have been cleaned up by `clean` but that never ran.
Instead we now run each helper pass once, one before and one after
iterating over the selected modules. This limits the number of bufnorm
helper cells.
This commit is contained in:
Jannis Harder 2025-10-07 17:35:32 +02:00
parent b8b0f80f79
commit 2c94ca85d9
3 changed files with 9 additions and 6 deletions

View file

@ -125,7 +125,7 @@ struct PortarcsPass : Pass {
for (auto cell : m->cells())
// Ignore all bufnorm helper cells
if (!cell->type.in(ID($buf), ID($input_port), ID($connect))) {
if (!cell->type.in(ID($buf), ID($input_port), ID($connect), ID($tribuf))) {
auto tdata = tinfo.find(cell->type);
if (tdata == tinfo.end())
log_cmd_error("Missing timing data for module '%s'.\n", log_id(cell->type));

View file

@ -1605,6 +1605,7 @@ static void replace_zbufs(Design *design)
mod->bufNormalize();
}
design->bufNormalize(false);
}
@ -1624,7 +1625,6 @@ static void restore_zbufs(Design *design)
mod->addBuf(NEW_ID, Const(State::Sz, GetSize(sig_y)), sig_y);
mod->remove(cell);
}
mod->bufNormalize();
}
}

View file

@ -141,7 +141,11 @@ struct AbcNewPass : public ScriptPass {
selected_modules = order_modules(active_design,
active_design->selected_whole_modules_warn());
active_design->push_empty_selection();
} else {
}
run("abc9_ops -replace_zbufs");
if (help_mode) {
selected_modules = {nullptr};
run("foreach module in selection");
}
@ -169,13 +173,10 @@ struct AbcNewPass : public ScriptPass {
}
run(stringf(" abc9_ops -write_box %s/input.box", tmpdir));
run(" abc9_ops -replace_zbufs");
run(stringf(" write_xaiger2 -mapping_prep -map2 %s/input.map2 %s/input.xaig", tmpdir, tmpdir));
run(stringf(" abc9_exe %s -cwd %s -box %s/input.box", exe_options, tmpdir, tmpdir));
run(stringf(" read_xaiger2 -sc_mapping -module_name %s -map2 %s/input.map2 %s/output.aig",
modname.c_str(), tmpdir.c_str(), tmpdir.c_str()));
run(" abc9_ops -restore_zbufs");
if (!help_mode && mod->has_attribute(ID(abc9_script))) {
if (script_save.empty())
active_design->scratchpad_unset("abc9.script");
@ -196,6 +197,8 @@ struct AbcNewPass : public ScriptPass {
}
}
run("abc9_ops -restore_zbufs");
if (!help_mode) {
active_design->pop_selection();
}