From ef31e84116e9c32fb1f2731d486d05f878fab2be Mon Sep 17 00:00:00 2001 From: nella Date: Wed, 6 May 2026 12:24:57 +0200 Subject: [PATCH] Resolve sig bugfix. --- passes/hierarchy/util/ports.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/passes/hierarchy/util/ports.cc b/passes/hierarchy/util/ports.cc index 47c99784c..658fa38af 100644 --- a/passes/hierarchy/util/ports.cc +++ b/passes/hierarchy/util/ports.cc @@ -29,7 +29,8 @@ namespace Hierarchy { INPUT, OUTPUT, INOUT, - DRIVEN + DRIVEN, + CONFLICT }; static void build_driven_signals_index(Module *module, SigMap &sigmap, SigPool &driven_signals) { @@ -62,6 +63,7 @@ namespace Hierarchy { for (auto &chunk : sig.chunks()) { if (chunk.is_wire()) { Wire *w = chunk.wire; + if (w->port_input && w->port_output) { has_input = true; has_output = true; @@ -71,19 +73,26 @@ namespace Hierarchy { has_output = true; } else { SigSpec chunk_sig = sigmap(SigSpec(chunk)); + if (driven_signals.check_any(chunk_sig)) { has_driven = true; } else { has_unknown = true; } } + } else { + has_driven = true; } } + if (has_input && has_driven) + return SigDirection::CONFLICT; if (has_input && has_output) return SigDirection::INOUT; - if (has_output || has_driven) + if (has_output) return SigDirection::OUTPUT; + if (has_driven) + return SigDirection::DRIVEN; if (has_input) return SigDirection::INPUT; if (has_unknown) @@ -198,6 +207,9 @@ namespace Hierarchy { SigDirection dir_a = get_signal_direction(sig_a, sigmap, driven_signals); SigDirection dir_b = get_signal_direction(sig_b, sigmap, driven_signals); + if (dir_a == SigDirection::CONFLICT || dir_b == SigDirection::CONFLICT) + continue; + SigSpec driver, driven; bool can_resolve = false;