Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the synthesis script flow/scripts/synth.tcl to include a new wildcard pattern "$module*" to match slang-elaborated parameterized instances. Feedback on this change highlights that the wildcard pattern is too broad and acts as a prefix match, which could inadvertently match and keep unrelated modules (e.g., matching "cpu_alu" when "cpu" is specified) and prevent optimization. It is recommended to use a more restrictive pattern to avoid over-matching.
| # `-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*" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
c068f48 to
4ba7421
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ba7421085
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # `-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*" |
There was a problem hiding this comment.
Avoid prefix-matching unrelated modules
When a requested keep name is also a prefix of another module, the new "$module*" pattern selects both and applies keep_hierarchy to the unrelated module. For example, the existing asap7/swerv_wrapper configuration lists exu, exu_alu_ctl, and exu_div_ctl, while its RTL also defines an unlisted exu_mul_ctl; processing exu now preserves exu_mul_ctl as well. This can unexpectedly prevent flattening and change hierarchy and synthesis QoR, so the fallback should distinguish Slang elaboration suffixes rather than accepting every suffix.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same concern as Gemini. I asked Claude about it:
Since $* already covers every suffix slang can produce, $module* adds no
slang coverage — it only adds prefix collisions. Whatever is causing the lost
pins under -hier in the verilator SAIF run is a different root cause, and this
pattern change is masking it rather than fixing it.
Sounds like it needs more investigation upstream.
There was a problem hiding this comment.
Yes... I was hoping for insights here from @povik
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 <oyvind.harboe@zylin.com>
|
This PR is now a no-op |
|
I have dropped the overly broad |
Extend module selection pattern in
flow/scripts/synth.tclto include$module*alongside$module\$*so kept module preservation (SYNTH_KEEP_MODULES) functions reliably for slang-elaborated modules.