# UVM Resource Database

Contents

UVM Resource Database |
Intro | The uvm_resource_db class provides a convenience interface for the resources facility.
uvm_resource_db | All of the functions in uvm_resource_db#(T) are static, so they must be called using the :: operator.
uvm_resource_db_options | Provides a namespace for managing options for the resources DB 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

All of the functions in uvm_resource_db#(T) are static, so they must be called using the :: operator. For example:

>     uvm_resource_db#(int)::set("A", "*", 17, this);

The parameter value “int” identifies the resource type as uvm_resource#(int). Thus, the type of the object in the resource container is int. This maintains the type-safety characteristics of resource operations.

Summary

uvm_resource_db
All of the functions in uvm_resource_db#(T) are static, so they must be called using the :: operator.
Class Declaration
> class uvm_resource_db #(
> | type | T | = | uvm_object
> )
Methods |
get_by_type | Get a resource by type.
get_by_name | Imports a resource by name.
set_default | add a new item into the resources database.
set | Create a new resource, write a val to it, and set it into the database using name and scope as the lookup parameters.
set_anonymous | Create a new resource, write a val to it, and set it into the database.
read_by_name | locate a resource by name and scope and read its value.
read_by_type | Read a value by type.
write_by_name | write a val into the resources database.
write_by_type | write a val into the resources database.
dump | Dump all the resources in the resource pool.

### Methods

### 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.

### set

> static function void set(
> | input | string | scope, |  |
> | input | string | name, |  |
> |  | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

Create a new resource, write a val to it, and set it into the database using name and scope as the lookup parameters. The accessor is used for auditing.

### set_anonymous

> static function void set_anonymous(
> | input | string | scope, |  |
> |  | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

Create a new resource, write a val to it, and set it into the database. The resource has no name and therefore will not be entered into the name map. But is does have a scope for lookup purposes. The accessor is used for auditing.

### read_by_name

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

locate a resource by name and scope and read its value. The value is returned through the output argument val. The return value is a bit that indicates whether or not the read was successful. The accessor is used for auditing.

### read_by_type

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

Read a value by type. The value is returned through the output 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 used for auditing.

### write_by_name

> static function bit write_by_name(
> | input | string | scope, |  |
> | input | string | name, |  |
> | input | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

write a val into the resources database. First, look up the resource by name and scope. If it is not located then add a new resource to the database and then write its value.

Because the scope is matched to a resource which may be a regular expression, and consequently may target other scopes beyond the scope argument. Care must be taken with this function. If a get_by_name match is found for name and scope then val will be written to that matching resource and thus may impact other scopes which also match the resource.

### write_by_type

> static function bit write_by_type(
> | input | string | scope, |  |
> | input | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

write a val into the resources database. First, look up the resource by type. If it is not located then add a new resource to the database and then write its value.

Because the scope is matched to a resource which may be a regular expression, and consequently may target other scopes beyond the scope argument. Care must be taken with this function. If a get_by_name match is found for name and scope then val will be written to that matching resource and thus may impact other scopes which also match the resource.

### 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.

## uvm_resource_db_options

Provides a namespace for managing options for the resources DB 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 DB facility.

Summary

uvm_resource_db_options
Provides a namespace for managing options for the resources DB facility.
Methods |
turn_on_tracing | Turn tracing on for the resource database.
turn_off_tracing | Turn tracing off for the resource database.
is_tracing | Returns 1 if the tracing facility is on and 0 if it is off.

### Methods

### turn_on_tracing

> static function void turn_on_tracing()

Turn tracing on for the resource database. This causes all reads and writes to the database to display information about the accesses. Tracing is off by default.

This method is implicitly called by the +UVM_RESOURCE_DB_TRACE.

### turn_off_tracing

> static function void turn_off_tracing()

Turn tracing off for the resource database.

### is_tracing

> static function bit is_tracing()

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

> class uvm_resource_db #(
> | type | T | = | uvm_object
> )

All of the functions in uvm_resource_db#(T) are static, so they must be called using the :: operator.

> virtual class uvm_resource_base extends uvm_object

Non-parameterized base class for resources.

> class uvm_resource #(
> | type | T | = | int
> ) extends uvm_resource_base

Parameterized resource.

> 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 void set(
> | input | string | scope, |  |
> | input | string | name, |  |
> |  | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

Create a new resource, write a val to it, and set it into the database using name and scope as the lookup parameters.

> static function void set_anonymous(
> | input | string | scope, |  |
> |  | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

Create a new resource, write a val to it, and set it into the database.

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

locate a resource by name and scope and read its value.

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

Read a value by type.

> static function bit write_by_name(
> | input | string | scope, |  |
> | input | string | name, |  |
> | input | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

write a val into the resources database.

> static function bit write_by_type(
> | input | string | scope, |  |
> | input | T | val, |  |
> | input | uvm_object | accessor | = | null
> )

write a val into the resources database.

> static function void dump()

Dump all the resources in the resource pool.

> static function void turn_on_tracing()

Turn tracing on for the resource database.

> static function void turn_off_tracing()

Turn tracing off for the resource database.

> static function bit is_tracing()

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