User guide
24-58
SystemVerilog Testbench Constructs
Shows new value of the base property, p, and value of the
extended property, q
Base: p=2
Extended: q=3
The base handle b2 is pointing to the Extended object
Base: p=2
Extended: q=3
Using $cast to assign b2 to e2
Base: p=2
Extended: q=3
The $cast() can be used to cast non-enum types into an enum-type
destination.
$cast(enum1, int1)
The following case is supported as long as enum1 and enum2 are of
same base enum-type:
$cast(enum1, enum2)
Enumerated types can, however, be cast into any other non-enum
types (that is, they can be used as the source argument in $cast()
without any restrictions):
$cast(int1, enum1) // supported, destination non-enum
(int)
Chaining Constructors
To understand the relational use of the terms “base” and “super” as
employed to refer to classes, consider the following code fragment: