I want to randomly select a sequence from 10 defines sequences and run using uvm_do();
uvm_do(seq_1),uvm_do(seq_9)…etc when run with different seed
To achieve this i have used a define With the above code, RAND_SEQ(rand_seq) will be preprocessed and gives error that “seq_rand_seq is undefined identifier” at `define
If i write as below,
if(rand_seq == 1) RAND_SEQ(1) else if(rand_seq == 2) RAND_SEQ(2)
else if()…
I need to write for all 10 sequences
then only it works.
If i have 100 sequences, i can’t do the same for 100.
How can i achieve above requirement in a simple way.
Compiler directives are pre-processor stuff and hence can’t be used in the way you are looking for. UVM library already has this feature for you - it is called uvm_sequence_library, use that.
In reply to swathi allenki:
You can do this with a simple array of uvm_object_wrappers
uvm_object_wrapper seq_array[$];
// in the constructor or the body of some other method
seq_array.push_back(first_seq::get_type());
seq_array.push_back(second_seq::get_type());
seq_array.push_back(third_seq::get_type());
...
seq_array.push_back(tenth_seq::get_type());
task random_sequence;
uvm_sequence#(your_item_type) seq;
int rand_seq;
rand_seq = $urandom_range(9,0);
$cast(seq,seq_array[rand_seq].create_object(""));
seq.start();
endtask
ncsim: *E,BCLCST : Invalid cast: a value with the class datatype ‘umc_pkg::third_seq’ cannot be assigned to a class variable with the datatype ‘uvm_pkg::uvm_sequence#(uvm_sequence_item,uvm_sequence_item)’.
ncsim: *E,TRNULLID: NULL pointer dereference.