svt_mem Class Reference

Inheritance diagram for class svt_mem:

List of all members.


Detailed Description

This class is used to model a single memory region.

An instance of this class represents an address space. When constructed, the address space number is assigned to the instance. If there are multiple memory banks/address spaces, the value of m_bv_addr_region should be used to select the corresponding memory instance to access.

Internally, the memory is modeled with a sparse array of svt_mem_word objects, each of which represents a full data word.



Public Member Functions

function void  clear ( )
function svt_pattern  do_allocate_pattern ( )
function bit  do_compare ( uvm_object rhs, uvm_comparer comparer )
function void  do_copy ( uvm_object rhs )
function void  do_print ( uvm_printer printer )
function bit  get_aligned_addr ( ref bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr )
function string  get_mcd_class_name ( )
function bit  get_prop_val ( string prop_name, ref bit [1023:0] prop_val, input int array_ix, ref svt_sequence_item_base data_obj )
function bit  get_property ( string name, output bit [1023:0] value )
function bit  is_in_bounds ( bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr )
function bit  is_locked ( bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr )
function bit  load_mem ( string filename, bit is_pattern = 0, int data_wdth = -1, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] start_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] end_addr = 1 << 64 - 1 )
function void  new ( string name = "svt_mem_inst", string suite_name = "", int data_wdth = 32, int addr_region = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] min_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] max_addr = 1 << 64 - 1 )
function logic [SVT_MEM_MAX_DATA_WIDTH-1:0]  read ( bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr, int set_lock = -1 )
function bit  save_mem ( string filename, int data_wdth = -1, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] start_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] end_addr = 1 << 64 - 1, bit enable_autosize_of_saveddata = 0 )
task   set_meminit ( svt_mem :: meminit_enum meminit = UNKNOWNS, bit [SVT_MEM_MAX_DATA_WIDTH-1:0] meminit_value = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] meminit_address_offset = 0 )
function void  set_property ( string name, bit [1023:0] value )
function bit  write ( bit [(SVT_MEM_MAX_ADDR_WIDTH-1):0] addr = 0, bit [(SVT_MEM_MAX_DATA_WIDTH-1):0] data = 0, bit [(SVT_MEM_MAX_DATA_WIDTH/8-1):0] byteen = ~0, int set_lock = -1 )

Public Attributes

bit [SVT_MEM_MAX_ADDR_REGION_WIDTH-1:0]  addr_region = 0; 
int  data_wdth = 0; 
bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  max_addr = 0; 
svt_mem :: meminit_enum  meminit 
bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  meminit_address_offset 
bit [SVT_MEM_MAX_DATA_WIDTH-1:0]  meminit_value 
bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  min_addr = 0; 
bit [SVT_MEM_MAX_DATA_WIDTH-1:0]  user_pattern [$] 

Member Typedefs

 typedef enum  meminit_enum 


Member Function Documentation

  function void
 svt_mem::clear

 (   ) 


Clears contents of the memory.

  function svt_pattern
 svt_mem::do_allocate_pattern

 (   ) 


Added t support the svt_shorthand_psdisplay_method

 Superseded functions 
 svt_sequence_item_base :: do_allocate_pattern 

  function bit
 svt_mem::do_compare

 (  uvm_object rhs , uvm_comparer comparer  ) 


Extend the compare routine to compare the memory contents

 Superseded functions 
 uvm_object :: do_compare 
 svt_sequence_item_base :: do_compare 

  function void
 svt_mem::do_copy

 (  uvm_object rhs  ) 


Extend the copy routine to compare the memory contents

 Superseded functions 
 uvm_object :: do_copy 
 uvm_transaction :: do_copy 
 svt_sequence_item_base :: do_copy 

  function void
 svt_mem::do_print

 (  uvm_printer printer  ) 


Extend the display routine to display the memory contents

 Superseded functions 
 uvm_object :: do_print 
 uvm_transaction :: do_print 
 uvm_sequence_item :: do_print 
 svt_sequence_item_base :: do_print 

  function bit
 svt_mem::get_aligned_addr

 (  ref bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr  ) 


Gets the aligned address.

  function string
 svt_mem::get_mcd_class_name

 (   ) 


Returns the class name for the object.

 Superseded functions 
 svt_sequence_item_base :: get_mcd_class_name 

  function bit
 svt_mem::get_prop_val

 (  string prop_name , ref bit [1023:0] prop_val , input int array_ix , ref svt_sequence_item_base data_obj  ) 


Added to support the svt_shorthand_psdisplay method

 Superseded functions 
 svt_sequence_item_base :: get_prop_val 

  function bit
 svt_mem::get_property

 (  string name , output bit [1023:0] value  ) 


Obtains a property value from this memory

name - Property name to retrieve the value for

value - Property value that was previously set

