Repository navigation
synth: error on typos in SYNTH_KEEP_MODULES #4239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,15 @@ if { $::env(SYNTH_GUT) } { | |
| } | ||
|
|
||
| if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } { | ||
| # In partition mode (SYNTH_BLACKBOXES set) only this partition's top | ||
| # module plus its own subhierarchy is present; the other kept modules | ||
| # are blackboxed and won't be found. The same SYNTH_KEEP_MODULES list | ||
| # is reused across partitions, so a missing name there is expected. | ||
| # 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] }] | ||
| set missing [list] | ||
| foreach module $::env(SYNTH_KEEP_MODULES) { | ||
| # Two patterns so both frontends work: | ||
| # - `$module` matches the bare name produced by verilog. | ||
|
|
@@ -87,10 +96,26 @@ if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } { | |
| # other pattern still applies -- no regression for non-slang. | ||
| # `-module <name>` would error if the module doesn't exist, which | ||
| # is why we use bare patterns instead. | ||
| select "$module" "$module\\\$*" | ||
| if { $strict } { | ||
| # `-assert-any` errors out if neither pattern matched. Catch so | ||
| # all missing names are reported in one consolidated error rather | ||
| # than failing on the first. | ||
| if { [catch { select -assert-any "$module" "$module\\\$*" }] } { | ||
| lappend missing $module | ||
| select -clear | ||
| continue | ||
| } | ||
|
Comment on lines
+103
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using References
|
||
| } else { | ||
| select "$module" "$module\\\$*" | ||
| } | ||
| setattr -mod -set keep_hierarchy 1 | ||
| select -clear | ||
| } | ||
| if { [llength $missing] > 0 } { | ||
| error "SYNTH_KEEP_MODULES contains [llength $missing] module name(s)\ | ||
| not present in the elaborated design (typos, post-refactor renames,\ | ||
| or wrong-design list): [join $missing {, }]" | ||
| } | ||
| } | ||
|
|
||
| if { [env_var_exists_and_non_empty SYNTH_HIER_SEPARATOR] } { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for determining
strictmode relies onSYNTH_BLACKBOXESbeing 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 ifSYNTH_BLACKBOXESis empty but partition mode is intended.