Links¶
File: UVM Links
The <UVMLinkBase> class, and its extensions, are provided as a mechanism to allow for compile-time safety when trying to establish links between records within a <uvm_tr_database>.
- class uvm.base.uvm_links.UVMLinkBase(name='unnamed-UVMLinkBase')[source]¶
Bases:
UVMObject
CLASS: UVMLinkBase
The ~UVMLinkBase~ class presents a simple API for defining a link between any two objects.
Using extensions of self class, a <uvm_tr_database> can determine the type of links being passed, without relying on “magic” string names.
For example:
def do_establish_link(self, link): pc_link: UVMParentChildLink = None ce_link: UVMCauseEffectLink = None if (sv.cast(pc_link, link)): # Record the parent-child relationship elif (sv.cast(ce_link, link)): # Record the cause-effect relationship else: # Unsupported relationship!
- set_lhs(lhs: UVMObject)[source]¶
Group: Accessors
Function: set_lhs Sets the left-hand-side of the link
Triggers the
do_set_lhs
callback.- Parameters
lhs –
- get_lhs() UVMObject [source]¶
Function: get_lhs Gets the left-hand-side of the link
Triggers the
do_get_lhs
callbackReturns:
- set_rhs(rhs: UVMObject) None [source]¶
Function: set_rhs Sets the right-hand-side of the link
Triggers the
do_set_rhs
callback.- Parameters
rhs –
- get_rhs() UVMObject [source]¶
Function: get_rhs Gets the right-hand-side of the link
Triggers the
do_get_rhs
callbackReturns:
- set(lhs: UVMObject, rhs: UVMObject) None [source]¶
Function: set Convenience method for setting both sides in one call.
Triggers both the
do_set_rhs
anddo_set_lhs
callbacks.- Parameters
lhs –
rhs –
- class uvm.base.uvm_links.UVMParentChildLink(name='unnamed-UVMParentChildLink')[source]¶
Bases:
UVMLinkBase
CLASS: UVMParentChildLink
The ~UVMParentChildLink~ is used to represent a Parent/Child relationship between two objects.
- classmethod get_link(lhs: UVMObject, rhs: UVMObject, name='pc_link') UVMParentChildLink [source]¶
Function: get_link Constructs a pre-filled link
This allows for simple one-line link creations.
| my_db.establish_link(UVMParentChildLink::get_link(record1, record2)) Parameters: lhs - Left hand side reference rhs - Right hand side reference name - Optional name for the link object
- Parameters
cls –
lhs –
rhs –
name –
Returns:
- do_set_lhs(lhs)[source]¶
Group: Implementation Callbacks
Function: do_set_lhs Sets the left-hand-side (Parent)
- Parameters
lhs –
- create(name='')¶
Group: Creation
The
create
method allocates a new object of the same type as this object and returns it via a base uvm_object handle. Every class deriving from uvm_object, directly or indirectly, must implement the create method.A typical implementation is as follows:
class mytype (UVMObject): ... def create(self, name=""): mytype t = mytype(name) return t
- Parameters
name (str) – Name of the created object.
- Returns
New object.
- Return type
obj
- get_object_type()¶
Function: get_object_type
Returns the type-proxy (wrapper) for this object. The uvm_factory’s type-based override and creation methods take arguments of
uvm_object_wrapper
. This method, if implemented, can be used as convenient means of supplying those arguments. This method is the same as the staticget_type
method, but uses an already allocated object to determine the type-proxy to access (instead of using the static object).The default implementation of this method does a factory lookup of the proxy using the return value from
get_type_name
. If the type returned byget_type_name
is not registered with the factory, then aNone
handle is returned.For example:
class cmd (UVMObject): type_id = UVMObjectRegistry() @classmethod def type_id get_type(cls): return type_id.get() def get_object_type(self): return cmd.type_id.get()
This function is implemented by the `uvm_*_utils macros, if employed.
Returns:
- classmethod get_type()¶
Returns the type-proxy (wrapper) for this object. The
UVMFactory
’s type-based override and creation methods take arguments ofuvm_object_wrapper
. This method, if implemented, can be used as convenient means of supplying those arguments.The default implementation of this method produces an error and returns
None
. To enable use of this method, a user’s subtype must implement a version that returns the subtype’s wrapper.For example:
class cmd(UVMObject): type_id = None @classmethod def get_type(cls): return cls.type_id.get()
Then, to use:
factory.set_type_override(cmd.get_type(), subcmd.get_type())
This function is implemented by the uvm_*_utils functions, if employed.
Returns:
- get_type_name()¶
This function returns the type name of the object, which is typically the type identifier enclosed in quotes. It is used for various debugging functions in the library, and it is used by the factory for creating objects.
This function must be defined in every derived class.
A typical implementation is as follows:
class mytype (UVMObject): ... type_name = "mytype" def get_type_name(self): return my_type.type_name
We define the
type_name
static variable to enable access to the type name without need of an object of the class, i.e., to enable access via the scope operator, ~mytype::type_name~.- Returns
Type name of the object.
- Return type
- type_id = <uvm.base.uvm_registry.UVMObjectRegistry object>¶
- type_name = 'UVMParentChildLink'¶
- class uvm.base.uvm_links.UVMCauseEffectLink(name='unnamed-UVMCauseEffectLink')[source]¶
Bases:
UVMLinkBase
CLASS: UVMCauseEffectLink
The ~UVMCauseEffectLink~ is used to represent a Cause/Effect relationship between two objects.
- classmethod get_link(lhs, rhs, name='ce_link') UVMCauseEffectLink [source]¶
Function: get_link Constructs a pre-filled link
This allows for simple one-line link creations.
| my_db.establish_link(UVMCauseEffectLink::get_link(record1, record2)) Parameters: lhs - Left hand side reference rhs - Right hand side reference name - Optional name for the link object
- Parameters
cls –
lhs –
rhs –
name –
Returns:
- class uvm.base.uvm_links.UVMRelatedLink(name='unnamed-UVMRelatedLink')[source]¶
Bases:
UVMLinkBase
CLASS: UVMRelatedLink
The ~UVMRelatedLink~ is used to represent a generic “is related” link between two objects.
- classmethod get_link(lhs, rhs, name='ce_link') UVMRelatedLink [source]¶
Function: get_link Constructs a pre-filled link
This allows for simple one-line link creations.
| my_db.establish_link(UVMRelatedLink::get_link(record1, record2))
- Parameters
lhs – Left hand side reference
rhs – Right hand side reference
name (str) – Optional name for the link object
- Returns
Created related link.
- Return type
- create(name='')¶
Group: Creation
The
create
method allocates a new object of the same type as this object and returns it via a base uvm_object handle. Every class deriving from uvm_object, directly or indirectly, must implement the create method.A typical implementation is as follows:
class mytype (UVMObject): ... def create(self, name=""): mytype t = mytype(name) return t
- Parameters
name (str) – Name of the created object.
- Returns
New object.
- Return type
obj
- get_object_type()¶
Function: get_object_type
Returns the type-proxy (wrapper) for this object. The uvm_factory’s type-based override and creation methods take arguments of
uvm_object_wrapper
. This method, if implemented, can be used as convenient means of supplying those arguments. This method is the same as the staticget_type
method, but uses an already allocated object to determine the type-proxy to access (instead of using the static object).The default implementation of this method does a factory lookup of the proxy using the return value from
get_type_name
. If the type returned byget_type_name
is not registered with the factory, then aNone
handle is returned.For example:
class cmd (UVMObject): type_id = UVMObjectRegistry() @classmethod def type_id get_type(cls): return type_id.get() def get_object_type(self): return cmd.type_id.get()
This function is implemented by the `uvm_*_utils macros, if employed.
Returns:
- classmethod get_type()¶
Returns the type-proxy (wrapper) for this object. The
UVMFactory
’s type-based override and creation methods take arguments ofuvm_object_wrapper
. This method, if implemented, can be used as convenient means of supplying those arguments.The default implementation of this method produces an error and returns
None
. To enable use of this method, a user’s subtype must implement a version that returns the subtype’s wrapper.For example:
class cmd(UVMObject): type_id = None @classmethod def get_type(cls): return cls.type_id.get()
Then, to use:
factory.set_type_override(cmd.get_type(), subcmd.get_type())
This function is implemented by the uvm_*_utils functions, if employed.
Returns:
- get_type_name()¶
This function returns the type name of the object, which is typically the type identifier enclosed in quotes. It is used for various debugging functions in the library, and it is used by the factory for creating objects.
This function must be defined in every derived class.
A typical implementation is as follows:
class mytype (UVMObject): ... type_name = "mytype" def get_type_name(self): return my_type.type_name
We define the
type_name
static variable to enable access to the type name without need of an object of the class, i.e., to enable access via the scope operator, ~mytype::type_name~.- Returns
Type name of the object.
- Return type
- type_id = <uvm.base.uvm_registry.UVMObjectRegistry object>¶
- type_name = 'UVMRelatedLink'¶