Skip to content

synth: error on typos in SYNTH_KEEP_MODULES - #4239

Closed
oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:synth-keep-modules-typo-check
Closed

oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:synth-keep-modules-typo-check

Conversation

@oharboe

@oharboe oharboe commented May 19, 2026

Copy link
Copy Markdown
Collaborator

...

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>
@oharboe
oharboe requested a review from maliberty May 19, 2026 12:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flow/scripts/synth.tcl
# 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] }]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment thread flow/scripts/synth.tcl
Comment on lines +103 to +107
if { [catch { select -assert-any "$module" "$module\\\$*" }] } {
lappend missing $module
select -clear
continue
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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
  1. In Yosys, providing multiple patterns as separate arguments to the select command results in the union of the selections.

@oharboe oharboe closed this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant