# Resources

Contents

Resources |
Intro | A resource is a parameterized container that holds arbitrary data.
uvm_resource_types | Provides typedefs and enums used throughout the resources facility.
uvm_resource_options | Provides a namespace for managing options for the resources facility.
uvm_resource_base | Non-parameterized base class for resources.
uvm_resource_pool | The global (singleton) resource database.
uvm_resource #(T) | Parameterized resource.

### 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_auditing | Turn auditing on for the resource database.
turn_off_auditing | Turn auditing off for the resource database.
is_auditing | Returns 1 if the auditing facility is on and 0 if it is off.

### Methods

### 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_void
uvm_object
uvm_resource_base
Class Declaration
> virtual class uvm_resource_base extends uvm_object
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.
default_precedence | The default precedence for an resource that has been created.
new | constructor for uvm_resource_base.
get_type_handle | Pure virtual function that returns the type handle of the resource container.
Read-only Interface |
set_read_only | Establishes this resource as a read-only resource.
is_read_only | Returns one if this resource has been set to read-only, zero otherwise
Notification |
wait_modified | This task blocks until the resource has been modified -- that is, a uvm_resource#(T)::write operation has been performed.
Scope Interface | Each resource has a name, a value and a set of scopes over which it is visible.
set_scope | Set the value of the regular expression that identifies the set of scopes over which this resource is visible.
get_scope | Retrieve the regular expression string that identifies the set of scopes over which this resource is visible.
match_scope | Using the regular expression facility, determine if this resource is visible in a scope.
Priority | Functions for manipulating the search priority of resources.
set priority | Change the search priority of the resource based on the value of the priority enum argument.
Utility Functions |
do_print | Implementation of do_print which is called by print().
Audit Trail | To find out what is happening as the simulation proceeds, an audit trail of each read and write is kept.
record_read_access |
record_write_access |
print_accessors | Dump the access records for this resource
init_access_record | Initialize 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

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

### Read-only Interface

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

### is_read_only

> function bit is_read_only()

Returns one if this resource has been set to read-only, zero otherwise

### Notification

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

### Scope Interface

Each resource has a name, a value and a set of scopes over which it is visible. A scope is a hierarchical entity or a context. A scope name is a multi-element string that identifies a scope. Each element refers to a scope context and the elements are separated by dots (.).

>     top.env.agent.monitor

Consider the example above of a scope name. It consists of four elements: “top”, “env”, “agent”, and “monitor”. The elements are strung together with a dot separating each element. top.env.agent is the parent of top.env.agent.monitor, top.env is the parent of top.env.agent, and so on. A set of scopes can be represented by a set of scope name strings. A very straightforward way to represent a set of strings is to use regular expressions. A regular expression is a special string that contains placeholders which can be substituted in various ways to generate or recognize a particular set of strings. Here are a few simple examples:

>      top\..*                   all of the scopes whose top-level component
>                             is top
>     top\.env\..*\.monitor  all of the scopes in env that end in monitor;
>                             i.e. all the monitors two levels down from env
>     .*\.monitor                all of the scopes that end in monitor; i.e.
>                             all the monitors (assuming a naming convention
>                             was used where all monitors are named "monitor")
>     top\.u[1-5]\.*         all of the scopes rooted and named u1, u2, u3,

u4, or u5, and any of their subscopes.

The examples above use POSIX regular expression notation. This is a very general and expressive notation. It is not always the case that so much expressiveness is required. Sometimes an expression syntax that is easy to read and easy to write is useful, even if the syntax is not as expressive as the full power of POSIX regular expressions. A popular substitute for regular expressions is globs. A glob is a simplified regular expression. It only has three metacharacters -- *, +, and ?. Character ranges are not allowed and dots are not a metacharacter in globs as they are in regular expressions. The following table shows glob metacharacters.

>     char meaning                 regular expression
>                                   equivalent
>     *        0 or more characters    .*
>     +        1 or more characters    .+
>     ?        exactly one character   .

Of the examples above, the first three can easily be translated into globs. The last one cannot. It relies on notation that is not available in glob syntax.

>     regular expression     glob equivalent
>     ---------------------      ------------------
>     top\..*                top.*
>     top\.env\..*\.monitor      top.env.*.monitor
>     .*\.monitor                *.monitor

The resource facility supports both regular expression and glob syntax. Regular expressions are identified as such when they surrounded by ‘/’ characters. For example, /^top\.*/ is interpreted as the regular expression ^top\.*, where the surrounding ‘/’ characters have been removed. All other expressions are treated as glob expressions. They are converted from glob notation to regular expression notation internally. Regular expression compilation and matching as well as glob-to-regular expression conversion are handled by two DPI functions:

>     function int uvm_re_match(string re, string str);
>     function string uvm_glob_to_re(string glob);

uvm_re_match both compiles and matches the regular expression. All of the matching is done using regular expressions, so globs are converted to regular expressions and then processed.

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

### Utility Functions

### do_print

> function void do_print (
> | uvm_printer | printer
> )

Implementation of do_print which is called by print().

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

> function void record_write_access(
> | uvm_object | accessor | = | null
> )

### print_accessors

> virtual function void print_accessors()

Dump the access records for this resource

### init_access_record

> function void init_access_record (
> | inout uvm_resource_types:: | access_t | access_record
> )

Initialize a new access record

## uvm_resource_pool

The global (singleton) resource database.

Each resource is stored both by primary name and by type handle. The resource pool contains two associative arrays, one with name as the key and one with the type handle as the key. Each associative array contains a queue of resources. Each resource has a regular expression that represents the set of scopes over which it is visible.

>     +------+------------+                          +------------+------+
>     | name | rsrc queue |                          | rsrc queue | type |
>     +------+------------+                          +------------+------+
>     |      |            |                          |            |      |
>     +------+------------+                  +-+-+   +------------+------+
>     |      |            |                  | | |<--+---*        |  T   |
>     +------+------------+   +-+-+          +-+-+   +------------+------+
>     |  A   |        *---+-->| | |           |      |            |      |
>     +------+------------+   +-+-+           |      +------------+------+
>     |      |            |      |            |      |            |      |
>     +------+------------+      +-------+  +-+      +------------+------+
>     |      |            |              |  |        |            |      |
>     +------+------------+              |  |        +------------+------+
>     |      |            |              V  V        |            |      |
>     +------+------------+            +------+      +------------+------+
>     |      |            |            | rsrc |      |            |      |
>     +------+------------+            +------+      +------------+------+

The above diagrams illustrates how a resource whose name is A and type is T is stored in the pool. The pool contains an entry in the type map for type T and an entry in the name map for name A. The queues in each of the arrays each contain an entry for the resource A whose type is T. The name map can contain in its queue other resources whose name is A which may or may not have the same type as our resource A. Similarly, the type map can contain in its queue other resources whose type is T and whose name may or may not be A.

Resources are added to the pool by calling set; they are retrieved from the pool by calling get_by_name or get_by_type. When an object creates a new resource and calls set the resource is made available to be retrieved by other objects outside of itself; an object gets a resource when it wants to access a resource not currently available in its scope.

The scope is stored in the resource itself (not in the pool) so whether you get by name or by type the resource’s visibility is the same.

As an auditing capability, the pool contains a history of gets. A record of each get, whether by get_by_type or get_by_name, is stored in the audit record. Both successful and failed gets are recorded. At the end of simulation, or any time for that matter, you can dump the history list. This will tell which resources were successfully located and which were not. You can use this information to determine if there is some error in name, type, or scope that has caused a resource to not be located or to be incorrectly located (i.e. the wrong resource is located).

Summary

uvm_resource_pool
The global (singleton) resource database.
Class Declaration
> class uvm_resource_pool
get | Returns the singleton handle to the resource pool
spell_check | Invokes the spell checker for a string s.
Set |
set | Add a new resource to the resource pool.
set_override | The resource provided as an argument will be entered into the pool and will override both by name and type.
set_name_override | The resource provided as an argument will entered into the pool using normal precedence in the type map and will override the name.
set_type_override | The resource provided as an argument will be entered into the pool using normal precedence in the name map and will override the type.
Lookup | This group of functions is for finding resources in the resource database.
lookup_name | Lookup resources by name.
get_highest_precedence | Traverse a queue, q, of resources and return the one with the highest precedence.
sort_by_precedence | Given a list of resources, obtained for example from lookup_scope, sort the resources in precedence order.
get_by_name | Lookup a resource by name, scope, and type_handle.
lookup_type | Lookup resources by type.
get_by_type | Lookup a resource by type_handle and scope.
lookup_regex_names | This utility function answers the question, for a given name, scope, and type_handle, what are all of the resources with requested name, a matching scope (where the resource scope may be a regular expression), and a matching type?
lookup_regex | Looks for all the resources whose name matches the regular expression argument and whose scope matches the current scope.
lookup_scope | This is a utility function that answers the question: For a given scope, what resources are visible to it?
Set Priority | Functions for altering the search priority of resources.
set_priority_type | Change the priority of the rsrc based on the value of pri, the priority enum argument.
set_priority_name | Change the priority of the rsrc based on the value of pri, the priority enum argument.
set_priority | Change the search priority of the rsrc based on the value of pri, the priority enum argument.
Debug |
find_unused_resources | Locate all the resources that have at least one write and no reads
print_resources | Print the resources that are in a single queue, rq.
dump | dump the entire resource pool.

### get

> static function uvm_resource_pool get()

Returns the singleton handle to the resource pool

### spell_check

> function bit spell_check(
> | string | s
> )

Invokes the spell checker for a string s. The universe of correctly spelled strings -- i.e. the dictionary -- is the name map.

### Set

> function void set (
> |  | uvm_resource_base | rsrc, |  |
> | uvm_resource_types:: | override_t | override | = | 0
> )

Add a new resource to the resource pool. The resource is inserted into both the name map and type map so it can be located by either.

An object creates a resources and sets it into the resource pool. Later, other objects that want to access the resource must get it from the pool

Overrides can be specified using this interface. Either a name override, a type override or both can be specified. If an override is specified then the resource is entered at the front of the queue instead of at the back. It is not recommended that users specify the override parameter directly, rather they use the set_override, set_name_override, or set_type_override functions.

### set_override

> function void set_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will be entered into the pool and will override both by name and type.

### set_name_override

> function void set_name_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will entered into the pool using normal precedence in the type map and will override the name.

### set_type_override

> function void set_type_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will be entered into the pool using normal precedence in the name map and will override the type.

### Lookup

This group of functions is for finding resources in the resource database.

lookup_name and lookup_type locate the set of resources that matches the name or type (respectively) and is visible in the current scope. These functions return a queue of resources.

get_highest_precedence traverse a queue of resources and returns the one with the highest precedence -- i.e. the one whose precedence member has the highest value.

get_by_name and get_by_type use lookup_name and lookup_type (respectively) and get_highest_precedence to find the resource with the highest priority that matches the other search criteria.

### lookup_name

> function uvm_resource_types::rsrc_q_t lookup_name(
> | string | scope | = | "",
> | string | name, |  |
> | uvm_resource_base | type_handle | = | null,
> | bit | rpterr | = | 1
> )

Lookup resources by name. Returns a queue of resources that match the name, scope, and type_handle. If no resources match the queue is returned empty. If rpterr is set then a warning is issued if no matches are found, and the spell checker is invoked on name. If type_handle is null then a type check is not made and resources are returned that match only name and scope.

### get_highest_precedence

> function uvm_resource_base get_highest_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

Traverse a queue, q, of resources and return the one with the highest precedence. In the case where there exists more than one resource with the highest precedence value, the first one that has that precedence will be the one that is returned.

### sort_by_precedence

> static function void sort_by_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

Given a list of resources, obtained for example from lookup_scope, sort the resources in precedence order. The highest precedence resource will be first in the list and the lowest precedence will be last. Resources that have the same precedence and the same name will be ordered by most recently set first.

### get_by_name

> function uvm_resource_base get_by_name(
> | string | scope | = | "",
> | string | name, |  |
> | uvm_resource_base | type_handle, |  |
> | bit | rpterr | = | 1
> )

