Skip to content

memories: a slang-uniquified memory module is named for its definition - #4658

Merged
maliberty merged 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:memories-slang-definition-names
Oct 11, 2026
Merged

maliberty merged 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:memories-slang-definition-names

Conversation

@oharboe

@oharboe oharboe commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

slang's --keep-hierarchy elaborates one module per instance and names it <definition>$<instance path>. The detector named a memory after its module, so a memory module instanced twice produced two entries, two liberty views of one array, and two uniquified names in blackboxes.txt. read_slang's --blackboxed-module matches the definition's name only and ignores a name it does not know, so nothing was blackboxed: every array was elaborated, flattened into its parent, and synthesis stopped at SYNTH_MEMORY_MAX_BITS.

The detector now cuts a module name at the first $ when an identifier precedes it (yosys's own $paramod\... names have nothing before it and stay whole) and collapses the copies into one entry. Copies that disagree in shape or pins are an error: one liberty view per definition cannot serve a definition parameterised on its memory.

Found with asap7/tage_update (#4595), which instances each of its SRAM definitions 8 to 16 times; with this fix blackboxes.txt holds mbtb_entry_sram, tage_entry_sram and tage_useful_sram, and synthesis completes.

🤖 Generated with Claude Code

slang's --keep-hierarchy elaborates one module per instance and names
it `<definition>$<instance path>`. The detector named a memory after
its module, so a memory module instanced twice produced two entries,
two liberty views of one array, and two uniquified names in
blackboxes.txt. read_slang's --blackboxed-module matches the
definition's name only and ignores a name it does not know, so nothing
was blackboxed: every array was elaborated, flattened into its parent,
and synthesis stopped at SYNTH_MEMORY_MAX_BITS. asap7/tage_update
(The-OpenROAD-Project#4595) instances each of its SRAM definitions 8 to 16 times and hits
this.

The detector now cuts a module name at the first `$` when an
identifier precedes it (yosys's own `$paramod\...` names have nothing
before it and stay whole) and collapses the copies into one entry.
Copies that disagree in shape or pins are an error: one liberty view
per definition cannot serve a definition parameterised on its memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request adds support for handling slang's --keep-hierarchy module naming convention by extracting the base definition name and deduplicating elaborated memory instances. It ensures that multiple copies of a definition agree on shape and pins, raising an error otherwise. The feedback suggests simplifying the definition_name check to correctly handle escaped Verilog identifiers starting with digits, adding a test case for this scenario, and refactoring the pin comparison in dedupe to compare Pin objects directly for improved robustness.

Comment thread flow/scripts/memories/detect.py Outdated
Comment thread flow/scripts/memories/detect.py Outdated
Comment thread flow/scripts/memories/detect_test.py Outdated
Review: cutting at the first `$` breaks a definition whose own name
has a `$` (legal in a Verilog identifier): read_slang names an instance
of `my$ram` under top `top2` `my$ram$top2.u2`, and the first-`$` cut
made it `my`, a module that does not exist. The instance path starts
at the top module, so the name is now cut where `$<top>.` begins;
gen_memories takes the top as --top, which the Makefile passes as
DESIGN_NAME. An escaped definition starting with a digit (`\1d_ram`,
which read_slang blackboxes as `1d_ram`) is cut the same way.

Copies of one definition are compared on their whole pins, port and
function included, not on name, direction and width only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@openroad-ci

openroad-ci commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 336c8ad · Jenkins build #1 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

@maliberty
maliberty merged commit 4137d73 into The-OpenROAD-Project:master Oct 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants