Skip to content

Fix inverted SRAM bank mapping in dmem read MUX - #4046

Merged
eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
ashnaaseth2325-oss:fix/dmem-read-mux-inversion
Mar 25, 2026
Merged

eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
ashnaaseth2325-oss:fix/dmem-read-mux-inversion

Conversation

@ashnaaseth2325-oss

Copy link
Copy Markdown
Contributor

1. SUMMARY

This PR fixes an incorrect read data selection in the dmem module where the output MUX returned data from the wrong SRAM bank. The issue affects flow/designs/src/riscv32i/dmem.v (lines 60–67), causing all memory reads to be inconsistent with the corresponding write bank.


2. FIX

// Before (incorrect mapping)
case (sel_mem)
  2'b00: mem_out = inter_dmem3;
  2'b01: mem_out = inter_dmem2;
  2'b10: mem_out = inter_dmem1;
  2'b11: mem_out = inter_dmem0;
endcase

// After (correct mapping)
case (sel_mem)
  2'b11: mem_out = inter_dmem3;
  2'b10: mem_out = inter_dmem2;
  2'b01: mem_out = inter_dmem1;
  2'b00: mem_out = inter_dmem0;
endcase

3. VERIFICATION

Run the existing RISC-V testbench and write a known value (e.g., 0xDEADBEEF) to an address in a specific memory bank (e.g., 0x8000_0000 for dmem3), then read it back. Before the fix, the read returns data from the wrong bank; after the fix, it correctly returns the written value. Repeat across other address regions to confirm all banks map correctly.

The sel_mem case arms were reversed, causing every memory
read to return data from the wrong SRAM bank.

Signed-off-by: Ashnaa Seth <ashnaaseth2325@gmail.com>
Signed-off-by: ashnaaseth2325-oss <ashnaaseth2325@gmail.com>
@ashnaaseth2325-oss
ashnaaseth2325-oss force-pushed the fix/dmem-read-mux-inversion branch from a86ded3 to 035008c Compare March 24, 2026 13:53
@ashnaaseth2325-oss

Copy link
Copy Markdown
Contributor Author

Hi @eder-matheus @maliberty,
Please review this PR whenever you get time.
Thanks!

@maliberty

Copy link
Copy Markdown
Member

I'll assume you got this right as it doesn't matter much to OR in any case.

@ashnaaseth2325-oss

Copy link
Copy Markdown
Contributor Author

Hi @maliberty,
Is it ready to merge?
Thanks!

@eder-matheus
eder-matheus merged commit 5c5d440 into The-OpenROAD-Project:master Mar 25, 2026
5 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