Lookup a resource by name, scope, and type_handle. Whether the get succeeds or fails, save a record of the get attempt. The rpterr flag indicates whether to report errors or not. Essentially, it serves as a verbose flag. If set then the spell checker will be invoked and warnings about multiple resources will be produced.

### lookup_type

> function uvm_resource_types::rsrc_q_t lookup_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

Lookup resources by type. Return a queue of resources that match the type_handle and scope. If no resources match then the returned queue is empty.

### get_by_type

> function uvm_resource_base get_by_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

Lookup a resource by type_handle and scope. Insert a record into the get history list whether or not the get succeeded.

### lookup_regex_names

> function uvm_resource_types::rsrc_q_t lookup_regex_names(
> | string | scope, |  |
> | string | name, |  |
> | uvm_resource_base | type_handle | = | null
> )

This utility function answers the question, for a given name, scope, and type_handle, what are all of the resources with requested name, a matching scope (where the resource scope may be a regular expression), and a matching type? name and scope are explicit values.

### lookup_regex

> function uvm_resource_types::rsrc_q_t lookup_regex(
> | string | re,
> |  | scope
> )

Looks for all the resources whose name matches the regular expression argument and whose scope matches the current scope.

### lookup_scope

> function uvm_resource_types::rsrc_q_t lookup_scope(
> | string | scope
> )

This is a utility function that answers the question: For a given scope, what resources are visible to it? Locate all the resources that are visible to a particular scope. This operation could be quite expensive, as it has to traverse all of the resources in the database.

### Set Priority

Functions for altering the search priority of resources. Resources are stored in queues in the type and name maps. When retrieving resources, either by type or by name, the resource queue is search from front to back. The first one that matches the search criteria is the one that is returned. The set_priority functions let you change the order in which resources are searched. For any particular resource, you can set its priority to UVM_HIGH, in which case the resource is moved to the front of the queue, or to UVM_LOW in which case the resource is moved to the back of the queue.

### set_priority_type

