# UVM Links

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

Contents

UVM Links | The uvm_link_base 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.
uvm_link_base | The uvm_link_base class presents a simple API for defining a link between any two objects.
uvm_parent_child_link | The uvm_parent_child_link is used to represent a Parent/Child relationship between two objects.
uvm_cause_effect_link | The uvm_cause_effect_link is used to represent a Cause/Effect relationship between two objects.
uvm_related_link | The uvm_related_link is used to represent a generic “is related” link between two objects.

## uvm_link_base

The uvm_link_base class presents a simple API for defining a link between any two objects.

Using extensions of this class, a uvm_tr_database can determine the type of links being passed, without relying on “magic” string names.

#### For example

>     virtual function void do_establish_link(uvm_link_base link);
>       uvm_parent_child_link pc_link;
>       uvm_cause_effect_link ce_link;

>       if ($cast(pc_link, link)) begin
>          // Record the parent-child relationship
>       end
>       else if ($cast(ce_link, link)) begin
>          // Record the cause-effect relationship
>       end
>       else begin
>          // Unsupported relationship!
>       end
>     endfunction : do_establish_link

Summary

uvm_link_base
The uvm_link_base class presents a simple API for defining a link between any two objects.
Class Hierarchy
uvm_void
uvm_object
uvm_link_base
Class Declaration
> virtual class uvm_link_base extends uvm_object
new | Constructor
Accessors |
set_lhs | Sets the left-hand-side of the link
get_lhs | Gets the left-hand-side of the link
set_rhs | Sets the right-hand-side of the link
get_rhs | Gets the right-hand-side of the link
set | Convenience method for setting both sides in one call.
Implementation Callbacks |
do_set_lhs | Callback for setting the left-hand-side
do_get_lhs | Callback for retrieving the left-hand-side
do_set_rhs | Callback for setting the right-hand-side
do_get_rhs | Callback for retrieving the right-hand-side

### new

> function new(
> | string | name | = | "unnamed-uvm_link_base"
> )

Constructor

#### Parameters

name | Instance name

### Accessors

### set_lhs

> function void set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side of the link

Triggers the do_set_lhs callback.

### get_lhs

> function uvm_object get_lhs()

Gets the left-hand-side of the link

Triggers the do_get_lhs callback

### set_rhs

> function void set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side of the link

Triggers the do_set_rhs callback.

### get_rhs

> function uvm_object get_rhs()

Gets the right-hand-side of the link

Triggers the do_get_rhs callback

### set

> function void set(
> | uvm_object | lhs,
> |  | rhs
> )

Convenience method for setting both sides in one call.

Triggers both the do_set_rhs and do_set_lhs callbacks.

### Implementation Callbacks

### do_set_lhs

> pure virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Callback for setting the left-hand-side

### do_get_lhs

> pure virtual function uvm_object do_get_lhs()

Callback for retrieving the left-hand-side

### do_set_rhs

> pure virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Callback for setting the right-hand-side

### do_get_rhs

> pure virtual function uvm_object do_get_rhs()

Callback for retrieving the right-hand-side

## uvm_parent_child_link

The uvm_parent_child_link is used to represent a Parent/Child relationship between two objects.

Summary

uvm_parent_child_link
The uvm_parent_child_link is used to represent a Parent/Child relationship between two objects.
Class Hierarchy
uvm_void
uvm_object
uvm_link_base
uvm_parent_child_link
Class Declaration
> class uvm_parent_child_link extends uvm_link_base
new | Constructor
get_link | Constructs a pre-filled link
Implementation Callbacks |
do_set_lhs | Sets the left-hand-side (Parent)
do_get_lhs | Retrieves the left-hand-side (Parent)
do_set_rhs | Sets the right-hand-side (Child)
do_get_rhs | Retrieves the right-hand-side (Child)

### new

> function new(
> | string | name | = | "unnamed-uvm_parent_child_link"
> )

Constructor

#### Parameters

name | Instance name

### get_link

> static function uvm_parent_child_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "pc_link"
> )

Constructs a pre-filled link

This allows for simple one-line link creations.

>     my_db.establish_link(uvm_parent_child_link::get_link(record1, record2));

#### Parameters

lhs | Left hand side reference
rhs | Right hand side reference
name | Optional name for the link object

### Implementation Callbacks

### do_set_lhs

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side (Parent)

### do_get_lhs

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side (Parent)

### do_set_rhs

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side (Child)

### do_get_rhs

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side (Child)

## uvm_cause_effect_link

The uvm_cause_effect_link is used to represent a Cause/Effect relationship between two objects.

Summary

