Skip to content

asap7/cva6: the RAMs as upstream has them, made macros - #4777

Merged
maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
oharboe:cva6-upstream-rams
Nov 6, 2026
Merged

maliberty merged 4 commits into
The-OpenROAD-Project:masterfrom
oharboe:cva6-upstream-rams

Conversation

@oharboe

@oharboe oharboe commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Before: asap7/cva6 rewrites cva6's RAM wrappers onto fakeram7 macros, and the D-cache data RAM loses its byte enables, so every refill and store hit overwrites the other way's word (#4769).
Now: the RAM RTL is upstream cva6's (3a389af), unmodified, and AUTO_MEMORIES makes each RAM a macro.

cva6 on asap7, 3_place: I-cache data RAMs orange, I-cache tag RAMs red, D-cache data RAMs green, D-cache directory RAMs yellow, standard cells blue
cva6 on asap7 after placement: die 151.5 µm × 151.5 µm, 8 RAM macros from AUTO_MEMORIES.

master this PR
D-cache data RAM byte enables dropped 8, each driven
RAM RTL changed from upstream 3 files none
global route at 910 ps closes closes, +1.8 % standard cells, die 151.61 µm (was 157.35)

Changes:

  • D-cache: hpdcache_sram.sv, hpdcache_sram_wbyteenable.sv and the behavioural hpdcache_sram_1rw.sv / hpdcache_sram_wbyteenable_1rw.sv as upstream has them; cva6.memories names their pins and byte enables for AUTO_MEMORIES. Fixes cva6: D-cache data RAM drops its byte enables, so every cache write corrupts the other way #4769.
  • I-cache: sram_cache.sv as upstream has it; surgery.py (SYNTH_VERILOG_SURGERY) puts a single-port SRAM with byte enables behind its techno cut in place of pulp's tc_sram, and AUTO_MEMORIES makes the data and tag RAMs macros. The Verilog is in surgery/: the techno cut as upstream has it (the build stops if upstream's differs), its replacement, and the two SRAMs.
  • config.mk: AUTO_MEMORIES on, LEC_CHECK = 0 (below).
  • README: what still differs from upstream (tie-offs).

Each macro's function is checked against the RTL's RAM by LEC, with controls that must fail. All 8 RAM instances, full size, run in cva6's Verilator testharness against Spike: the two-way test and CoreMark pass, RVFI traces are byte-identical to upstream's RAMs, and the controls fail.

Kepler LEC is off for cva6: kepler-formal cannot load the netlist after CTS (cva6_icache_data_sram cannot be found in SNL), the macro AUTO_MEMORIES makes of the I-cache data RAM. A new kepler-formal is in the works; cva6 sets LEC_CHECK = 0 until the Kepler team rewires it.

🤖 Generated with Claude Code

https://claude.ai/code/session_018PFLaCzFtFbnWE4nPTDwpC

@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 replaces hardcoded fakeram7 models in the CVA6 design with behavioral SRAM models and integrates them using AUTO_MEMORIES and a Python-based surgery script (surgery.py). The feedback suggests explicitly specifying UTF-8 encoding when opening files in the surgery script to prevent potential UnicodeDecodeError issues on systems with different default encodings.

Comment thread flow/designs/asap7/cva6/surgery.py Resolved
@openroad-ci

openroad-ci commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

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

Commit 0bb97fa · Jenkins build #7 · Baseline: build · View build on dashboard

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

❌ asap7/cva6 base — 2 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -276.256 -33.192 -732.289% -215.192 PeriodPadding 20.000%
finish__timing__setup__tns -5521.570 -265.156 -1982.385% -447.156 PeriodPadding 20.000%

vvbandeira pushed a commit that referenced this pull request Nov 4, 2026
flow/scripts/memories/gen_memories.py runs tools/FakeRAM2.0/run.py,
found relative to itself. The image copies flow/ and tools/AutoTuner but
not tools/FakeRAM2.0, so every AUTO_MEMORIES flow run from the image
stops at the memories step:

    /usr/bin/python3: can't open file
    '/OpenROAD-flow-scripts/tools/FakeRAM2.0/run.py': [Errno 2] No such
    file or directory

