synth: extend SYNTH_KEEP_MODULES selection pattern for slang elaboration - #4381
synth: extend SYNTH_KEEP_MODULES selection pattern for slang elaboration#4381oharboe wants to merge 1 commit into
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
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.