From 4f4672d17b5cfd2d63c4319403e243f3f2667bbd Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Thu, 19 Mar 2026 00:11:20 +0100 Subject: [PATCH] muxpack: fix wide Y port handling --- passes/opt/muxpack.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/passes/opt/muxpack.cc b/passes/opt/muxpack.cc index 6efeefb3c..ac47f6bf7 100644 --- a/passes/opt/muxpack.cc +++ b/passes/opt/muxpack.cc @@ -38,6 +38,9 @@ struct ExclusiveDatabase pool reduce_or; for (auto cell : module->cells()) { if (cell->type == ID($eq)) { + SigSpec y_sig = sigmap(cell->getPort(ID::Y)); + if (GetSize(y_sig) == 0) + continue; nonconst_sig = sigmap(cell->getPort(ID::A)); const_sig = sigmap(cell->getPort(ID::B)); if (!const_sig.is_fully_const()) { @@ -45,12 +48,15 @@ struct ExclusiveDatabase continue; std::swap(nonconst_sig, const_sig); } - y_port = sigmap(cell->getPort(ID::Y)); + y_port = y_sig[0]; } else if (cell->type == ID($logic_not)) { + SigSpec y_sig = sigmap(cell->getPort(ID::Y)); + if (GetSize(y_sig) == 0) + continue; nonconst_sig = sigmap(cell->getPort(ID::A)); const_sig = Const(State::S0, GetSize(nonconst_sig)); - y_port = sigmap(cell->getPort(ID::Y)); + y_port = y_sig[0]; } else if (cell->type == ID($reduce_or)) { reduce_or.insert(cell); @@ -84,7 +90,10 @@ struct ExclusiveDatabase } if (nonconst_sig.empty()) continue; - y_port = sigmap(cell->getPort(ID::Y)); + SigSpec y_sig = sigmap(cell->getPort(ID::Y)); + if (GetSize(y_sig) == 0) + continue; + y_port = y_sig[0]; sig_cmp_prev[y_port] = std::make_pair(nonconst_sig,std::move(values)); } }