uvm_named_object

The uvm_named_object class is the root base class for UVM components.  In addition to the features inherited from <uvm_object> and <uvm_report_object>, uvm_named_object provides the following interfaces:

Hierarchyprovides methods for searching and traversing the component hierarchy.
Configurationprovides methods for configuring component topology and other parameters ahead of and during component construction.
Phasingdefines a phased test flow that all components follow.  Derived components implement one or more of the predefined phase callback methods to perform their function.  During simulation, all components’ callbacks are executed in precise order.  Phasing is controlled by uvm_top, the singleton instance of <uvm_root>.
Reportingprovides a convenience interface to the <uvm_report_handler>.  All messages, warnings, and errors are processed through this interface.
Transaction recordingprovides methods for recording the transactions produced or consumed by the component to a transaction database (vendor specific).
Factoryprovides a convenience interface to the <uvm_factory>.  The factory is used to create new components and other objects based on type-wide and instance-specific configuration.

The uvm_named_object is automatically seeded during construction using UVM seeding, if enabled.  All other objects must be manually reseeded, if appropriate.  See <uvm_object::reseed> for more information.

Summary
uvm_named_object
The uvm_named_object class is the root base class for UVM components.
Class Hierarchy
uvm_object
uvm_named_object
Class Declaration
virtual class uvm_named_object extends uvm_object
newCreates a new component with the given leaf instance name and handle to to its parent.
Debug Section
Hierarchy InterfaceThese methods provide user access to information about the component hierarchy, i.e., topology.
get_parentReturns a handle to this component’s parent, or null if it has no parent.
get_full_nameReturns the full hierarchical name of this object.
get_child
get_next_child
get_first_childThese methods are used to iterate through this component’s children, if any.
get_num_childrenReturns the number of this component’s children.
has_childReturns 1 if this component has a child with the given name, 0 otherwise.
set_nameRenames this component to name and recalculates all descendants’ full names.
lookupLooks for a component with the given hierarchical name relative to this component.
Factory InterfaceThe factory interface provides convenient access to a portion of UVM’s <uvm_factory> interface.
create_objectA convenience function for <uvm_factory::create_object_by_name>, this method calls upon the factory to create a new object whose type corresponds to the preregistered type name, requested_type_name, and instance name, name.
set_type_override_by_typeA convenience function for <uvm_factory::set_type_override_by_type>, this method registers a factory override for components and objects created at this level of hierarchy or below.
set_inst_override_by_typeA convenience function for <uvm_factory::set_inst_override_by_type>, this method registers a factory override for components and objects created at this level of hierarchy or below.
set_type_overrideA convenience function for <uvm_factory::set_type_override_by_name>, this method configures the factory to create an object of type override_type_name whenever the factory is asked to produce a type represented by original_type_name.
set_inst_overrideA convenience function for <uvm_factory::set_inst_override_by_type>, this method registers a factory override for components created at this level of hierarchy or below.
print_override_infoThis factory debug method performs the same lookup process as create_object and create_named_object, but instead of creating an object, it prints information about what type of object would be created given the provided arguments.
find_allReturns the component handle (find) or list of components handles (find_all) matching a given string.
remove_child()Remove the child named ‘name’ from ‘this’.
We don’t care if we don’t find it.1.

new

function new (string name = "",
uvm_named_object parent = null)

Creates a new component with the given leaf instance name and handle to to its parent.  If the component is a top-level component (i.e. it is created in a static module or interface), parent should be null.

The component will be inserted as a child of the parent object, if any.  If parent already has a child by the given name, an error is produced.

If parent is null, then the component will become a child of the implicit top-level component, uvm_top.

All classes derived from uvm_named_object must call super.new(name,parent).

Hierarchy Interface

These methods provide user access to information about the component hierarchy, i.e., topology.

get_parent

virtual function uvm_named_object get_parent ()

Returns a handle to this component’s parent, or null if it has no parent.

get_full_name

virtual function string get_full_name ()

Returns the full hierarchical name of this object.  The default implementation concatenates the hierarchical name of the parent, if any, with the leaf name of this object, as given by <uvm_object::get_name>.

