diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-06-06 14:21:34 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-06-06 14:21:34 -0700 |
commit | 5c277c6325b78bfe18cf294b63ea69ff272e69c5 (patch) | |
tree | 5407195159a09be5b3fd7f8af0e7d28dee7c6f75 /passes/opt | |
parent | 0a66720f6f67b087fe6342d01d45944506240942 (diff) | |
download | yosys-5c277c6325b78bfe18cf294b63ea69ff272e69c5.tar.gz yosys-5c277c6325b78bfe18cf294b63ea69ff272e69c5.tar.bz2 yosys-5c277c6325b78bfe18cf294b63ea69ff272e69c5.zip |
Fix and test for balanced case
Diffstat (limited to 'passes/opt')
-rw-r--r-- | passes/opt/muxpack.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/passes/opt/muxpack.cc b/passes/opt/muxpack.cc index f9e5c8f09..8c4db4e4d 100644 --- a/passes/opt/muxpack.cc +++ b/passes/opt/muxpack.cc @@ -94,23 +94,27 @@ struct MuxpackWorker { log_debug("Considering %s (%s)\n", log_id(cell), log_id(cell->type)); - SigSpec next_sig = cell->getPort("\\A"); - if (sig_chain_prev.count(next_sig) == 0) { - if (cell->type == "$mux") { - next_sig = cell->getPort("\\B"); - if (sig_chain_prev.count(next_sig) == 0) - goto start_cell; - } - else + SigSpec a_sig = cell->getPort("\\A"); + if (cell->type == "$mux") { + SigSpec b_sig = cell->getPort("\\B"); + if (sig_chain_prev.count(a_sig) + sig_chain_prev.count(b_sig) != 1) + goto start_cell; + + if (!sig_chain_prev.count(a_sig)) + a_sig = b_sig; + } + else if (cell->type == "$pmux") { + if (!sig_chain_prev.count(a_sig)) goto start_cell; } + else log_abort(); { - for (auto bit : next_sig.bits()) + for (auto bit : a_sig.bits()) if (sigbit_with_non_chain_users.count(bit)) goto start_cell; - Cell *c1 = sig_chain_prev.at(next_sig); + Cell *c1 = sig_chain_prev.at(a_sig); Cell *c2 = cell; if (c1->getParam("\\WIDTH") != c2->getParam("\\WIDTH")) |