Skip to content

Commit 0bc1a7d

Browse files
oharboeclaude
andcommitted
synth: stop on a SYNTH_KEEP_MODULES name that is not in the design
A SYNTH_KEEP_MODULES name that matched no module was a yosys warning and nothing else: synthesis went on with that module flattened. A misspelled name, or a module the RTL has renamed, changed the result without a word. That is how asap7/coralnpu's keep list went stale in #4653: the current RTL renamed DispatchV1, LsuV1 and DBus2AxiV1 to DispatchV2, LsuV3 and DBus2AxiV2, and a full flow ran with three of its ten units flattened before anything noticed. Each name now has to select a module, by either of the two patterns already used (the name itself, or slang's uniquified name$...); synthesis stops otherwise, naming it. On asap7/riscv32i a misspelled name stops synthesis and the real one passes; asap7/chi_async_bridge, whose kept modules have slang's uniquified names, passes unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 64939f3 commit 0bc1a7d

4 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎docs/user/FlowVariables.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ configuration file.
304304
| <a name="SYNTH_HIER_SEPARATOR"></a>SYNTH_HIER_SEPARATOR| Separator used for the synthesis flatten stage.| .|
305305
| <a name="SYNTH_INSBUF"></a>SYNTH_INSBUF| Insert input buffers on top-level input ports during synthesis. Useful to disable when doing parallel synthesis and concatenating netlists later as we're generating netlists of submodules.| 1|
306306
| <a name="SYNTH_KEEP_MOCKED_MEMORIES"></a>SYNTH_KEEP_MOCKED_MEMORIES| When `SYNTH_MOCK_LARGE_MEMORIES=1`, setting this to 1, will keep mocked memories (not flattening them). This preserves some of the access logic complexity and avoids optimizations outside of the mocked memory.| 1|
307-
| <a name="SYNTH_KEEP_MODULES"></a>SYNTH_KEEP_MODULES| Mark modules to keep from getting removed in flattening.| |
307+
| <a name="SYNTH_KEEP_MODULES"></a>SYNTH_KEEP_MODULES| Mark modules to keep from getting removed in flattening. A name that matches no module of the design stops synthesis.| |
308308
| <a name="SYNTH_MEMORY_MAX_BITS"></a>SYNTH_MEMORY_MAX_BITS| Maximum number of bits for memory synthesis. Ideally, real RAM or realistic fakeram should be used for RAMs much larger than 1024 bits. To temporarily ignore the RAM concerns and investigate other aspects of the design, consider setting `SYNTH_MOCK_LARGE_MEMORIES=1`, or adjusting `SYNTH_MEMORY_MAX_BITS`.| 4096|
309309
| <a name="SYNTH_MINIMUM_KEEP_SIZE"></a>SYNTH_MINIMUM_KEEP_SIZE| For hierarchical synthesis, we keep modules of larger area than given by this variable and flatten smaller modules. The area unit used is the size of a basic nand2 gate from the platform's standard cell library. The default value is platform specific.| 0|
310310
| <a name="SYNTH_MOCK_LARGE_MEMORIES"></a>SYNTH_MOCK_LARGE_MEMORIES| Reduce Yosys inferred memories larger than SYNTH_MEMORY_MAX_BITS to 1 row. Yosys will generally infer memories from behavioral Verilog code, whether the memories are in standalone modules or instantiated within some larger module. fakeram and empty Verilog memories(blackboxes) of memories will not be inferred memories by Yosys and are therefore not affected by this variable. This is useful and convenient to separate the concern of instantiating and placing memories from investigating other issues with a design, though it comes at the expense of the increased accuracy that using realistic fakemem would provide. Memories with a single 1 row will of course have unrealistically good timing and area characteristics, but timing will still correctly terminate in a register. Large port memories, typically register files, will still have the retain a lot of the port logic that can be useful to investigate issues. This can be especially useful during development of designs where the behavioral model comes first and suitable memories are matched up when the design RTL is stable. A typical use case would be Chisel which will generate a behavioral model for a memories with the required clocks, ports, etc. in addition to a computer readable file with the specification of the memories that is used to [automatically](https://chipyard.readthedocs.io/en/stable/Tools/Barstools.html/) match up suitable memory macros later in the flow. During an architectural screening study, a large range of memory configurations can be investigated quickly with this option, without getting bogged down in the concern of how to realize the memories in silicon for emphemral RTL configurations that exist only long enough to run through the ORFS flow to create a table of some characteristics of a design configuration.| 0|

‎flow/scripts/synth.tcl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } {
8888
# `-module <name>` would error if the module doesn't exist, which
8989
# is why we use bare patterns instead.
9090
select "$module" "$module\\\$*"
91+
if { [string trim [tee -q -s result.string select -list]] eq "" } {
92+
error "SYNTH_KEEP_MODULES: no module $module in the design"
93+
}
9194
setattr -mod -set keep_hierarchy 1
9295
select -clear
9396
}

‎flow/scripts/variables.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flow/scripts/variables.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ DFF_LIB_FILE:
11031103
SYNTH_KEEP_MODULES:
11041104
description: |
11051105
Mark modules to keep from getting removed in flattening.
1106+
A name that matches no module of the design stops synthesis.
11061107
stages:
11071108
- synth
11081109
SYNTH_ARGS:

0 commit comments

Comments
 (0)