Resources

UVMkit » 1800.2-2017
Contents
Resources
IntroA resource is a parameterized container that holds arbitrary data.
uvm_resource_typesProvides typedefs and enums used throughout the resources facility.
uvm_resource_optionsProvides a namespace for managing options for the resources facility.
uvm_resource_baseNon-parameterized base class for resources.
uvm_resource_baseThe library implements the following public API beyond what is documented in 1800.2.

Intro

A resource is a parameterized container that holds arbitrary data.  Resources can be used to configure components, supply data to sequences, or enable sharing of information across disparate parts of a testbench.  They are stored using scoping information so their visibility can be constrained to certain parts of the testbench.  Resource containers can hold any type of data, constrained only by the data types available in SystemVerilog.  Resources can contain scalar objects, class handles, queues, lists, or even virtual interfaces.

Resources are stored in a resource database so that each resource can be retrieved by name or by type.  The database has both a name table and a type table and each resource is entered into both.  The database is globally accessible.

Each resource has a set of scopes over which it is visible.  The set of scopes is represented as a regular expression.  When a resource is looked up the scope of the entity doing the looking up is supplied to the lookup function.  This is called the current scope.  If the current scope is in the set of scopes over which a resource is visible then the resource can be retuned in the lookup.

Resources can be looked up by name or by type.  To support type lookup each resource has a static type handle that uniquely identifies the type of each specialized resource container.

Multiple resources that have the same name are stored in a queue.  Each resource is pushed into a queue with the first one at the front of the queue and each subsequent one behind it.  The same happens for multiple resources that have the same type.  The resource queues are searched front to back, so those placed earlier in the queue have precedence over those placed later.

The precedence of resources with the same name or same type can be altered.  One way is to set the precedence member of the resource container to any arbitrary value.  The search algorithm will return the resource with the highest precedence.  In the case where there are multiple resources that match the search criteria and have the same (highest) precedence, the earliest one located in the queue will be one returned.  Another way to change the precedence is to use the set_priority function to move a resource to either the front or back of the queue.

The classes defined here form the low level layer of the resource database.  The classes include the resource container and the database that holds the containers.  The following set of classes are defined here:

uvm_resource_types: A class without methods or members, only typedefs and enums.  These types and enums are used throughout the resources facility.  Putting the types in a class keeps them confined to a specific name space.

uvm_resource_options: policy class for setting options, such as auditing, which effect resources.

uvm_resource_base: the base (untyped) resource class living in the resource database.  This class includes the interface for setting a resource as read-only, notification, scope management, altering search priority, and managing auditing.

uvm_resource#(T): parameterized resource container.  This class includes the interfaces for reading and writing each resource.  Because the class is parameterized, all the access functions are type safe.

uvm_resource_pool: the resource database.  This is a singleton class object.

uvm_resource_types

Provides typedefs and enums used throughout the resources facility.  This class has no members or methods, only typedefs.  It’s used in lieu of package-scope types.  When needed, other classes can use these types by prefixing their usage with uvm_resource_types::.  E.g.

uvm_resource_types::rsrc_q_t queue;
Summary
uvm_resource_types
Provides typedefs and enums used throughout the resources facility.
Class Declaration
class uvm_resource_types

uvm_resource_options

Provides a namespace for managing options for the resources facility.  The only thing allowed in this class is static local data members and static functions for manipulating and retrieving the value of the data members.  The static local data members represent options and settings that control the behavior of the resources facility.

Summary
uvm_resource_options
Provides a namespace for managing options for the resources facility.
Methods
turn_on_auditingTurn auditing on for the resource database.
turn_off_auditingTurn auditing off for the resource database.
is_auditingReturns 1 if the auditing facility is on and 0 if it is off.

turn_on_auditing

static function void turn_on_auditing()

Turn auditing on for the resource database.  This causes all reads and writes to the database to store information about the accesses.  Auditing is turned on by default.

