Is it valid to pass uvm_component parameter while creating instance of a sequence?

Hi,

In our code base, when creating an instance of a sequence inside an environment, we pass two parameters to create() which are string name and parent. But I don’t understand the reasoning behind it and also UVM doesn’t complain about it.

Here is an example code:

class test_magic_seq_c extends uvm_sequence#(magic_word);

class magic_env_c extends uvm_env;

test_magic_seq_c   test_magic_seq;
test_magic_seq = test_magic_seq_c::type_id::create("test_magic_seq",  this);

endclass: magic_env

I would appreciate if someone can provide me a reason how this is valid as sequence is uvm_object.

Thanks in advance.

The name gets used for reporting and debugging. If this sequence creates sub-sequences, it creates a pathname similar to call stack.

The parent get used as a context for controlling factory overrides.

Could you please elaborate on this as generally ‘parent’ is passed for uvm_component and not for uvm_object. Also, as sequence class gets extended from uvm_object, why do we pass parent when creating a sequence. (constructor of uvm_object/uvm_sequence class also has a single parameter of ‘name’)

function new (	string 	name	 = 	"uvm_sequence"	)

Is it that if we don’t pass parent parameter, it’s not possible to instance override?

Appreciate your response!

Correct. You will only be able to factory override the sequence by type.

Thanks Dave!

Hi Dave ,

Isn’t this partially true ?
As we discussed in thread the 3rd argument ‘contxt’ to create function also enables instance override for both uvm_object and uvm_components irrespective of whether an actual was passed to 2nd argument ‘parent’ of type uvm_component.
From what I am able to recollect from all examples that I have tried in the past,
if all 3 arguments are passed to create , the ‘contxt’ argument takes precedence over ‘parent’ and the instance override should be set using the ‘contxt’ argument.
I found a blog which has examples of instance override using ‘contxt’ argument and without passing an actual to parent argument.

Yes, I forgot about the third argument. The context is ultimately just a string name.