aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelina Koƛcielnicka <mwk@0x04.net>2021-08-22 17:01:58 +0200
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-08-22 18:34:11 +0200
commit9cbff3a4a972f359d3842b689e135d4f906d763b (patch)
treefe6d45578321155dcf9fdb030b16d8f9ba50feb4
parent62d41d46397a93d1efa2b8282203d192b256d824 (diff)
downloadyosys-9cbff3a4a972f359d3842b689e135d4f906d763b.tar.gz
yosys-9cbff3a4a972f359d3842b689e135d4f906d763b.tar.bz2
yosys-9cbff3a4a972f359d3842b689e135d4f906d763b.zip
opt_merge: Remove and reinsert init when connecting nets.
Mutating the SigMap by adding a new connection will throw off FfInitVals index. Work around this by removing the relevant init values from index whenever we connect nets, then re-add the new init value. Should fix #2920.
-rw-r--r--passes/opt/opt_merge.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/passes/opt/opt_merge.cc b/passes/opt/opt_merge.cc
index d9861f49b..115eb97a9 100644
--- a/passes/opt/opt_merge.cc
+++ b/passes/opt/opt_merge.cc
@@ -282,11 +282,12 @@ struct OptMergeWorker
RTLIL::SigSpec other_sig = r.first->second->getPort(it.first);
log_debug(" Redirecting output %s: %s = %s\n", it.first.c_str(),
log_signal(it.second), log_signal(other_sig));
+ Const init = initvals(other_sig);
+ initvals.remove_init(it.second);
+ initvals.remove_init(other_sig);
module->connect(RTLIL::SigSig(it.second, other_sig));
assign_map.add(it.second, other_sig);
-
- if (it.first == ID::Q && RTLIL::builtin_ff_cell_types().count(cell->type))
- initvals.remove_init(it.second);
+ initvals.set_init(other_sig, init);
}
}
log_debug(" Removing %s cell `%s' from module `%s'.\n", cell->type.c_str(), cell->name.c_str(), module->name.c_str());