turn_off_auditing

static function void turn_off_auditing()

Turn auditing off for the resource database.  If auditing is turned off, it is not possible to get extra information about resource database accesses.

is_auditing

static function bit is_auditing()

Returns 1 if the auditing facility is on and 0 if it is off.

uvm_resource_base

Non-parameterized base class for resources.  Supports interfaces for scope matching, and virtual functions for printing the resource and for printing the accessor list

Summary
uvm_resource_base
Non-parameterized base class for resources.
Class Hierarchy
uvm_resource_base

uvm_resource_base

The library implements the following public API beyond what is documented in 1800.2.

Summary
uvm_resource_base
The library implements the following public API beyond what is documented in 1800.2.
Class Hierarchy
uvm_resource_base
Class Declaration
virtual class uvm_resource_base extends uvm_object
precedenceThis variable is used to associate a precedence that a resource has with respect to other resources which match the same scope and name.
default_precedenceThe default precedence for an resource that has been created.
newconstructor for uvm_resource_base.
get_type_handlePure virtual function that returns the type handle of the resource container.
Read-only Interface
set_read_onlyEstablishes this resource as a read-only resource.
Notification
wait_modifiedThis task blocks until the resource has been modified -- that is, a uvm_resource#(T)::write operation has been performed.
Scope Interface
set_scopeSet the value of the regular expression that identifies the set of scopes over which this resource is visible.
get_scopeRetrieve the regular expression string that identifies the set of scopes over which this resource is visible.
match_scopeUsing the regular expression facility, determine if this resource is visible in a scope.
PriorityFunctions for manipulating the search priority of resources.
set priorityChange the search priority of the resource based on the value of the priority enum argument.
Utility Functions
Audit TrailTo find out what is happening as the simulation proceeds, an audit trail of each read and write is kept.
record_read_accessRecord the read access information for this resource for debug purposes.
record_write_accessRecord the write access information for this resource for debug purposes.
print_accessorsPrint the read/write access history of the resource, using the accessor argument <accessor> which is passed to the uvm_resource#(T)::read and uvm_resource#(T)::write
init_access_recordInitialize a new access record

precedence

int unsigned precedence

This variable is used to associate a precedence that a resource has with respect to other resources which match the same scope and name.  Resources are set to the default_precedence initially, and may be set to a higher or lower precedence as desired.

default_precedence

static int unsigned default_precedence = 1000

The default precedence for an resource that has been created.  When two resources have the same precedence, the first resource found has precedence.

new

