I have a confusion. What is the purpose of using uvm_object data type. For example, I have seen in code like uvm_object tmp_object;
and then we cast it into our required variable, by doing
assert($cast(m_seq_a[0][0], tmp_object));
Why can’t we directly create handle and the using “function new” create object? I didn’t understand the part of creating tmp_object of type uvm_object and later casting it to required handle.
You cannot call new() except as the RHS of a procedural assignment; the BNF syntax does not allow it. You could use the UVM’s create method directly instead of using a temporary variable.
Hi, i think if i understand your intention correctly then i can say,
uvm_object is at very fundamental level a common base type class where we can utilise the casting concept when we aren’t sure about the original data type of class.
The type casting using $cast is not limited to uvm_objects. You can use it also for uvm_components.
Type casting is used when functions are returning the type of the uvm base classess, like uvm_object or uvm_component.
A typical example is when you are searching for components in your envrionment using the function find.
The definition
function uvm_component find (string comp_match);
returns a component of type uvm_component and you can cast this to your real component.