Resources | |
uvm_resource_pool | The global (singleton) resource database. |
uvm_resource #(T) | Implementation of uvm_resource#(T) as defined in section C.2.5.1 of 1800.2-2017. |
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).
uvm_resource_pool | ||
The global (singleton) resource database. | ||
Class Declaration | ||
| ||
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. | |
delete | If rsrc exists within the pool, then it is removed from all internal maps. | |
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. |
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.
`ifdef UVM_ENABLE_DEPRECATED_API 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.
function void set_override( uvm_resource_base rsrc, string scope = "" )
The resource provided as an argument will be entered into the pool and will override both by name and type. Default value to ‘scope’ argument is violating 1800.2-2017 LRM, but it is added to make the routine backward compatible
function void set_name_override( uvm_resource_base rsrc, string scope = "" )
The resource provided as an argument will entered into the pool using normal precedence in the type map and will override the name. Default value to ‘scope’ argument is violating 1800.2-2017 LRM, but it is added to make the routine backward compatible
function void set_type_override( uvm_resource_base rsrc, string scope = "" )
The resource provided as an argument will be entered into the pool using normal precedence in the name map and will override the type. Default value to ‘scope’ argument is violating 1800.2-2017 LRM, but it is added to make the routine backward compatible
virtual function void delete ( uvm_resource_base rsrc )
If rsrc exists within the pool, then it is removed from all internal maps. If the rsrc is null, or does not exist within the pool, then the request is silently ignored.
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.
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.
static 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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
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. 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.
function void dump( bit audit = 0, uvm_printer printer = null )
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.
Implementation of uvm_resource#(T) as defined in section C.2.5.1 of 1800.2-2017.
uvm_resource #(T) | |||||||||||||||||
Implementation of uvm_resource#(T) as defined in section C.2.5.1 of 1800.2-2017. | |||||||||||||||||
Class Hierarchy | |||||||||||||||||
| |||||||||||||||||
Class Declaration | |||||||||||||||||
| |||||||||||||||||
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 | |||||||||||||||||
write | |||||||||||||||||
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. |
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.
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.
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.
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.
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.
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.
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 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.
function T read( uvm_object accessor = null )
function T read(uvm_object accessor = null);
This function is the implementation of the uvm_resource#(T)::read method detailed in IEEE1800.2-2017 section C.2.5.4.1
It calls uvm_resource_base::record_read_access before returning the value.
@uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
function void write( T t, uvm_object accessor = null )
function void write(T t, uvm_object accessor = null);
This function is the implementation of the uvm_resource#(T)::write method detailed in IEEE1800.2-2017 section C.2.5.4.2
It calls uvm_resource_base::record_write_access before writing the value.
@uvm-accellera The details of this API are specific to the Accellera implementation, and are not being considered for contribution to 1800.2
Functions for manipulating the search priority of resources. These implementations of the interface defined in the base class delegate to the resource pool.
Change the search priority of the resource based on the value of the priority enum argument, pri.
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.
The global (singleton) resource database.
class uvm_resource_pool
Implementation of uvm_resource#(T) as defined in section C.2.5.1 of 1800.2-2017.
class uvm_resource #( type T = int ) extends uvm_resource_base
Returns the singleton handle to the resource pool
static function uvm_resource_pool get()
Invokes the spell checker for a string s.
function bit spell_check( string s )
Add a new resource to the resource pool.
`ifdef UVM_ENABLE_DEPRECATED_API function void set ( uvm_resource_base rsrc, uvm_resource_types:: override_t override = 0 )
The resource provided as an argument will be entered into the pool and will override both by name and type.
function void set_override( uvm_resource_base rsrc, string scope = "" )
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_name_override( uvm_resource_base rsrc, string scope = "" )
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 void set_type_override( uvm_resource_base rsrc, string scope = "" )
If rsrc exists within the pool, then it is removed from all internal maps.
virtual function void delete ( uvm_resource_base rsrc )
Lookup resources by name.
function uvm_resource_types::rsrc_q_t lookup_name( string scope = "", string name, uvm_resource_base type_handle = null, bit rpterr = 1 )
Traverse a queue, q, of resources and return the one with the highest precedence.
static function uvm_resource_base get_highest_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.
static function void sort_by_precedence( ref uvm_resource_types:: rsrc_q_t q )
This is a utility function that answers the question: For a given scope, what resources are visible to it?
function uvm_resource_types::rsrc_q_t lookup_scope( string scope )
Lookup a resource by name, scope, and type_handle.
function uvm_resource_base get_by_name( string scope = "", string name, uvm_resource_base type_handle, bit rpterr = 1 )
Lookup resources by type.
function uvm_resource_types::rsrc_q_t lookup_type( string scope = "", uvm_resource_base type_handle )
Lookup a resource by type_handle and scope.
function uvm_resource_base get_by_type( string scope = "", uvm_resource_base type_handle )
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_names( string scope, string name, uvm_resource_base type_handle = null )
Looks for all the resources whose name matches the regular expression argument and whose scope matches the current scope.
function uvm_resource_types::rsrc_q_t lookup_regex( string re, scope )
Change the priority of the rsrc based on the value of pri, the priority enum argument.
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 search 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 )
Locate all the resources that have at least one write and no reads
function uvm_resource_types::rsrc_q_t find_unused_resources()
Print the resources that are in a single queue, rq.
function void print_resources( uvm_resource_types:: rsrc_q_t rq, bit audit = 0 )
dump the entire resource pool.
function void dump( bit audit = 0, uvm_printer printer = null )
The uvm_void class is the base class for all UVM classes.
virtual class uvm_void
The uvm_object class is the base class for all UVM data and hierarchical classes.
virtual class uvm_object extends uvm_void
Static function that returns the static type handle.
static function this_type get_type()
Returns the static type handle of this resource in a polymorphic fashion.
function uvm_resource_base get_type_handle()
Simply put this resource into the global resource pool
function void set()
Put a resource into the global resource pool as an override.
function void set_override(
looks up a resource by name in the name map.
static function this_type get_by_name( string scope, string name, bit rpterr = 1 )
looks up a resource by type_handle in the type map.
static function this_type get_by_type( string scope = "", uvm_resource_base type_handle )
function T read( uvm_object accessor = null )
function void write( T t, uvm_object accessor = null )
In a queue of resources, locate the first one with the highest precedence whose type is T.
static function this_type get_highest_precedence( ref uvm_resource_types:: rsrc_q_t q )