Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flow/scripts/synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } {
foreach module $::env(SYNTH_KEEP_MODULES) {
# Two patterns so both frontends work:
# - `$module` matches the bare name produced by verilog.
# - `$module\$*` matches the `$`-suffixed canonical names the
# slang frontend generates for parameterized instances
# - `$module\$*` and `$module*` match `$`-suffixed canonical names
# the slang frontend generates for parameterized instances
# (e.g. `\foo$1`); yosys's match_ids retries the pattern with
# the id's leading `\` stripped, so no `\`-prefix is needed
# here -- see tools/yosys/passes/cmds/select.cc match_ids().
Expand All @@ -87,7 +87,7 @@ 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\\\$*"
select "$module" "$module\\\$*" "$module*"

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 the wildcard pattern "$module*" acts as a prefix match and will match any module whose name starts with the module name. For example, if SYNTH_KEEP_MODULES contains "cpu", this pattern will also match and keep unrelated modules like "cpu_alu" or "cpu_ctrl". This prevents those unrelated modules from being flattened and optimized, which can negatively impact area and timing. If slang-elaborated parameterized modules are named with a specific separator (like an underscore or dollar sign), it is highly recommended to use a more restrictive pattern (such as "${module}_*" or the existing dollar-suffixed pattern) to avoid over-matching.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@povik I'm skeptical of Gemini when it comes to this .tcl Yosys select code.

The symptom here is that the netlist fails in verilator .saif emulation because pins are lost with -hier.

setattr -mod -set keep_hierarchy 1
select -clear
}
Expand Down