Verification #49 · 2026-11-11 · Memory models · Easy · about 10 min

A RAM model that reads its own write

ram_dp is a 16 x 8 RAM with a write port and a read port that can both be used in the same cycle. On a rising edge:

  • we = 1 writes wdata to waddr.
  • re = 1 loads rdata from raddr. If we writes the same address on that edge, the read still returns the old contents.
  • re = 0 leaves rdata unchanged.

The RAM starts as all zeros. ram_model in ram_model.sv is the testbench's copy of it: step() is called once per edge with that edge's inputs and returns what rdata will be after the edge.

The RAM is correct, but Run shows the model disagreeing with it. Fix ram_model.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.