Sequence switching

There are two different sequences each having repetition of hundred, I want to run them on sequencer in such a way that after random number of repetition lets say 5, each sequence should run one by one. How can I achieve this?

In reply to krishnachaudhary:

You need to fill in more details. How are first 5 (or whatever number) sequences selected? Do you mean there are a total of exactly 200 sequences; 100 of each type? If yes, that means the first 5 sequences need to be selected in such a way that leaves the remaining sequences balanced between types.

In reply to dave_59:
Hi Dave,
let me elaborate, let me take an example having below 2 sequences,

class axi_m_wr_Sequence extends uvm_sequence#(axi_m_Sequence_Item);
  
  `uvm_object_utils(axi_m_wr_Sequence)
  
  function new(string name="axi_m_wr_Sequence");
  super.new(name);
  endfunction
  
  virtual task body();
   repeat(100) begin //repeating 100 times
    `uvm_create(req)
    `uvm_rand_send_with(req,{req.RW==0;  })  //Write sequence 
   end
  endtask
endclass


class axi_m_rd_Sequence extends uvm_sequence#(axi_m_Sequence_Item);
  
  `uvm_object_utils(axi_m_rd_Sequence)
  
  function new(string name="axi_m_rd_Sequence");
  super.new(name);
  endfunction
  
  virtual task body();
   repeat(100) begin //repeating 100 times
    `uvm_create(req)
    `uvm_rand_send_with(req,{req.RW==1; })  //Read sequence 
   end
  endtask
endclass

class axi_m_sequencer  extends uvm_sequencer#(axi_m_Sequence_Item);  
  `uvm_component_utils(axi_m_sequencer)

  function new(string name="axi_m_sequencer",uvm_component parent);
    super.new(name,parent);
  endfunction : new 
endclass

I want to run above 2 sequences in such a way that after sending 5 request another sequence should start or in other words suppose axi_m_wr_Sequence is running then after 5 write req rather than 100, axi_m_rd_Sequence should run for another 5 read req.

Read about virtual sequences. Virtual sequences can help orchestrate how other sequences are created and run on the sequencer. You can achieve what you are asking using that.

In reply to maddy0812:

I do not agree. Virtual sequences are typically used to orchestrate sequences for different sequencers without generating seq_items.
In the actual case you do not have this. But you can define a sequence which executes inside write and read sequences to create the corresponding seq_items of the same type (class).

In reply to chr_sue:

Dont understand what you mean by without generating seq_items.

the sequence_items are still created inside the 2 sequences(based on sequence randomization) which are started on the same sequencer in the virtual sequence. Can you elaborate on why that might be a problem?

In reply to maddy0812:

Your sequences are running on the same sequencer. A virtual sequence can not run on this sequencer. And a virtual sequence is not creating seq_items.
Using a nested sequence which runs on your sequencer is the solution.

the virtual sequence is not going to run on the sequencer. it starts the child sequences on the same sequencer. don’t understand what the gap is here.

In reply to krishnachaudhary:

I think, instead of putting 100 repeat in each sequence will not help you to archive your goal easy way.
As per my suggestion, easy approach will be like you need to make both sequence independent (I mean without repeat)
And need to control sequence when/which/what order as per requirement inside test.

I have prepared simple example in which i am switching between sequence after 5 transection.

I hope it helps.

Thanks!