Skip to content

Extend uvm_mem to catch an address-decode bug – the base class remembers nothing

write-from-scratch / mem-modelUVM · runs take about 2 minutes

uvm_reg has a mirror: ask a field what it should read, and the register layer answers from tracked state. uvm_mem has none. Each access moves data across the bus and nothing remembers what any address was last set to; to check reads, you build that state yourself, by address.

uvm_mem’s hooks for it: post_write(uvm_reg_item rw) and post_read(uvm_reg_item rw) run from the base class’s do_write()/do_read() after every access, frontdoor or back, through any map. rw.get_offset() is the address; rw.get_value(0) is the data written or read back.

RequirementsOverriding both on tracked_mem with whatever member state you need

  1. A write records what its address should read back. That survives writes to other addresses until a write lands on the same address again.
  2. A read increments match_count if it returns the value last written to its address, and mismatch_count if it doesn’t.

Right nowmatch_count=0, want 4. The stub tracks nothing.

Done whenAfter the access sequence in the test, match_count is 4 and mismatch_count is

  1. One of the five reads hits data corrupted by an address-decode bug in the driver, and

your override is what catches it.

Source on GitHub

uvm_mem_needs_a_shadow_model.sv