From 7bff8b63b366e1e9c8308a235133600afac757e8 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 25 Apr 2023 12:39:00 +0200 Subject: [PATCH] rename: Fix renaming cells in -witness mode This was renaming cells while iterating over them which would always cause an assertion failure. Apparently having to rename cells to make all witness signals public is rarely required, so this slipped through. --- passes/cmds/rename.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/passes/cmds/rename.cc b/passes/cmds/rename.cc index 45576c91c..6bd317ed0 100644 --- a/passes/cmds/rename.cc +++ b/passes/cmds/rename.cc @@ -116,6 +116,8 @@ static bool rename_witness(RTLIL::Design *design, dict &ca } cache.emplace(module, -1); + std::vector> renames; + bool has_witness_signals = false; for (auto cell : module->cells()) { @@ -130,8 +132,9 @@ static bool rename_witness(RTLIL::Design *design, dict &ca c = '_'; auto new_id = module->uniquify("\\_witness_." + name); cell->set_hdlname_attribute({ "_witness_", strstr(new_id.c_str(), ".") + 1 }); - module->rename(cell, new_id); + renames.emplace_back(cell, new_id); } + break; } if (cell->type.in(ID($anyconst), ID($anyseq), ID($anyinit), ID($allconst), ID($allseq))) { @@ -155,6 +158,9 @@ static bool rename_witness(RTLIL::Design *design, dict &ca } } } + for (auto rename : renames) { + module->rename(rename.first, rename.second); + } cache[module] = has_witness_signals; return has_witness_signals;