Skip to content

Commit ce6ea03

Browse files
committed
fix: initialize the last 4 bytes of mem to zero
These last 4 bytes are, in fact, used for register `x0`, and must be zero. In multi-valued simulators, however, without an explicit init, these bytes start as undefined. Moving `x0` to anywhere results in those undefined bytes "infecting" other registers. Issue: #148
1 parent 24006a7 commit ce6ea03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

serving/serving_ram.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ module serving_ram
4242
$display("Preloading %m from %s", memfile);
4343
$readmemh(memfile, mem);
4444
end
45+
46+
// The last 4 bytes are the `x0` (zero) register. Zero them out
47+
// to avoid starting the simulation with `x0` undefined.
48+
mem[depth-4] = 8'h0;
49+
mem[depth-3] = 8'h0;
50+
mem[depth-2] = 8'h0;
51+
mem[depth-1] = 8'h0;
4552
endmodule

0 commit comments

Comments
 (0)