Return values - Return 1 if the name was previously set, 0 if not previously set

  function bit
 svt_mem::is_in_bounds

 (  bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr  ) 


Used to check whether a given byte-level address is within the Min/Max bounds for this memory.

addr - The byte-level address to be checked.

Return values - 1 if the address is in the memory, 0 if it is not.

  function bit
 svt_mem::is_locked

 (  bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr  ) 


Used to check whether a given byte-level address within this memory is locked or not locked.

addr - The byte-level address to be checked.

Return values - 1 if the address is locked, 0 if it is not.

  function bit
 svt_mem::load_mem

 (  string filename , bit is_pattern = 0, int data_wdth = -1, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] start_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] end_addr = 1 << 64 - 1  ) 


Loads the contents of the file into memory. Data should be in $readmemh format.

If the data width of the file contents is different than the configured width of the memory then a step value is generated that is proportional to the relationship between the two widths.

  • If the data width of the file is less than the configured data width of the memory then each value that is read from the file will be merged to write into contiguous memory addresses.
  • If the data width of the file is greater than the the configured data width of the memory then each value read from the file will be split to write into multiple contiguous memory addresses. Care must be taken in this case to not exceed the end address if one is supplied to this method.

filename - Name of the file from which data is to be loaded.

is_pattern - If this bit is set, the contents of the file are loaded as a user-defined pattern. This pattern is used to return data from a read to an uninitialized location if meminit is USER_PATTERN. The pattern is repeated across the entire memory.

data_wdth - If the data width of the memory is greater than or equal to 8 and is an exact power of 2, this value specifies the data width of the the words in the file. If the data width of the memory is not a power of 2 or is less than 8, this value must be left at its default value (-1). If left at its default value, it is assumed that the data width of the words in the file is same as that of the memory.

start_addr - The byte aligned start address at which data in the memory is to be loaded. If the value supplied is not byte aligned then a warning is generated and the start address will be modified to be byte aligned. This argument is optional, and if not provided then the load will begin at address 0.

end_addr - The byte aligned end address up to which data is to be loaded. If the value supplied is not byte aligned then a warning is generated and the end address will be modified to be byte aligned. This argument is optional, and if not provided then the end address will be the maximum addressable location.

  function void
 svt_mem::new

 (  string name = "svt_mem_inst", string suite_name = "", int data_wdth = 32, int addr_region = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] min_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] max_addr = 1 << 64 - 1  ) 


CONSTRUCTOR: Create a new instance of this class.

When this object is created, the memory is assigned an instance name, data width, an address region and Max/Min byte address locations.

name - Intance name for this memory object

suite_name - Name of the suite in which the memory is used.

data_wdth - The data width of this memory.

addr_region - The address region of this memory.

min_addr - The lower (word-aligned) address bound of this memory.

max_addr - The upper (word-aligned) address bound of this memory.

  function logic [SVT_MEM_MAX_DATA_WIDTH-1:0]
 svt_mem::read

 (  bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] addr , int set_lock = -1  ) 


Returns the value of the data word stored by this object.

addr - The byte-level address to be read. The addr should be aligned to the data_width of memory, if address is unaligned it will be realigned to data_width of memory.

set_lock - (Optional) If supplied as 1 (or any positive int), locks this memory location (preventing writes). If supplied as 0, unlocks this memory location (to allow writes). If not supplied (or supplied as any negative int) the locked/unlocked state of this memory location is not changed.

Return values - The data stored at the indicated address. If the address has not previously been written, data is returned per the setting in meminit.

  function bit
 svt_mem::save_mem

 (  string filename , int data_wdth = -1, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] start_addr = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] end_addr = 1 << 64 - 1, bit enable_autosize_of_saveddata = 0  ) 


Dumps the contents of this memory into a file. The data is dumped in hex format.

filename - Name of the file into which the contents are to be dumped.

data_wdth - If the data width of the memory is greater than or equal to 8 and is an exact power of 2, this value specifies the data width of the the words in the file. If the data width of the memory is not a power of 2 or is less than 8, this value must be left at its default value (-1). If left at its default value, it is assumed that the data width of the words in the file is same as that of the memory.

start_addr - The start address from which data in the memory is to be saved.

end_addr - The end address upto which data is to be saved.

enable_autosize_of_saveddata - Control to write/save the data with automatic sizing i.e. with leading zeros, if any

  task
 svt_mem::set_meminit

 (  svt_mem :: meminit_enum meminit = UNKNOWNS, bit [SVT_MEM_MAX_DATA_WIDTH-1:0] meminit_value = 0, bit [SVT_MEM_MAX_ADDR_WIDTH-1:0] meminit_address_offset = 0  ) 


Configures how the memory structures data to be returned by reads from uninitialized addresses.

meminit - (Optional: Default = UNKNOWNS). Refer to meminit_enum for supported types.

