Repository navigation
Commit fffb07a
committed
synth: hash post-
yosys-slang was recently found to be non-idempotent in a few cases:
re-running synth on the same RTL produces different post-frontend
RTLIL. Master already has two file-based hashes that bracket the
whole synthesis pipeline:
synth__canonical_netlist__hash sha1 of `1_1_yosys_canonicalize.rtlil`
(captured AFTER `read_design_sources`
-> `hierarchy -check` -> `opt_clean
-purge`).
synth__netlist__hash sha1 of `1_2_yosys.v`
(captured AFTER ABC).
A slang-induced diff therefore collapses into `canonical_netlist__hash`
alongside any hierarchy / opt_clean drift, with no way to tell them
apart.
Add one more hash, `synth__post_read_sources__hash`, captured
immediately after `read_design_sources` returns -- i.e. the state
straight out of the HDL frontend, before any other pass runs. An
unstable hash here means the frontend itself is non-idempotent,
distinct from drift introduced later.
Mechanics:
* `flow/scripts/synth_preamble.tcl` gains a `write_state_hash`
proc that strips `src` attributes (file:line metadata, so the
hash is path-independent across the bazel sandbox and the
classic-make build), dumps the current RTLIL to a temp file
under `$OBJECTS_DIR`, sha1's it, deletes the temp, and emits
a `<metric>: <sha>` line to the yosys log.
* `flow/scripts/synth_canonicalize.tcl` calls
`write_state_hash synth__post_read_sources__hash` immediately
after `read_design_sources`.
* `flow/util/genMetrics.py` extracts the new hash from
`1_1_yosys_canonicalize.log` into `metadata.json`.
* `flow/util/genRuleFile.py` declares a `level=warning`,
`compare="=="` literal rule for the new metric so a downstream
`rules-base.json` can pin it without failing the build on a
mismatch (matching how `canonical_netlist__hash` and
`netlist__hash` are declared).
No design's `rules-base.json` gets a baseline value pinned in this
PR; declaring the rule type just makes the metric available to any
future per-design pin.
Pre-ABC / post-hierarchy / post-synth-main hashes are intentionally
left out -- they belong in follow-up PRs if the slang-only signal
isn't enough.
Signed-off-by: Øyvind Harboe <oyvind@ascenium.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>read_design_sources state to isolate slang non-determinism1 parent 2f6e9c9 commit fffb07a
4 files changed
Lines changed: 60 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
3 | 9 | | |
4 | 10 | | |
5 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
6 | 32 | | |
7 | 33 | | |
8 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
269 | 288 | | |
270 | 289 | | |
271 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| |||
0 commit comments