No design in CI sets AUTO_MEMORIES today, so CI on master does not show
it; a PR that adds one fails there (asap7/cva6 in #4777).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe marked this pull request as ready for review November 6, 2026 06:32
@oharboe
oharboe requested a review from maliberty November 6, 2026 06:38
oharboe and others added 3 commits November 6, 2026 12:15
asap7/cva6 had rewritten hpdcache_sram_wbyteenable to instantiate a
fakeram7_128x64 macro and dropped its byte enables: the RAM holds both
ways of a set in one 64-bit word, so every refill and store hit wrote
the whole word and overwrote the other way's data.

hpdcache_sram.sv and hpdcache_sram_wbyteenable.sv are upstream cva6's
again (3a389af, cv-hpdcache 04de808), unmodified, with upstream's
behavioural hpdcache_sram_1rw and hpdcache_sram_wbyteenable_1rw.
AUTO_MEMORIES makes each a macro, cva6.memories naming its pins and
byte enables: the data RAM (128 x 64, 8 byte enables) and the
directory (64 x 28).

Fixes The-OpenROAD-Project#4769

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
asap7/cva6 had rewritten sram_cache to instantiate fakeram7_64x256 and
fakeram7_64x25 in place of its techno cut, dropping the I-cache RAMs'
byte enables and replacing tc_sram's read behaviour with a fakeram's.

sram_cache.sv is upstream cva6's again, unmodified. Upstream fills its
techno cut, tc_sram_wrapper_cache_techno, with pulp's generic tc_sram;
SYNTH_VERILOG_SURGERY (surgery.py) puts a single-port SRAM with byte
enables there in its place, for AUTO_MEMORIES to make a macro of: the
I-cache data (64 x 256, 32 byte enables) and tag (64 x 25, 4 byte
enables, the last of them 1 bit, which needs mask_lane_width). The
fakeram views leave the config.

The Verilog is in surgery/, next to the script: the module as upstream
has it (the one in VERILOG_FILES must match it token for token, or the
build stops), its replacement, and the two SRAMs. The script reads and
writes UTF-8 whatever the locale.

tc_sram's read data follows the last read address through idle cycles
and writes; an SRAM holds while idle. cva6_icache uses read data only
in a cycle after a read, or after idle cycles with no write since that
read, so the two return the same data whenever it is used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018PFLaCzFtFbnWE4nPTDwpC
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
The README said "with some changes for the RAMs". The RAMs are now
upstream's; what still differs are tie-offs for outputs or struct
fields cv32a65x leaves undriven, listed by file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe force-pushed the cva6-upstream-rams branch from 12f6fb8 to 1ea7bac Compare November 6, 2026 11:16
CI's CTS stage stops in the Kepler LEC check: kepler-formal cannot load
the netlist, "cva6_icache_data_sram cannot be found in SNL", the macro
AUTO_MEMORIES makes of the I-cache data RAM. A new kepler-formal is in
the works; LEC_CHECK is 0 for cva6 until the Kepler team rewires it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018PFLaCzFtFbnWE4nPTDwpC
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe force-pushed the cva6-upstream-rams branch from 1ea7bac to afac85c Compare November 6, 2026 11:19
$(PLATFORM_DIR)/lib/NLDM/fakeram7_128x64.lib \
$(PLATFORM_DIR)/lib/NLDM/fakeram7_64x28.lib \
$(PLATFORM_DIR)/lib/NLDM/fakeram7_64x25.lib
# Kepler LEC off for now: kepler-formal stops on the macros AUTO_MEMORIES

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanocoh I'm disabling this for now. Once kepler-formal is bumped in bazel bcr and #4732 is merged, we're in a great position to wire up cva6 properly to cva6.

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.

ok. lets do that.

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.

Some update. The issue was not with the tool but with missing memory files that were added with this change and need to be given to the formal check. Added the fix to #4329

@oharboe

oharboe commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty cva6 is now set up quite differently, and correctly, so I see no sense in looking at the QoR "regression". This is a new baseline.

@maliberty
maliberty merged commit 8d33f93 into The-OpenROAD-Project:master Nov 6, 2026
10 of 12 checks passed
@oharboe

oharboe commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

😌

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.

cva6: D-cache data RAM drops its byte enables, so every cache write corrupts the other way

4 participants