Specifying default values to constructor of user classes extended uvm_object and uvm_component

Hi all ,

If I don’t specify the default value of name argument in class extended from uvm_sequence_item ::


class Txn extends uvm_sequence_item ;

 `uvm_object_utils(Txn)

rand bit [1:0] b ;

function new (string name  ); 
 super.new(name);
endfunction

endclass


I get an error ::

Error-[TFAFTC] Too few arguments to function/task call
/asiclibs/libraries/uvm/uvm-1.1d/src/base/uvm_registry.svh, 199
“Txn::new()”
The above function/task call is not done with sufficient arguments.

But for classes extended from uvm_component if default value isn’t given ( for both name as well as parent argument ) it works fine .

[Q] SO why are default values necessary for uvm_object but not for uvm_component class ?

In reply to MICRO_91:

See Mandatory uvm_object Constructors

I think the main question is why we are required to add default name for uvm_object but not uvm_component.

The article just explains why we need to add constructor for every object and component.

There is no default name for a uvm_component because you are required to provide a name at construction so it can build a full path name to its place in the component hierarchy. It cannot be a null string "". And the name must be unique if you are instantiating multiple instances with the same parent.