`ifdef UVM_ENABLE_DEPRECATED_API function new( string  name  =  "",
string  s  =  "*" )

constructor for uvm_resource_base.  The constructor takes two arguments, the name of the resource and a regular expression which represents the set of scopes over which this resource is visible.

get_type_handle

pure virtual function uvm_resource_base get_type_handle()

Pure virtual function that returns the type handle of the resource container.

set_read_only

function void set_read_only()

Establishes this resource as a read-only resource.  An attempt to call uvm_resource#(T)::write on the resource will cause an error.

wait_modified

task wait_modified()

This task blocks until the resource has been modified -- that is, a uvm_resource#(T)::write operation has been performed.  When a uvm_resource#(T)::write is performed the modified bit is set which releases the block.  Wait_modified() then clears the modified bit so it can be called repeatedly.

set_scope

function void set_scope( string  s )

Set the value of the regular expression that identifies the set of scopes over which this resource is visible.  If the supplied argument is a glob it will be converted to a regular expression before it is stored.

get_scope

function string get_scope()

Retrieve the regular expression string that identifies the set of scopes over which this resource is visible.

match_scope

function bit match_scope( string  s )

Using the regular expression facility, determine if this resource is visible in a scope.  Return one if it is, zero otherwise.

Priority

Functions for manipulating the search priority of resources.  The function definitions here are pure virtual and are implemented in derived classes.  The definitons serve as a priority management interface.

set priority

Change the search priority of the resource based on the value of the priority enum argument.

Audit Trail

To find out what is happening as the simulation proceeds, an audit trail of each read and write is kept.  The uvm_resource#(T)::read and uvm_resource#(T)::write methods each take an accessor argument.  This is a handle to the object that performed that resource access.

function T read(uvm_object accessor = null);
function void write(T t, uvm_object accessor = null);

The accessor can by anything as long as it is derived from uvm_object.  The accessor object can be a component or a sequence or whatever object from which a read or write was invoked.  Typically the this handle is used as the accessor.  For example:

uvm_resource#(int) rint;
int i;
...
rint.write(7, this);
i = rint.read(this);

The accessor’s get_full_name() is stored as part of the audit trail.  This way you can find out what object performed each resource access.  Each audit record also includes the time of the access (simulation time) and the particular operation performed (read or write).

Auditing is controlled through the uvm_resource_options class.

record_read_access

function void record_read_access( uvm_object  accessor  =  null )

Record the read access information for this resource for debug purposes.  This information is used by print_accessors function.

@uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2

record_write_access

function void record_write_access( uvm_object  accessor  =  null )

Record the write access information for this resource for debug purposes.  This information is used by print_accessors function.

@uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2

print_accessors

virtual function void print_accessors()

Print the read/write access history of the resource, using the accessor argument <accessor> which is passed to the uvm_resource#(T)::read and uvm_resource#(T)::write

@uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2

init_access_record

function void init_access_record (
    inout uvm_resource_types:: access_t  access_record
)

Initialize a new access record

class uvm_resource_types
Provides typedefs and enums used throughout the resources facility.
virtual class uvm_resource_base extends uvm_object
The library implements the following public API beyond what is documented in 1800.2.
Provides a namespace for managing options for the resources facility.
class uvm_resource #( type  T  =  int ) extends uvm_resource_base
Implementation of uvm_resource#(T) as defined in section C.2.5.1 of 1800.2-2017.
class uvm_resource_pool
The global (singleton) resource database.
static function void turn_on_auditing()
Turn auditing on for the resource database.
static function void turn_off_auditing()
Turn auditing off for the resource database.
static function bit is_auditing()
Returns 1 if the auditing facility is on and 0 if it is off.
virtual class uvm_void
The uvm_void class is the base class for all UVM classes.
virtual class uvm_object extends uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
int unsigned precedence
This variable is used to associate a precedence that a resource has with respect to other resources which match the same scope and name.
static int unsigned default_precedence = 1000
The default precedence for an resource that has been created.
`ifdef UVM_ENABLE_DEPRECATED_API function new( string  name  =  "",
string  s  =  "*" )
constructor for uvm_resource_base.
pure virtual function uvm_resource_base get_type_handle()
Pure virtual function that returns the type handle of the resource container.
function void set_read_only()
Establishes this resource as a read-only resource.
task wait_modified()
This task blocks until the resource has been modified -- that is, a uvm_resource#(T)::write operation has been performed.
function void write( t,   
uvm_object  accessor  =  null )
function void set_scope( string  s )
Set the value of the regular expression that identifies the set of scopes over which this resource is visible.
function string get_scope()
Retrieve the regular expression string that identifies the set of scopes over which this resource is visible.
function bit match_scope( string  s )
Using the regular expression facility, determine if this resource is visible in a scope.
function void record_read_access( uvm_object  accessor  =  null )
Record the read access information for this resource for debug purposes.
function void record_write_access( uvm_object  accessor  =  null )
Record the write access information for this resource for debug purposes.
virtual function void print_accessors()
Print the read/write access history of the resource, using the accessor argument accessor which is passed to the uvm_resource#(T)::read and uvm_resource#(T)::write
function T read( uvm_object  accessor  =  null )
function void init_access_record (
    inout uvm_resource_types:: access_t  access_record
)
Initialize a new access record