> function void set_priority_type(
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the priority of the rsrc based on the value of pri, the priority enum argument. This function changes the priority only in the type map, leaving the name map untouched.

### set_priority_name

> function void set_priority_name(
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the priority of the rsrc based on the value of pri, the priority enum argument. This function changes the priority only in the name map, leaving the type map untouched.

### set_priority

> function void set_priority (
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the search priority of the rsrc based on the value of pri, the priority enum argument. This function changes the priority in both the name and type maps.

### Debug

### find_unused_resources

> function uvm_resource_types::rsrc_q_t find_unused_resources()

Locate all the resources that have at least one write and no reads

### print_resources

> function void print_resources(
> | uvm_resource_types:: | rsrc_q_t | rq, |  |
> |  | bit | audit | = | 0
> )

Print the resources that are in a single queue, rq. This is a utility function that can be used to print any collection of resources stored in a queue. The audit flag determines whether or not the audit trail is printed for each resource along with the name, value, and scope regular expression.

### dump

> function void dump(
> | bit | audit | = | 0
> )

dump the entire resource pool. The resource pool is traversed and each resource is printed. The utility function print_resources() is used to initiate the printing. If the audit bit is set then the audit trail is dumped for each resource.

## uvm_resource #(T)

Parameterized resource. Provides essential access methods to read from and write to the resource database.

Summary

uvm_resource #(T)
Parameterized resource.
Class Hierarchy
uvm_void
uvm_object
uvm_resource_base
uvm_resource#(T)
Class Declaration
> class uvm_resource #(
> | type | T | = | int
> ) extends uvm_resource_base
Type Interface | Resources can be identified by type using a static type handle.
get_type | Static function that returns the static type handle.
get_type_handle | Returns the static type handle of this resource in a polymorphic fashion.
Set/ Get Interface | uvm_resource#(T) provides an interface for setting and getting a resources.
set | Simply put this resource into the global resource pool
set_override | Put a resource into the global resource pool as an override.
get_by_name | looks up a resource by name in the name map.
get_by_type | looks up a resource by type_handle in the type map.
Read/ Write Interface | read and write provide a type-safe interface for getting and setting the object in the resource container.
read | Return the object stored in the resource container.
write | Modify the object stored in this resource container.
Priority | Functions for manipulating the search priority of resources.
set priority | Change the search priority of the resource based on the value of the priority enum argument, pri.
get_highest_precedence | In a queue of resources, locate the first one with the highest precedence whose type is T.

### Type Interface

Resources can be identified by type using a static type handle. The parent class provides the virtual function interface get_type_handle. Here we implement it by returning the static type handle.

### get_type

> static function this_type get_type()

Static function that returns the static type handle. The return type is this_type, which is the type of the parameterized class.

### get_type_handle

> function uvm_resource_base get_type_handle()

Returns the static type handle of this resource in a polymorphic fashion. The return type of get_type_handle() is uvm_resource_base. This function is not static and therefore can only be used by instances of a parameterized resource.

### Set/ Get Interface

uvm_resource#(T) provides an interface for setting and getting a resources. Specifically, a resource can insert itself into the resource pool. It doesn’t make sense for a resource to get itself, since you can’t call a function on a handle you don’t have. However, a static get interface is provided as a convenience. This obviates the need for the user to get a handle to the global resource pool as this is done for him here.

### set

> function void set()

Simply put this resource into the global resource pool

### set_override

> function void set_override(

Put a resource into the global resource pool as an override. This means it gets put at the head of the list and is searched before other existing resources that occupy the same position in the name map or the type map. The default is to override both the name and type maps. However, using the override argument you can specify that either the name map or type map is overridden.

### get_by_name

> static function this_type get_by_name(
> | string | scope, |  |
> | string | name, |  |
> | bit | rpterr | = | 1
> )

looks up a resource by name in the name map. The first resource with the specified name, whose type is the current type, and is visible in the specified scope is returned, if one exists. The rpterr flag indicates whether or not an error should be reported if the search fails. If rpterr is set to one then a failure message is issued, including suggested spelling alternatives, based on resource names that exist in the database, gathered by the spell checker.

### get_by_type

> static function this_type get_by_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

looks up a resource by type_handle in the type map. The first resource with the specified type_handle that is visible in the specified scope is returned, if one exists. If there is no resource matching the specifications, null is returned.

### Read/ Write Interface

read and write provide a type-safe interface for getting and setting the object in the resource container. The interface is type safe because the value argument for write and the return value of read are T, the type supplied in the class parameter. If either of these functions is used in an incorrect type context the compiler will complain.

### read

> function T read(
> | uvm_object | accessor | = | null
> )

Return the object stored in the resource container. If an accessor object is supplied then also update the accessor record for this resource.

### write

> function void write(
> | T | t, |  |
> | uvm_object | accessor | = | null
> )

Modify the object stored in this resource container. If the resource is read-only then issue an error message and return without modifying the object in the container. If the resource is not read-only and an accessor object has been supplied then also update the accessor record. Lastly, replace the object value in the container with the value supplied as the argument, t, and release any processes blocked on uvm_resource_base::wait_modified. If the value to be written is the same as the value already present in the resource then the write is not done. That also means that the accessor record is not updated and the modified bit is not set.

### Priority

Functions for manipulating the search priority of resources. These implementations of the interface defined in the base class delegate to the resource pool.

### set priority

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

### get_highest_precedence

> static function this_type get_highest_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

In a queue of resources, locate the first one with the highest precedence whose type is T. This function is static so that it can be called from anywhere.

> class uvm_resource_types

Provides typedefs and enums used throughout the resources facility.

> virtual class uvm_resource_base extends uvm_object

Non-parameterized base class for resources.

> class uvm_resource_pool

The global (singleton) resource database.

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

Parameterized resource.
Provides a namespace for managing options for the resources facility.

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

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

> function bit is_read_only()

Returns one if this resource has been set to read-only, zero otherwise

> 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 | t, |  |
> | uvm_object | accessor | = | null
> )

Modify the object stored in this resource container.

> 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 do_print (
> | uvm_printer | printer
> )

Implementation of do_print which is called by print().

> function void record_read_access(
> | uvm_object | accessor | = | null
> )

> function void record_write_access(
> | uvm_object | accessor | = | null
> )

> virtual function void print_accessors()

Dump the access records for this resource

> function void init_access_record (
> | inout uvm_resource_types:: | access_t | access_record
> )

Initialize a new access record

> function T read(
> | uvm_object | accessor | = | null
> )

Return the object stored in the resource container.

> static function uvm_resource_pool get()

Returns the singleton handle to the resource pool

> function bit spell_check(
> | string | s
> )

Invokes the spell checker for a string s.

> function void set (
> |  | uvm_resource_base | rsrc, |  |
> | uvm_resource_types:: | override_t | override | = | 0
> )

Add a new resource to the resource pool.

> function void set_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will be entered into the pool and will override both by name and type.

> function void set_name_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will entered into the pool using normal precedence in the type map and will override the name.

> function void set_type_override(
> | uvm_resource_base | rsrc
> )

The resource provided as an argument will be entered into the pool using normal precedence in the name map and will override the type.

> function uvm_resource_types::rsrc_q_t lookup_name(
> | string | scope | = | "",
> | string | name, |  |
> | uvm_resource_base | type_handle | = | null,
> | bit | rpterr | = | 1
> )

Lookup resources by name.

> function uvm_resource_base get_highest_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

Traverse a queue, q, of resources and return the one with the highest precedence.

> static function void sort_by_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

Given a list of resources, obtained for example from lookup_scope, sort the resources in precedence order.

> function uvm_resource_types::rsrc_q_t lookup_scope(
> | string | scope
> )

This is a utility function that answers the question: For a given scope, what resources are visible to it?

> function uvm_resource_base get_by_name(
> | string | scope | = | "",
> | string | name, |  |
> | uvm_resource_base | type_handle, |  |
> | bit | rpterr | = | 1
> )

Lookup a resource by name, scope, and type_handle.

> function uvm_resource_types::rsrc_q_t lookup_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

Lookup resources by type.

> function uvm_resource_base get_by_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

Lookup a resource by type_handle and scope.

> function uvm_resource_types::rsrc_q_t lookup_regex_names(
> | string | scope, |  |
> | string | name, |  |
> | uvm_resource_base | type_handle | = | null
> )

This utility function answers the question, for a given name, scope, and type_handle, what are all of the resources with requested name, a matching scope (where the resource scope may be a regular expression), and a matching type?

> function uvm_resource_types::rsrc_q_t lookup_regex(
> | string | re,
> |  | scope
> )

Looks for all the resources whose name matches the regular expression argument and whose scope matches the current scope.

> function void set_priority_type(
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the priority of the rsrc based on the value of pri, the priority enum argument.

> function void set_priority_name(
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the priority of the rsrc based on the value of pri, the priority enum argument.

> function void set_priority (
> |  | uvm_resource_base | rsrc,
> | uvm_resource_types:: | priority_e | pri
> )

Change the search priority of the rsrc based on the value of pri, the priority enum argument.

> function uvm_resource_types::rsrc_q_t find_unused_resources()

Locate all the resources that have at least one write and no reads

> function void print_resources(
> | uvm_resource_types:: | rsrc_q_t | rq, |  |
> |  | bit | audit | = | 0
> )

Print the resources that are in a single queue, rq.

> function void dump(
> | bit | audit | = | 0
> )

dump the entire resource pool.

> static function this_type get_type()

Static function that returns the static type handle.

> function uvm_resource_base get_type_handle()

Returns the static type handle of this resource in a polymorphic fashion.

> function void set()

Simply put this resource into the global resource pool

> function void set_override(

Put a resource into the global resource pool as an override.

> static function this_type get_by_name(
> | string | scope, |  |
> | string | name, |  |
> | bit | rpterr | = | 1
> )

looks up a resource by name in the name map.

> static function this_type get_by_type(
> | string | scope | = | "",
> | uvm_resource_base | type_handle |  |
> )

looks up a resource by type_handle in the type map.

> static function this_type get_highest_precedence(
> | ref uvm_resource_types:: | rsrc_q_t | q
> )

In a queue of resources, locate the first one with the highest precedence whose type is T.