Repository navigation
Conversation
Today a name in SYNTH_KEEP_MODULES that doesn't exist in the elaborated design (typo, post-refactor rename, wrong-design list) produces only a yosys warning from `select` -- the whole keep silently turns into a no-op and the design flattens. Catch this by passing `-assert-any` to the two-pattern `select` so an empty selection becomes a hard error. Skip the strict check in partition mode (SYNTH_BLACKBOXES set): the same SYNTH_KEEP_MODULES list is reused across partitions and other partitions' kept modules are legitimately absent from this partition's RTLIL. Collect all missing names and report them in one error rather than failing on the first -- much friendlier when several names have drifted. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
There was a problem hiding this comment.
Code Review
This pull request implements a strict validation check for modules listed in SYNTH_KEEP_MODULES within flow/scripts/synth.tcl. When not in partition mode (determined by the absence of SYNTH_BLACKBOXES), the script now verifies that all specified modules exist in the design, collecting any missing names and throwing a consolidated error if necessary. Review feedback suggests refining the logic for detecting partition mode to be more robust and highlights the importance of verifying Yosys selection stack consistency when using catch with select -assert-any.
| # Outside partition mode, a missing name is almost certainly a typo or | ||
| # a stale post-refactor reference, and silently skipping it turns the | ||
| # whole keep into a no-op -- collect all missing names and fail loudly. | ||
| set strict [expr { ![env_var_exists_and_non_empty SYNTH_BLACKBOXES] }] |
There was a problem hiding this comment.
The logic for determining strict mode relies on SYNTH_BLACKBOXES being non-empty. While this is generally true in partition mode, it might be safer to explicitly check if the design is being synthesized in a parallel/partitioned context if such a variable exists, to avoid false positives if SYNTH_BLACKBOXES is empty but partition mode is intended.
| if { [catch { select -assert-any "$module" "$module\\\$*" }] } { | ||
| lappend missing $module | ||
| select -clear | ||
| continue | ||
| } |
There was a problem hiding this comment.
Using catch around select -assert-any is an effective way to collect all missing modules before failing. However, ensure that select -assert-any does not leave the Yosys selection stack in an inconsistent state upon failure. Note that providing multiple patterns to select results in a union, which affects how -assert-any behaves. While select -clear is called at line 105, it might be worth verifying if Yosys selection state is fully reset when an assertion fails inside a catch block.
References
- In Yosys, providing multiple patterns as separate arguments to the select command results in the union of the selections.
...