3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-02-07 01:32:15 +00:00

Make compare_signals produce a total order.

Currently when `s1` and `s2` are different bits of the same wire,
it is possible for both `compare_signals(s1, s2)` and `compare_signals(s2, s1)` to
return false. This means the calling code will call `assign_map.add()` for
both `s1` and `s2`, which doesn't make much sense --- one of `s1` or `s2`
should be consistently preferred.

So fix that by preferring the `SigBit` with the smaller bit offset.
This commit is contained in:
Robert O'Callahan 2026-01-24 01:48:15 +00:00
parent 125609105d
commit 2468b391bf

View file

@ -271,6 +271,9 @@ bool compare_signals(RTLIL::SigBit &s1, RTLIL::SigBit &s2, SigPool &regs, SigPoo
return conns.check_any(s2);
}
if (w1 == w2)
return s2.offset < s1.offset;
if (w1->port_output != w2->port_output)
return w2->port_output;