Skip to content

Commit 2c94ca8

Browse files
committed
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.
1 parent b8b0f80 commit 2c94ca8

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

passes/cmds/portarcs.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct PortarcsPass : Pass {
125125

126126
for (auto cell : m->cells())
127127
// Ignore all bufnorm helper cells
128-
if (!cell->type.in(ID($buf), ID($input_port), ID($connect))) {
128+
if (!cell->type.in(ID($buf), ID($input_port), ID($connect), ID($tribuf))) {
129129
auto tdata = tinfo.find(cell->type);
130130
if (tdata == tinfo.end())
131131
log_cmd_error("Missing timing data for module '%s'.\n", log_id(cell->type));

passes/techmap/abc9_ops.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ static void replace_zbufs(Design *design)
16051605

16061606
mod->bufNormalize();
16071607
}
1608+
design->bufNormalize(false);
16081609
}
16091610

16101611

@@ -1624,7 +1625,6 @@ static void restore_zbufs(Design *design)
16241625
mod->addBuf(NEW_ID, Const(State::Sz, GetSize(sig_y)), sig_y);
16251626
mod->remove(cell);
16261627
}
1627-
mod->bufNormalize();
16281628
}
16291629
}
16301630

passes/techmap/abc_new.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ struct AbcNewPass : public ScriptPass {
141141
selected_modules = order_modules(active_design,
142142
active_design->selected_whole_modules_warn());
143143
active_design->push_empty_selection();
144-
} else {
144+
}
145+
146+
run("abc9_ops -replace_zbufs");
147+
148+
if (help_mode) {
145149
selected_modules = {nullptr};
146150
run("foreach module in selection");
147151
}
@@ -169,13 +173,10 @@ struct AbcNewPass : public ScriptPass {
169173
}
170174

171175
run(stringf(" abc9_ops -write_box %s/input.box", tmpdir));
172-
run(" abc9_ops -replace_zbufs");
173176
run(stringf(" write_xaiger2 -mapping_prep -map2 %s/input.map2 %s/input.xaig", tmpdir, tmpdir));
174177
run(stringf(" abc9_exe %s -cwd %s -box %s/input.box", exe_options, tmpdir, tmpdir));
175178
run(stringf(" read_xaiger2 -sc_mapping -module_name %s -map2 %s/input.map2 %s/output.aig",
176179
modname.c_str(), tmpdir.c_str(), tmpdir.c_str()));
177-
run(" abc9_ops -restore_zbufs");
178-
179180
if (!help_mode && mod->has_attribute(ID(abc9_script))) {
180181
if (script_save.empty())
181182
active_design->scratchpad_unset("abc9.script");
@@ -196,6 +197,8 @@ struct AbcNewPass : public ScriptPass {
196197
}
197198
}
198199

200+
run("abc9_ops -restore_zbufs");
201+
199202
if (!help_mode) {
200203
active_design->pop_selection();
201204
}

0 commit comments

Comments
 (0)