UVM Resource Database

UVMkit » 1800.2-2017
Summary
UVM Resource Database
IntroThe uvm_resource_db class provides a convenience interface for the resources facility.

Intro

The uvm_resource_db class provides a convenience interface for the resources facility.  In many cases basic operations such as creating and setting a resource or getting a resource could take multiple lines of code using the interfaces in uvm_resource_base or uvm_resource#(T).  The convenience layer in uvm_resource_db reduces many of those operations to a single line of code.

If the run-time +UVM_RESOURCE_DB_TRACE command line option is specified, all resource DB accesses (read and write) are displayed.

uvm_resource_db

Implementation of uvm_resource_db, as defined in section C.3.2.1 of 1800.2-2017.

class uvm_resource_db#(type T=uvm_object)
Summary
uvm_resource_db
Implementation of uvm_resource_db, as defined in section C.3.2.1 of 1800.2-2017.
Class Declaration
class uvm_resource_db #( type  T  =  uvm_object )
Methods
get_by_typeGet a resource by type.
get_by_nameImports a resource by name.
set_defaultadd a new item into the resources database.
read_by_nameLocates a resource by name and scope and reads its value.
read_by_typeReads a value by type.
dumpDump all the resources in the resource pool.

get_by_type

static function rsrc_t get_by_type( string  scope )

Get a resource by type.  The type is specified in the db class parameter so the only argument to this function is the scope.

get_by_name

static function rsrc_t get_by_name( string  scope,   
string  name,   
bit  rpterr  =  1 )

Imports a resource by name.  The first argument is the current scope of the resource to be retrieved and the second argument is the name.  The rpterr flag indicates whether or not to generate a warning if no matching resource is found.

set_default

static function rsrc_t set_default( string  scope,
string  name )

add a new item into the resources database.  The item will not be written to so it will have its default value.  The resource is created using name and scope as the lookup parameters.

read_by_name

static function bit read_by_name( input  string  scope,   
input  string  name,   
inout  val,   
input  uvm_object  accessor  =  null )

Locates a resource by name and scope and reads its value.  The value is returned through the inout argument val.  The return value is a bit that indicates whether or not the read was successful.  The accessor is available for an implementation to use for debug purposes only; its value shall have no functional effect on outcome of this method.

Note: This function deviates from IEEE 1800.2-2017 LRM as it defines the val argument as inout, whereas the LRM defines it as an output.

static function bit read_by_name(input string scope,
                                 input string name,
                                 inout T val,
                                 input uvm_object accessor = null);

The implementation treats the argument as inout for cases where a read may fail and the value will not change from its original supplied value.

@uvm-contrib This API is being considered for potential contribution to 1800.2

read_by_type

static function bit read_by_type( input  string  scope,   
inout  val,   
input  uvm_object  accessor  =  null )

Reads a value by type.  The value is returned through the inout argument val.  The scope is used for the lookup.  The return value is a bit that indicates whether or not the read is successful.  The accessor is available for an implementation to use for debug purposes only; its value shall have no functional effect on outcome of this method.

Note: This function deviates from IEEE 1800.2-2017 LRM as it defines the <val> argument as inout, whereas the LRM defines it as an output.

static function bit read_by_type(input string scope,
                                 inout T val,
                                 input uvm_object accessor = null);

The implementation treats the argument as inout for cases where a read may fail and the value will not change from its original supplied value.

@uvm-contrib This API is being considered for potential contribution to 1800.2

dump

static function void dump()

Dump all the resources in the resource pool.  This is useful for debugging purposes.  This function does not use the parameter T, so it will dump the same thing -- the entire database -- no matter the value of the parameter.

class uvm_resource_db #( type  T  =  uvm_object )
Implementation of uvm_resource_db, as defined in section C.3.2.1 of 1800.2-2017.
Non-parameterized base class for resources.
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.
static function rsrc_t get_by_type( string  scope )
Get a resource by type.
static function rsrc_t get_by_name( string  scope,   
string  name,   
bit  rpterr  =  1 )
Imports a resource by name.
static function rsrc_t set_default( string  scope,
string  name )
add a new item into the resources database.
static function bit read_by_name( input  string  scope,   
input  string  name,   
inout  val,   
input  uvm_object  accessor  =  null )
Locates a resource by name and scope and reads its value.
static function bit read_by_type( input  string  scope,   
inout  val,   
input  uvm_object  accessor  =  null )
Reads a value by type.
static function void dump()
Dump all the resources in the resource pool.