get_child

function uvm_named_object get_child (string name)

get_next_child

function int get_next_child (ref string name)

get_first_child

function int get_first_child (ref string name)

These methods are used to iterate through this component’s children, if any.  For example, given a component with an object handle, comp, the following code calls <uvm_object::print> for each child:

string name;
uvm_named_object child;
if (comp.get_first_child(name))
  do begin
    child = comp.get_child(name);
    child.print();
  end while (comp.get_next_child(name));

get_num_children

function int get_num_children ()

Returns the number of this component’s children.

has_child

function int has_child (string name)

Returns 1 if this component has a child with the given name, 0 otherwise.

set_name

virtual function void set_name (string name)

Renames this component to name and recalculates all descendants’ full names.

lookup

function uvm_named_object lookup (string name)

Looks for a component with the given hierarchical name relative to this component.  If the given name is preceded with a ‘.’  (dot), then the search begins relative to the top level (absolute lookup).  The handle of the matching component is returned, else null.  The name must not contain wildcards.

Factory Interface

The factory interface provides convenient access to a portion of UVM’s <uvm_factory> interface.  For creating new objects and components, the preferred method of accessing the factory is via the object or component wrapper (see <uvm_named_object_registry #(T,Tname)> and <uvm_object_registry #(T,Tname)>).  The wrapper also provides functions for setting type and instance overrides.

create_object

function uvm_object create_object (string requested_type_name,  
string name = "")

A convenience function for <uvm_factory::create_object_by_name>, this method calls upon the factory to create a new object whose type corresponds to the preregistered type name, requested_type_name, and instance name, name.  This method is equivalent to:

factory.create_object_by_name(requested_type_name,
                              get_full_name(), name);

If the factory determines that a type or instance override exists, the type of the object created may be different than the requested type.  See <uvm_factory> for details on factory operation.

set_type_override_by_type

static function void set_type_override_by_type (
   uvm_object_wrapper original_type,  
   uvm_object_wrapper override_type,  
   bit replace = 1
)

A convenience function for <uvm_factory::set_type_override_by_type>, this method registers a factory override for components and objects created at this level of hierarchy or below.  This method is equivalent to:

factory.set_type_override_by_type(original_type, override_type,replace);

The relative_inst_path is relative to this component and may include wildcards.  The original_type represents the type that is being overridden.  In subsequent calls to <uvm_factory::create_object_by_type> or <uvm_factory::create_named_object_by_type>, if the requested_type matches the original_type and the instance paths match, the factory will produce the override_type.

The original and override type arguments are lightweight proxies to the types they represent.  See set_inst_override_by_type for information on usage.

set_inst_override_by_type

A convenience function for <uvm_factory::set_inst_override_by_type>, this method registers a factory override for components and objects created at this level of hierarchy or below.  In typical usage, this method is equivalent to:

factory.set_inst_override_by_type({get_full_name(),".",
                                   relative_inst_path},
                                   original_type,
                                   override_type);

The relative_inst_path is relative to this component and may include wildcards.  The original_type represents the type that is being overridden.  In subsequent calls to <uvm_factory::ereate_object_by_type> or

set_type_override

static function void set_type_override(string original_type_name,  
string override_type_name,  
bit replace = 1)

A convenience function for <uvm_factory::set_type_override_by_name>, this method configures the factory to create an object of type override_type_name whenever the factory is asked to produce a type represented by original_type_name.  This method is equivalent to:

factory.set_type_override_by_name(original_type_name,
                                  override_type_name, replace);

The original_type_name typically refers to a preregistered type in the factory.  It may, however, be any arbitrary string.  Subsequent calls to create_named_object or create_object with the same string and matching instance path will produce the type represented by override_type_name.  The override_type_name must refer to a preregistered type in the factory.

set_inst_override

function void set_inst_override(string relative_inst_path,
string original_type_name,
string override_type_name)

A convenience function for <uvm_factory::set_inst_override_by_type>, this method registers a factory override for components created at this level of hierarchy or below.  In typical usage, this method is equivalent to:

factory.set_inst_override_by_name({get_full_name(),".",
                                   relative_inst_path},
                                    original_type_name,
                                   override_type_name);

The relative_inst_path is relative to this component and may include wildcards.  The original_type_name typically refers to a preregistered type in the factory.  It may, however, be any arbitrary string.  Subsequent calls to create_named_object or create_object with the same string and matching instance path will produce the type represented by override_type_name.  The override_type_name must refer to a preregistered type in the factory.

print_override_info

function void print_override_info(string requested_type_name,  
string name = "")

This factory debug method performs the same lookup process as create_object and create_named_object, but instead of creating an object, it prints information about what type of object would be created given the provided arguments.

find_all

function void find_all(string comp_match,  
ref uvm_named_object comps[$],  
input uvm_named_object comp = null)

Returns the component handle (find) or list of components handles (find_all) matching a given string.  The string may contain the wildcards,

  • and ?.  Strings beginning with ‘.’ are absolute path names.  If optional comp arg is provided, then search begins from that component down (default=all components).

remove_child()

function void uvm_named_object::remove_child(string name,
uvm_named_object old_child)

Remove the child named ‘name’ from ‘this’.  This function cleans up the child management arrays in THIS object.

We don’t care if we don’t find it.

If we don’t find the name, then that means

1.  Sloppy bookkeeping, or 2.  We just changed the name, and things aren’t quite right yet.  We called this function as a way to try to get things straightened out.  Not to cause more problems.

virtual class uvm_named_object extends uvm_object
The uvm_named_object class is the root base class for UVM components.
function new (string name = "",
uvm_named_object parent = null)
Creates a new component with the given leaf instance name and handle to to its parent.
virtual function uvm_named_object get_parent ()
Returns a handle to this component’s parent, or null if it has no parent.
virtual function string get_full_name ()
Returns the full hierarchical name of this object.
function uvm_named_object get_child (string name)
function int get_next_child (ref string name)
function int get_first_child (ref string name)
These methods are used to iterate through this component’s children, if any.
function int get_num_children ()
Returns the number of this component’s children.
function int has_child (string name)
Returns 1 if this component has a child with the given name, 0 otherwise.
virtual function void set_name (string name)
Renames this component to name and recalculates all descendants’ full names.
function uvm_named_object lookup (string name)
Looks for a component with the given hierarchical name relative to this component.
function uvm_object create_object (string requested_type_name,  
string name = "")
A convenience function for uvm_factory::create_object_by_name, this method calls upon the factory to create a new object whose type corresponds to the preregistered type name, requested_type_name, and instance name, name.
static function void set_type_override_by_type (
   uvm_object_wrapper original_type,  
   uvm_object_wrapper override_type,  
   bit replace = 1
)
A convenience function for uvm_factory::set_type_override_by_type, this method registers a factory override for components and objects created at this level of hierarchy or below.
static function void set_type_override(string original_type_name,  
string override_type_name,  
bit replace = 1)
A convenience function for uvm_factory::set_type_override_by_name, this method configures the factory to create an object of type override_type_name whenever the factory is asked to produce a type represented by original_type_name.
function void set_inst_override(string relative_inst_path,
string original_type_name,
string override_type_name)
A convenience function for uvm_factory::set_inst_override_by_type, this method registers a factory override for components created at this level of hierarchy or below.
function void print_override_info(string requested_type_name,  
string name = "")
This factory debug method performs the same lookup process as create_object and create_named_object, but instead of creating an object, it prints information about what type of object would be created given the provided arguments.
function void find_all(string comp_match,  
ref uvm_named_object comps[$],  
input uvm_named_object comp = null)
Returns the component handle (find) or list of components handles (find_all) matching a given string.
function void uvm_named_object::remove_child(string name,
uvm_named_object old_child)
Remove the child named ‘name’ from ‘this’.
A convenience function for uvm_factory::set_inst_override_by_type, this method registers a factory override for components and objects created at this level of hierarchy or below.