~ruther/verilog-riscv-semestral-project

ca9604e2c8a9c44ccba5223ef095d84cd618bbe1 — Rutherther 1 year, 5 months ago 30a7f94
fix: offset ram by bytes, not bits
1 files changed, 4 insertions(+), 4 deletions(-)

M src/ram.sv
M src/ram.sv => src/ram.sv +4 -4
@@ 8,14 8,14 @@ module ram (

  reg [4095:0]    RAM;

  assign rd = RAM[a[11:0] +:32]; // word aligned
  assign rd = RAM[(a[11:0] * 8) +:32]; // word aligned

  always @(posedge clk)
    if(we) begin
      case(mask)
        MEM_BYTE: RAM[a[11:0] +:8] <= wd[7:0];
        MEM_HALFWORD: RAM[a[11:0] +:16] <= wd[15:0];
        MEM_WORD: RAM[{a[11:0]} +:32] <= wd[31:0];
        MEM_BYTE: RAM[(a[11:0] * 8) +:8] <= wd[7:0];
        MEM_HALFWORD: RAM[(a[11:0] * 8) +:16] <= wd[15:0];
        MEM_WORD: RAM[(a[11:0] * 8) +:32] <= wd[31:0];
        default: ;
      endcase
    end

Do not follow this link