3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-08-10 08:01:14 +00:00
yosys/kernel
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
..
unstable patch: fix signorm commit broken by twine rename 2026-07-20 15:01:30 +02:00
binding.cc
binding.h
bitpattern.h Fix covers_nothing. 2026-07-06 13:26:00 +02:00
calc.cc End of file fix 2026-06-23 07:23:41 +02:00
cellaigs.cc WIP 2026-07-20 12:27:17 +02:00
cellaigs.h WIP 2026-07-20 12:27:17 +02:00
celledges.cc WIP 2026-07-20 12:27:17 +02:00
celledges.h WIP 2026-07-20 12:27:17 +02:00
cellhelp.py Remove trailing whitespaces 2026-06-23 07:24:59 +02:00
celltypes.h WIP 2026-07-20 12:27:17 +02:00
CMakeLists.txt twine 2026-07-20 12:26:39 +02:00
compressor_tree.cc twines phase-3 build fix: post-fork main files broken by twine migration 2026-07-20 15:01:30 +02:00
compressor_tree.h End of file fix 2026-06-23 07:23:41 +02:00
compute_graph.h
consteval.h WIP 2026-07-20 12:27:17 +02:00
constids.inc twines phase-3 build fix: post-fork main files broken by twine migration 2026-07-20 15:01:30 +02:00
cost.cc prevent IdString construction when looking up module from instance type 2026-07-20 12:27:17 +02:00
cost.h WIP 2026-07-20 12:27:17 +02:00
driver.cc WIP migration to twine 2026-07-20 12:27:18 +02:00
drivertools.cc WIP 2026-07-20 12:27:17 +02:00
drivertools.h WIP 2026-07-20 12:27:17 +02:00
ff.cc ff: fix src_twine 2026-07-20 15:01:30 +02:00
ff.h opt_dff: keep the signorm index alive across the pass 2026-07-21 16:53:04 +02:00
ffinit.h ffinit: an x init bit is the absence of a value, not a conflict 2026-07-21 16:52:31 +02:00
ffmerge.cc WIP 2026-07-20 12:27:17 +02:00
ffmerge.h
fmt.cc WIP 2026-07-20 12:27:17 +02:00
fmt.h
fstdata.cc Migrate build system to CMake 2026-06-03 08:58:10 +00:00
fstdata.h Add comments to make sure it is clear scale is an exponent of 10 2026-04-23 17:22:14 +01:00
functional.cc functinoal: twines 2026-07-20 15:01:30 +02:00
functional.h functinoal: twines 2026-07-20 15:01:30 +02:00
gzip.cc
gzip.h
hashlib.h hashlib: error on unused containers 2026-05-12 12:51:41 +02:00
io.cc Fix Windows portability issues that break MSVC build. 2026-06-03 08:58:11 +00:00
io.h Remove trailing whitespaces 2026-06-23 07:24:59 +02:00
json.cc End of file fix 2026-06-23 07:23:41 +02:00
json.h
log.cc rtlil: options for dumping twines 2026-07-20 15:01:30 +02:00
log.h WIP 2026-07-20 12:27:17 +02:00
log_compat.cc Add one more compatibility logger used in patches for some time 2026-06-12 14:44:26 +02:00
log_help.cc Fixup help contents source_file 2026-07-09 16:05:15 +12:00
log_help.h Fixup help contents source_file 2026-07-09 16:05:15 +12:00
macc.h WIP 2026-07-20 12:27:17 +02:00
mem.cc twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
mem.h
modtools.h WIP 2026-07-20 12:27:17 +02:00
newcelltypes.h newcelltypes: twines 2026-07-20 12:27:18 +02:00
pattern.h OptDff more accurate ctrl/pattern desc. 2026-01-26 22:19:36 +01:00
pmux.h WIP 2026-07-20 12:27:17 +02:00
qcsat.cc WIP 2026-07-20 12:27:17 +02:00
qcsat.h
register.cc WIP migration to twine 2026-07-20 12:27:18 +02:00
register.h Drop YOSYS_ENABLE_HELP_SOURCE since C++20 is required. 2026-06-03 08:58:11 +00:00
rtlil.cc WIP opt_clean: garbage collect against the signorm index 2026-07-21 15:10:36 +02:00
rtlil.h WIP opt_clean: garbage collect against the signorm index 2026-07-21 15:10:36 +02:00
rtlil_bufnorm.cc WIP opt_clean: garbage collect against the signorm index 2026-07-21 15:10:36 +02:00
satgen.cc WIP 2026-07-20 12:27:17 +02:00
satgen.h WIP 2026-07-20 12:27:17 +02:00
scopeinfo.cc WIP 2026-07-20 12:27:17 +02:00
scopeinfo.h Refactored uses of log_id() 2026-05-08 20:59:24 -07:00
sexpr.cc
sexpr.h
sigtools.h sigmap: take the signorm index's map directly instead of via connections() 2026-07-21 12:53:38 +02:00
tclapi.cc twine: avoid TwinePool::lookup 2026-07-20 12:27:18 +02:00
threading.cc threading: whitespace 2026-05-18 16:26:14 +02:00
threading.h Migrate build system to CMake 2026-06-03 08:58:10 +00:00
timinginfo.h WIP 2026-07-20 12:27:17 +02:00
topo_scc.h Remove trailing whitespaces 2026-06-23 07:24:59 +02:00
twine.cc twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
twine.h twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
utils.h twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
version.cc.in Include build datetime in scl cache hash. 2026-07-10 12:44:34 +02:00
yosys.cc WIP 2026-07-20 12:27:17 +02:00
yosys.h Include build datetime in scl cache hash. 2026-07-10 12:44:34 +02:00
yosys_common.h twine: fix replayability, reduce TwineSearch usage 2026-07-20 13:57:10 +02:00
yosys_config.h.in Drop YOSYS_ENABLE_HELP_SOURCE since C++20 is required. 2026-06-03 08:58:11 +00:00
yw.cc
yw.h prevent IdString construction when looking up module from instance type 2026-07-20 12:27:17 +02:00