Skip to content

regfile_ram: refuse a named bit_folds the fold rule would fold further - #4820

Open
oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:regfile-ram-refuse-low-bit-folds
Open

oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:regfile-ram-refuse-low-bit-folds

Conversation

@oharboe

@oharboe oharboe commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Before: a register-file spec that names bit_folds bypasses regfile_ram.py's fold rule. A spec that writes out bit_folds 1 as a default therefore builds a long, thin array: every word's selects and write enables run the full width. repair_design buffers those long wires inside the array, where the only sites wide enough are the rows above and below it, and detailed placement cannot legalise the buffers.

Now: the fold rule is factored into _folds(). When a spec names bit_folds, the rule is applied to the array that fold builds; if it would fold further, generate() stops with the aspect ratio, the word span and the fold the rule would choose:

regfile_ram: rf.regfile: bit_folds 1 leaves the array 34.1 times as wide as tall and a word 600 um long; the fold rule folds it 8 times: leave bit_folds out, or name that

A named fold at or above the rule's choice builds as before, and a spec without bit_folds is unchanged. No spec under flow/designs names bit_folds.

Tests: flow/scripts/memories/gen_memories_test.py gains tests that stub generate_ram (the generate script writes the outline, the views script stops the run): the rule's choices, the refusal and its message, a fold at the rule's choice accepted, and an unnamed fold built twice. The refusal tests fail without the change. All flow/scripts/memories/*_test.py pass.

🤖 Generated with Claude Code

A spec that names bit_folds bypasses the fold rule, so a pinned low fold
(bit_folds 1 written out as a default) builds the array as named: a long,
thin outline whose word selects and write enables run the full width.
repair_design then buffers those long wires inside the array, where the
only sites wide enough are the rows above and below it, and detailed
placement cannot legalise the buffers.

Factor the fold rule into _folds() and, when a spec names bit_folds,
apply the rule to the array that fold builds. If the rule would fold it
further, stop with the aspect ratio, the word span and the fold the rule
would choose, instead of building it. A named fold at or above the
rule's choice builds as before.

Tests in gen_memories_test.py stub generate_ram to check the rule, the
refusal and that a fold at the rule's choice is accepted.

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 refactors the word folding logic in regfile_ram.py by extracting it into a dedicated _folds helper function. It also introduces validation to refuse user-specified bit_folds configurations that are fewer than what the rule would choose, raising a SystemExit error with a descriptive message. Additionally, comprehensive unit tests are added in gen_memories_test.py to verify these folding rules and validation behaviors. I have no feedback to provide on these changes.

@oharboe
oharboe requested a review from jhkim-pii November 11, 2026 06:22
@openroad-ci

Copy link
Copy Markdown
Member

🔍 QoR check

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

Commit d41a61e · Jenkins build #1 · Baseline: build · View build on dashboard

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

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.

2 participants