uvm_cause_effect_link
The uvm_cause_effect_link is used to represent a Cause/Effect relationship between two objects.
Class Hierarchy
uvm_void
uvm_object
uvm_link_base
uvm_cause_effect_link
Class Declaration
> class uvm_cause_effect_link extends uvm_link_base
new | Constructor
get_link | Constructs a pre-filled link
Implementation Callbacks |
do_set_lhs | Sets the left-hand-side (Cause)
do_get_lhs | Retrieves the left-hand-side (Cause)
do_set_rhs | Sets the right-hand-side (Effect)
do_get_rhs | Retrieves the right-hand-side (Effect)

### new

> function new(
> | string | name | = | "unnamed-uvm_cause_effect_link"
> )

Constructor

#### Parameters

name | Instance name

### get_link

> static function uvm_cause_effect_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "ce_link"
> )

Constructs a pre-filled link

This allows for simple one-line link creations.

>     my_db.establish_link(uvm_cause_effect_link::get_link(record1, record2));

#### Parameters

lhs | Left hand side reference
rhs | Right hand side reference
name | Optional name for the link object

### Implementation Callbacks

### do_set_lhs

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side (Cause)

### do_get_lhs

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side (Cause)

### do_set_rhs

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side (Effect)

### do_get_rhs

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side (Effect)

## uvm_related_link

The uvm_related_link is used to represent a generic “is related” link between two objects.

Summary

uvm_related_link
The uvm_related_link is used to represent a generic “is related” link between two objects.
Class Hierarchy
uvm_void
uvm_object
uvm_link_base
uvm_related_link
Class Declaration
> class uvm_related_link extends uvm_link_base
new | Constructor
get_link | Constructs a pre-filled link
Implementation Callbacks |
do_set_lhs | Sets the left-hand-side
do_get_lhs | Retrieves the left-hand-side
do_set_rhs | Sets the right-hand-side
do_get_rhs | Retrieves the right-hand-side

### new

> function new(
> | string | name | = | "unnamed-uvm_related_link"
> )

Constructor

#### Parameters

name | Instance name

### get_link

> static function uvm_related_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "ce_link"
> )

Constructs a pre-filled link

This allows for simple one-line link creations.

>     my_db.establish_link(uvm_related_link::get_link(record1, record2));

#### Parameters

lhs | Left hand side reference
rhs | Right hand side reference
name | Optional name for the link object

### Implementation Callbacks

### do_set_lhs

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side

### do_get_lhs

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side

### do_set_rhs

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side

### do_get_rhs

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side

> virtual class uvm_link_base extends uvm_object

The uvm_link_base class presents a simple API for defining a link between any two objects.

> virtual class uvm_tr_database extends uvm_object

The uvm_tr_database class is intended to hide the underlying database implementation from the end user, as these details are often vendor or tool-specific.

> class uvm_parent_child_link extends uvm_link_base

The uvm_parent_child_link is used to represent a Parent/Child relationship between two objects.

> class uvm_cause_effect_link extends uvm_link_base

The uvm_cause_effect_link is used to represent a Cause/Effect relationship between two objects.

> class uvm_related_link extends uvm_link_base

The uvm_related_link is used to represent a generic “is related” link between two objects.

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

> function new(
> | string | name | = | "unnamed-uvm_link_base"
> )

Constructor

> function void set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side of the link

> function uvm_object get_lhs()

Gets the left-hand-side of the link

> function void set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side of the link

> function uvm_object get_rhs()

Gets the right-hand-side of the link

> function void set(
> | uvm_object | lhs,
> |  | rhs
> )

Convenience method for setting both sides in one call.

> pure virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Callback for setting the left-hand-side

> pure virtual function uvm_object do_get_lhs()

Callback for retrieving the left-hand-side

> pure virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Callback for setting the right-hand-side

> pure virtual function uvm_object do_get_rhs()

Callback for retrieving the right-hand-side

> function new(
> | string | name | = | "unnamed-uvm_parent_child_link"
> )

Constructor

> static function uvm_parent_child_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "pc_link"
> )

Constructs a pre-filled link

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side (Parent)

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side (Parent)

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side (Child)

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side (Child)

> function new(
> | string | name | = | "unnamed-uvm_cause_effect_link"
> )

Constructor

> static function uvm_cause_effect_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "ce_link"
> )

Constructs a pre-filled link

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side (Cause)

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side (Cause)

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side (Effect)

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side (Effect)

> function new(
> | string | name | = | "unnamed-uvm_related_link"
> )

Constructor

> static function uvm_related_link get_link(
> | uvm_object | lhs, |  |
> | uvm_object | rhs, |  |
> | string | name | = | "ce_link"
> )

Constructs a pre-filled link

> virtual function void do_set_lhs(
> | uvm_object | lhs
> )

Sets the left-hand-side

> virtual function uvm_object do_get_lhs()

Retrieves the left-hand-side

> virtual function void do_set_rhs(
> | uvm_object | rhs
> )

Sets the right-hand-side

> virtual function uvm_object do_get_rhs()

Retrieves the right-hand-side