meminit_value - Specifies the (hex) value to be returned by a read from any uninitialized memory location, if the meminit argument was passed with the value VALUE. Specifies the value at the minimum address if the meminit argument was passed as INCR or DECR.

meminit_address_offset - Specifies the (hex) value of a word-aligned byte level address. If (and only if) the meminit argument was passed with the value ADDR, a read from any uninitialized memory location will return the address of that location, plus this offset.

  function void
 svt_mem::set_property

 (  string name , bit [1023:0] value  ) 


Applies a property value to this memory

name - Property name to be set

value - Property value to be set

  function bit
 svt_mem::write

 (  bit [(SVT_MEM_MAX_ADDR_WIDTH-1):0] addr = 0, bit [(SVT_MEM_MAX_DATA_WIDTH-1):0] data = 0, bit [(SVT_MEM_MAX_DATA_WIDTH/8-1):0] byteen = ~0, int set_lock = -1  ) 


Stores a data word into this object, with optional byte-enables.

addr - The byte-level address to be written. The addr should be aligned to the data_width of memory, if address is unaligned it will be realigned to data_width of memory.

data - The data word to be stored. If the memory location is currently locked, the attempted write will not change the stored data, and the function will return 0.

byteen - (Optional) The byte-enables to be applied to this write. A 1 in a given bit position enables the byte in the data word corresponding to that bit position.

set_lock - (Optional) If supplied as 1 (or any positive int), locks this memory location (preventing writes). If supplied as 0, unlocks this memory location (to allow writes). If not supplied (or supplied as any negative int) the locked/unlocked state of this memory location is not changed.

Return values - 1 if the write was successful, or 0 if it was not successful (because the memory location was locked).


Member Attribute Documentation

 bit [SVT_MEM_MAX_ADDR_REGION_WIDTH-1:0]  attribute
 svt_mem::addr_region = 0


Identifies the address region in which this memory resides.

 int  attribute
 svt_mem::data_wdth = 0


Stores the effective data width, as defined by the configuration.

 bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  attribute
 svt_mem::max_addr = 0


Identifies maximum byte-level address considered part of this memory.

 svt_mem :: meminit_enum  attribute
 svt_mem::meminit = UNKNOWNS


Determines the form of data that is returned by a read from an address that has not previously been written.

 bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  attribute
 svt_mem::meminit_address_offset


The offset to be added to the address, the sum of which defines the data returned by read from a location not previously written, if (and only if) meminit = ADDR.

 bit [SVT_MEM_MAX_DATA_WIDTH-1:0]  attribute
 svt_mem::meminit_value


Value used to calculate default data returned by read from a location not previously written, if meminit is VALUE, INCR or DECR. If meminit = VALUE, this represents the default value returned; if meminit = INCR or if meminit = DECR, this represents the default value at the minimum byte-level address of this memory. Default value of other locations will be calculated based on this value.

 bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]  attribute
 svt_mem::min_addr = 0


Identifies minimum byte-level address considered part of this memory.

 bit [SVT_MEM_MAX_DATA_WIDTH-1:0]  attribute
 svt_mem::user_pattern[$]


Queue used to store a user-defined pattern

Member Typedef Documentation

 Typedefe'd string ==>   bit [SVT_MEM_MAX_ADDR_WIDTH-1:0]

 Typedefe'd string ==>   bit [SVT_MEM_MAX_DATA_WIDTH-1:0]

 typedef enum  svt_mem::meminit_enum

Defines values used to specify what type of data is returned when a read targets a memory address that has not been initialized (not previously written).

UNKNOWNS(SVT_MEM_INIT_UNKNOWNS)
Reading any uninitialized address returns Xs.
ZEROES(SVT_MEM_INIT_ZEROES)
Reading any uninitialized address returns 0s.
ONES(SVT_MEM_INIT_ONES)
Reading any uninitialized address returns 1s.
ADDRESS(SVT_MEM_INIT_ADDRESS)
Reading any uninitialized address returns the address (plus an optional offset).
VALUE(SVT_MEM_INIT_VALUE)
Reading any uninitialized address returns a fixed value.
INCR(SVT_MEM_INIT_INCR)
Reading any uninitialized address returns the incrementing pattern stored in the address. If the incremented value exceeds 2**data_wdth, the higher order bits are masked out.
DECR(SVT_MEM_INIT_DECR)
Reading any uninitialized address returns the decrementing pattern stored in the address. If the decremented value is less than 0, the returned value is 0.
USER_PATTERN(SVT_MEM_INIT_USER_PATTERN)
Reading any uninitialized address returns data is based on the user pattern that has been loaded into the memory using load_mem. The pattern loaded through load_mem is considered to be repeated across the entire address range and the data returned is calculated accordingly.
RANDOM(SVT_MEM_INIT_RANDOM)
Reading any uninitialized address returns random data