Dynamic array of sequence

Hi All,

i have a dynamic array of sequence seq_module (which is extended from uvm_sequence) in one of my top_class and i am creating this seq_module ie., din build phase of the top_class ie., using create method

Question is: do i also need to use new the dynamic array :seq_module

My analaysis is: create would call the new of the sequence but somehow without newing (just by create) when i try to use sequnce_module[0]/[i] it gives me null pointer error

Not very sure if i missed some basic concept of new vs create

Thanks,
Shravan

In reply to shravan19:

Could you please elaborate in some more detail and more precisely.
What is seq_module? Is this indeed a module? And why do you need dynamic array of sequences?

In reply to shravan19:

The “new” function is used to set the size of dynamic arrays. While, “create()”/“new()” will allocate memory to each element of array. They both allocate memory and initialize values. The big difference is that the new() function is called to construct a single object, whereas the new operator is building an array with multiple elements.

Here you have to allocate the memory for dynamic array first and then you can allocate each elements individually using “create()”.

// I am assuming seq_module is a uvm based class
seq_module seq_mod[];
seq_mod = new[num_elements];
foreach(seq_mod[i])
  seq_mod[i] = seq_module::type_id::create($sformatf("seq_mod[%0d]",i));

Here, the “new” will allow you to create elements/handles to iterate in foreach loop. While “create()” will allocate memory space for each of those elements.

In reply to chr_sue:

I had some custom need for our project where in i needed dynamic array of sequences.
i just named seq_module just for understanding the hierarchy ie>< its not a module<its class

In reply to sharvil111:

Thanks a lot,now i got it,Really nice ,detailed explanation