3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-08-08 15:12:21 +00:00
yosys/passes
Emil J. Tywoniak 8dc93a6b9f opt_dff: keep the signorm index alive across the pass
This is the other half of the signorm-native opt_clean: the two are
strictly complementary, since whichever of them still calls
sigNormalize(false) destroys the index and opt_expr rebuilds it on the
next iteration of the opt loop. Together they take `opt` on a 2000-stage
pipeline from 4.54s to 3.14s (Debug) against main-dbg's 4.28s, with peak
RSS 540MB against main's 683MB.

The obstacle was never bit2mux/bitusers, as the TODO removed here
guessed -- that guard passes in both modes, and it is not even consulted
in one pass: try_merge_srst absorbs the reset mux, emits an $sdff, pushes
it back onto dff_cells, and the enable is found on the next iteration.
What breaks is the SigMap the worker snapshots in its constructor.
FfData::emit() builds the replacement cell before the caller removes the
old one, so at setPort(Q, \q) the wire still has a driver and the kernel
does what I1 requires: interpose a fresh wire and alias \q to it. (Same
unconditionally for a sliced Q -- a port may never hold a partial wire.)
The snapshot does not relate the two, so try_merge_ce compares
a = sigmap(\q) against ff.sig_q and sees no feedback, yielding $sdff
where $sdffe was expected (tests/sim/sim_sdffe.ys).

So stop snapshotting. In signorm mode the module already maintains this
map and keeps it live across our edits; borrow it and settle the index
once per FF rewrite instead. FfDataSigMapped and BitSim take a
const SigMapView & so the borrow is read-only -- only the kernel may
write a module's own map.

Where resync() goes is the subtlety: only between whole FF rewrites.
Mid-rewrite, after try_merge_srst has emitted cells for some bit groups
but before the original cell is removed, a \q slice transiently has two
drivers, and flushing there would emit a multi-driver $connect instead of
merging the alias.

bitusers/bit2mux stay constructor snapshots. Keyed by canonical bits, so
a bit whose representative later moves becomes unreachable and its
lookups miss -- every guard reading them then fails closed, never open.

Test suite: 12 failures before, 12 after, four traded. Fixed:
arch/fabulous/fsm, arch/quicklogic/qlf_k6n10f/t_mem{5,6},
memories/wide_all. New: arch/{analogdevices/dsp_abc9,intel_alm/mul,
nexus/mul,nexus/fuse_mac}, all DSP/whitebox flows failing the same way --
techmap copies signorm helper wires out of a template that was in signorm
mode, and opt_expr -undriven then ties them to x. Diagnosed but not
fixed here; see g/signorm-opt_clean.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MQU5XCqDYY8MbivGkNRrDo
2026-07-21 16:53:04 +02:00
..
cmds timeest: leave signorm mode 2026-07-21 16:52:45 +02:00
equiv twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
fsm passes: leave signorm mode where the index cannot be maintained 2026-07-21 14:05:07 +02:00
hierarchy passes: leave signorm mode where the index cannot be maintained 2026-07-21 14:05:07 +02:00
memory memory_libmap: provide blackboxes for the RAM cells it instantiates 2026-07-21 14:05:07 +02:00
opt opt_dff: keep the signorm index alive across the pass 2026-07-21 16:53:04 +02:00
pmgen WIP migration to twine 2026-07-20 13:57:10 +02:00
proc proc_mux: WIP 2026-07-20 15:01:30 +02:00
sat twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
techmap techmap: decode derived_name in the map pool, not the target design 2026-07-20 15:01:30 +02:00
tests twines phase-3 build fix: post-fork main files broken by twine migration 2026-07-20 15:01:30 +02:00
CMakeLists.txt Migrate build system to CMake 2026-06-03 08:58:10 +00:00