uvm_memory_ranges

The class uvm_memory_ranges contains a list of ranges, sorted by starting address.

Create N allocated blocks with each having a size in the range [i,j] bytes.  Create the N allocated blocks

  • evenly over the range [A,B].
  • using a distribution D.
  • with average spacing between them in the range [k,l].
  • with NO spacing between them for P percent of the time.  Otherwise some other spacing.
Summary
uvm_memory_ranges
The class uvm_memory_ranges contains a list of ranges, sorted by starting address.
Class Declaration
class uvm_memory_ranges
Methods
m_new_range_randomCreate a new range, and mark it random.
add_range()This is the “by-hand” access routine.
add_range_random_by_hand()This is the “MEMORY_RAND_BY_HAND” access routine.
m_unlock()Internal use only, for turning constraints back on after a previous call to lock().
m_lock()Internal use only, for turning constraints off.
pre_randomize()Built-in function.
post_randomize()Built-in function.
m_checkA utility function that call be called anytime.

m_new_range_random

local function uvm_memory_range m_new_range_random(string l_tag_name =  "ranges")

Create a new range, and mark it random.  It is important to call randomize here - it appears to make the array more “fair”.  Instead of calling randomize(), you can just set the range_start and end values to zero - or any other value.  The real values will get set later (randomize() will be called later, whether or not you call randomize() now).

add_range()

virtual function uvm_memory_range add_range(address_t range_start,  
address_t range_end,  
string l_tag_name =  "ranges")

This is the “by-hand” access routine.  Create a new range with the range_start and end values specifid, and give it a “tag”.  The tag is used as a way to group ranges.

add_range_random_by_hand()

virtual function uvm_memory_range add_range_random_by_hand(
   string l_tag_name =  "ranges"
)

This is the “MEMORY_RAND_BY_HAND” access routine.  Create a placeholder for some random range.  We don’t care a lick about the values, just that we need to have a block.  It is tagged.  TODO: add a “size” parameter - create a block of at least size bytes.

m_unlock()

local function void m_unlock()

Internal use only, for turning constraints back on after a previous call to lock().

m_lock()

local function void m_lock()

Internal use only, for turning constraints off.  The goal is to turn off ALL constraints NOT associated with the size randomization.

pre_randomize()

function void pre_randomize()

Built-in function.  In this case we’re using pre_randomize() as a way to randomize the size of the array before randomizing the contents.

Take care of expansion and contraction.

post_randomize()

function void post_randomize()

Built-in function.  In this case we’re using post_randomize() as a way to randomize the value of the range_end attribute.

m_check

function void m_check()

A utility function that call be called anytime.  It checks to make sure the list is “OK”.  The list can get to be not OK if the constraints are not correct or if other bad things happen.  Under normal circumstances, this function won’t be neeed - the list will be fine.

TODO: Is this code needed anymore?

class uvm_memory_ranges
The class uvm_memory_ranges contains a list of ranges, sorted by starting address.
local function uvm_memory_range m_new_range_random(string l_tag_name =  "ranges")
Create a new range, and mark it random.
virtual function uvm_memory_range add_range(address_t range_start,  
address_t range_end,  
string l_tag_name =  "ranges")
This is the “by-hand” access routine.
virtual function uvm_memory_range add_range_random_by_hand(
   string l_tag_name =  "ranges"
)
This is the “MEMORY_RAND_BY_HAND” access routine.
local function void m_unlock()
Internal use only, for turning constraints back on after a previous call to lock().
local function void m_lock()
Internal use only, for turning constraints off.
function void pre_randomize()
Built-in function.
function void post_randomize()
Built-in function.
function void m_check()
A utility function that call be called anytime.