Assume that A is a registered class extended by uvm_object. B is a function inside A. Now in another task C,if I want to use the function B in A,can I code as below shown?
class A extends uvm_object;
function void B();
Yes, you should be able to do that.
You are creating an object U_A of type A by using “create” method. After that you will be able to access all the members of that class (A).
You cannot have a reference to this outside of a class method, if that was your intention. You don’t need a parent argument to create a
uvm_object anyways, so you can eliminate it.
Sorry, I still don’t understand. What don’t we need a parent argument when creating
uvm_object. If I want to register it ,this class should extend
By the way , can we instantiate a
class in a
The parent argument to
create() is a
uvm_component. It sets the context used when there are factory overrides. A context is the hierarchical path of a tree of
uvm_components. (if you were creating a class extended from
uvm_component the argument sets both is context and its parent).
Typically you are constructing UVM classes as methods of other UVM classes. You would pass this as the parent if the class was extended from
uvm_component. Otherwise it would be null, or if creating from a sequence, you would pass the sequencer.
Thanks! I didn’t notice that I had added
this when creating a child class of
Additionally, I still want to ask that if it is allowed to instantiate a
class in a
Thanks for your patient answering. I have tried and it worked.