uvm_memory

uvm_memory is used to model memory, and have that modeled memory participate with the register models in order to support certain address map verification techniques (like “shadow” memory and randomized configurations of memory and registers).

The choice of how to model memory needs to be made carefully.  The model of memory supported by uvm_memory is as follows. uvm_memory “contains” a regular verilog memory - modeled something like bit[7:0]mem[address]; or bit[31:0]mem[address]; or T mem[address];

where T is some typedef (packed struct, union, etc).

The ‘mem’ field is a sparse array, which means it consumes little or no actual space until a value is written to an address.

Within a management memory space, there can be ranges.  The ranges can either be unmanaged (holes) or managed.  The holes are treated like “illegal” memory access.  The managed ranges are treated like memory which “could be used”.

Summary
uvm_memory
uvm_memory is used to model memory, and have that modeled memory participate with the register models in order to support certain address map verification techniques (like “shadow” memory and randomized configurations of memory and registers).
Class Hierarchy
uvm_register#(T)
uvm_memory
Class Declaration
class uvm_memory #(
   type T =  int
) extends uvm_register#(T)
Variables
mem[int]A “regular” verilog memory implemented as an associative array (sparse array).
rangesThis is the list of managed (and unmanaged) addresses.
start_addressThe first legal address to use in this memory.
end_addressThe last legal address to use in this memory.
Methods
mem_poke()“Write” to the actual memory using address (addr) and data (d).
mem_peek()“Read” from the actual memory using address (addr).
mem_poke_bytes()Given an address (addr) and an array of bytes, write those bytes into the memory, starting at the address supplied.
mem_peek_bytes()Given an address (addr) and a number of bytes to read, return a list of bytes (nbytes long) starting from the address supplied.
bus_read()

mem[int]

T mem[int]

A “regular” verilog memory implemented as an associative array (sparse array).  Each memory location is of type ‘T’.  Normal access to this memory is to use mem_peek() and mem_poke().

ranges

uvm_memory_ranges ranges

This is the list of managed (and unmanaged) addresses.  In a future release ‘ranges’ will be ‘rand’.

start_address

address_t start_address

The first legal address to use in this memory.

end_address

address_t end_address

The last legal address to use in this memory.

mem_poke()

function void mem_poke(address_t addr,
d)

”Write” to the actual memory using address (addr) and data (d).

mem_peek()

function T mem_peek(address_t addr)

”Read” from the actual memory using address (addr).  Return the value read.

mem_poke_bytes()

virtual function void mem_poke_bytes(address_t addr,
bytearray_t d)

Given an address (addr) and an array of bytes, write those bytes into the memory, starting at the address supplied.

mem_peek_bytes()

virtual function void mem_peek_bytes(output bytearray_t d,
input address_t addr,
int nbytes)

Given an address (addr) and a number of bytes to read, return a list of bytes (nbytes long) starting from the address supplied.

bus_read()

virtual function void bus_read(bytearray_t read_data,  
address_t address =  0)
class uvm_memory #(type T =  int) extends uvm_register#(T)
uvm_memory is used to model memory, and have that modeled memory participate with the register models in order to support certain address map verification techniques (like “shadow” memory and randomized configurations of memory and registers).
T mem[int]
A “regular” verilog memory implemented as an associative array (sparse array).
uvm_memory_ranges ranges
This is the list of managed (and unmanaged) addresses.
address_t start_address
The first legal address to use in this memory.
address_t end_address
The last legal address to use in this memory.
function void mem_poke(address_t addr,
d)
“Write” to the actual memory using address (addr) and data (d).
function T mem_peek(address_t addr)
“Read” from the actual memory using address (addr).
virtual function void mem_poke_bytes(address_t addr,
bytearray_t d)
Given an address (addr) and an array of bytes, write those bytes into the memory, starting at the address supplied.
virtual function void mem_peek_bytes(output bytearray_t d,
input address_t addr,
int nbytes)
Given an address (addr) and a number of bytes to read, return a list of bytes (nbytes long) starting from the address supplied.
virtual function void bus_read(bytearray_t read_data,  
address_t address =  0)