From 4ba7421085f76e6473077f99aa9a4ecb5ddf3eb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Sun, 26 Jul 2026 21:14:13 +0200 Subject: [PATCH 1/2] synth: extend SYNTH_KEEP_MODULES selection pattern for slang MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øyvind Harboe --- flow/scripts/synth.tcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl index 58dc0af1d2..644b1b0b1b 100644 --- a/flow/scripts/synth.tcl +++ b/flow/scripts/synth.tcl @@ -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(). @@ -87,7 +87,7 @@ if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } { # other pattern still applies -- no regression for non-slang. # `-module ` would error if the module doesn't exist, which # is why we use bare patterns instead. - select "$module" "$module\\\$*" + select "$module" "$module\\\$*" "$module*" setattr -mod -set keep_hierarchy 1 select -clear } From c1664e176823b2c19ec0516c957312ef28d01e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Mon, 3 Aug 2026 22:38:24 +0200 Subject: [PATCH 2/2] synth: drop overly broad '$module*' from SYNTH_KEEP_MODULES selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wildcard '*' matches any module starting with the base module's name as a prefix (e.g. 'cpu_alu' when keeping 'cpu'). The pattern '$module\$*' already reliably matches the canonical parameterized instance names generated by the slang frontend (e.g., \foo$1), so the broader wildcard is unnecessary and prevents optimization of unrelated modules sharing the prefix. Signed-off-by: Øyvind Harboe --- flow/scripts/synth.tcl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl index 644b1b0b1b..58dc0af1d2 100644 --- a/flow/scripts/synth.tcl +++ b/flow/scripts/synth.tcl @@ -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\$*` and `$module*` match `$`-suffixed canonical names - # the slang frontend generates for parameterized instances + # - `$module\$*` matches the `$`-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(). @@ -87,7 +87,7 @@ if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } { # other pattern still applies -- no regression for non-slang. # `-module ` would error if the module doesn't exist, which # is why we use bare patterns instead. - select "$module" "$module\\\$*" "$module*" + select "$module" "$module\\\$*" setattr -mod -set keep_hierarchy 1 select -clear }