[source]

Class uvm_resource_pool

uvm_pkg::uvm_resource_pool + get_record[$] : get_t + rtab[string] : uvm_resource_types::rsrc_q_t + ttab[uvm_resource_base] : uvm_resource_types::rsrc_q_t + dump(): void + dump_get_records(): void + find_unused_resources(): uvm_resource_types::rsrc_q_t + get(): uvm_resource_pool + get_by_name(): uvm_resource_base + get_by_type(): uvm_resource_base + get_highest_precedence(): uvm_resource_base + lookup_name(): uvm_resource_types::rsrc_q_t + lookup_regex(): uvm_resource_types::rsrc_q_t + lookup_regex_names(): uvm_resource_types::rsrc_q_t + lookup_scope(): uvm_resource_types::rsrc_q_t + lookup_type(): uvm_resource_types::rsrc_q_t + print_resources(): void + push_get_record(): void + set(): void + set_name_override(): void + set_override(): void + set_priority(): void + set_priority_name(): void + set_priority_type(): void + set_type_override(): void + sort_by_precedence(): void + spell_check(): bit

Inheritance Diagram of 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).

Variables

Name

Type

Description

rtab

uvm_resource_types::rsrc_q_t

ttab

uvm_resource_types::rsrc_q_t

get_record

get_t

history of gets

Functions

static function uvm_resource_pool get ( ) [source]

Returns the singleton handle to the resource pool

function bit spell_check ( string s ) [source]

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

function void set ( uvm_resource_base rsrc, uvm_resource_types::override_t override ) [source]

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 ) [source]

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 ) [source]

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 ) [source]

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 push_get_record ( string name, string scope, uvm_resource_base rsrc ) [source]

function

push_get_record

Insert a new record into the get history list.

function void dump_get_records ( ) [source]

function

dump_get_records

Format and print the get history list.

function uvm_resource_types::rsrc_q_t lookup_name ( string scope, string name, uvm_resource_base type_handle, bit rpterr ) [source]

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 .

function uvm_resource_base get_highest_precedence ( uvm_resource_types::rsrc_q_t q ) [source]

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 ( uvm_resource_types::rsrc_q_t q ) [source]

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 ) [source]

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 ) [source]

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 ) [source]

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 ) [source]

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, string scope ) [source]

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 ) [source]

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.

function void set_priority_type ( uvm_resource_base rsrc, uvm_resource_types::priority_e pri ) [source]

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 ) [source]

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 ) [source]

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 ( ) [source]

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 ) [source]

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 ) [source]

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.