From 9da4fe747e96e68a0c8ca8420659ff016cc8481b Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Tue, 28 Jan 2025 11:23:36 +0100 Subject: [PATCH] fix bus ioff inference --- techlibs/quicklogic/ql_ioff.cc | 18 +++--- tests/arch/quicklogic/qlf_k6n10f/ioff.ys | 81 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/techlibs/quicklogic/ql_ioff.cc b/techlibs/quicklogic/ql_ioff.cc index c857fc35d..e08850fb7 100644 --- a/techlibs/quicklogic/ql_ioff.cc +++ b/techlibs/quicklogic/ql_ioff.cc @@ -39,13 +39,14 @@ struct QlIoffPass : public Pass { if (!(e_const && r_const && s_const)) continue; - auto d_sig = modwalker.sigmap(cell->getPort(ID::D)); - if (d_sig.is_wire() && d_sig.as_wire()->port_input) { + SigSpec d = cell->getPort(ID::D); + if (GetSize(d) != 1) continue; + SigBit d_sig = modwalker.sigmap(d[0]); + if (d_sig.is_wire() && d_sig.wire->port_input) { log_debug("Cell %s is potentially eligible for promotion to input IOFF.\n", cell->name.c_str()); // check that d_sig has no other consumers - if (GetSize(d_sig) != 1) continue; pool portbits; - modwalker.get_consumers(portbits, d_sig[0]); + modwalker.get_consumers(portbits, d_sig); if (GetSize(portbits) > 1) { log_debug("not promoting: d_sig has other consumers\n"); continue; @@ -53,13 +54,14 @@ struct QlIoffPass : public Pass { cells_to_replace.insert(cell); continue; // no need to check Q if we already put it on the list } - auto q_sig = modwalker.sigmap(cell->getPort(ID::Q)); - if (q_sig.is_wire() && q_sig.as_wire()->port_output) { + SigSpec q = cell->getPort(ID::Q); + if (GetSize(q) != 1) continue; + SigBit q_sig = modwalker.sigmap(q[0]); + if (q_sig.is_wire() && q_sig.wire->port_output) { log_debug("Cell %s is potentially eligible for promotion to output IOFF.\n", cell->name.c_str()); // check that q_sig has no other consumers - if (GetSize(q_sig) != 1) continue; pool portbits; - modwalker.get_consumers(portbits, q_sig[0]); + modwalker.get_consumers(portbits, q_sig); if (GetSize(portbits) > 0) { log_debug("not promoting: q_sig has other consumers\n"); continue; diff --git a/tests/arch/quicklogic/qlf_k6n10f/ioff.ys b/tests/arch/quicklogic/qlf_k6n10f/ioff.ys index bd69a28d4..3144eda13 100644 --- a/tests/arch/quicklogic/qlf_k6n10f/ioff.ys +++ b/tests/arch/quicklogic/qlf_k6n10f/ioff.ys @@ -9,6 +9,18 @@ EOF synth_quicklogic -family qlf_k6n10f -top top select -assert-count 1 t:dff +design -reset +# test: acceptable for output IOFF promotion +read_verilog <