How can UVM driver control getting of sequence item

3The driver is requesting sequence item from sequencer and it has to get 3 sequence items(in a sequence). Those 3 sequence items it has to drive randomly in 5 cycles. How can driver drive virtual interface with 3 sequence items in 5 cycles.

seq item d0 no get no get d1 d2 d0 d1 no get no get d2
clk cycle cycle1 cycle2 cycle3 cycle 4 cycle 5 cycle 6 cycle 7 cycle 7 cycle 8 cycle 9

forever begin
@(posedge vif.clk)
if(drive_en)-what condition can be added here to get 3 seq item randomly on 5 cycles.
seq_item_port.get_next_item(req)
—drive vif------
seq_item_port.item_done(rsp);
end

In reply to ajay.garg1222:

get_next_item() needs to be paired with item_done() , so ::


REQ  req1 , req2 , req3 ;
 forever  begin 
   .....
seq_item_port.get_next_item( req1 ) ;  
seq_item_port.item_done() ;
seq_item_port.get_next_item( req2 ) ;  
seq_item_port.item_done() ;
seq_item_port.get_next_item( req3 ) ;
seq_item_port.item_done() ;
 //  Drive  on  Virtual  Interface  
seq_item_port.put_response( rsp ) ;  

I would rather suggest ::


REQ  req1 , req2 , req3 ;
 forever  begin 
   .....
seq_item_port.get( req1 ) ;  
seq_item_port.get( req2 ) ;  
seq_item_port.get( req3 ) ;  
 //  Drive  on  Virtual  Interface  
seq_item_port.put_response( rsp ) ;

In reply to ajay.garg1222:

3The driver is requesting sequence item from sequencer and it has to get 3 sequence items(in a sequence). Those 3 sequence items it has to drive randomly in 5 cycles. How can driver drive virtual interface with 3 sequence items in 5 cycles.
seq item d0 no get no get d1 d2 d0 d1 no get no get d2
clk cycle cycle1 cycle2 cycle3 cycle 4 cycle 5 cycle 6 cycle 7 cycle 7 cycle 8 cycle 9
forever begin
@(posedge vif.clk)
if(drive_en)-what condition can be added here to get 3 seq item randomly on 5 cycles.
seq_item_port.get_next_item(req)
—drive vif------
seq_item_port.item_done(rsp);
end

Sounds like an interview question.
You get the 3 seq_items in a fixed order.
Is it correct you want to drive these items in random order?
I believ it should be driving the data from the 3 seq_items shall be driven in 5 clock cycles?
Or are 5 clock cycles required for driving 1 seq_item?
And another question is ‘why should you do this’?

In reply to chr_sue:

Yes you are correct. It gets in fixed order but you have to drive randomly in 5 cycles.

The driver gets 1 sequence item in 1 cycle and it has to get 3 sequence items but it has to drive those 3 sequence items randomly in 5 cycles.

How to control that driver get mechanism.?

In reply to ajay.garg1222:

You can store the seq_items in a queue.

my_seq_item q[$];
for (int i = 0; i < 3; i++) begin
  seq_item_port.get( req );
  q.push_back(req);
end
q.shuffle();   //randomizes the order
for (int i = 0; i < 3; i++) begin
  req = q.pop_front;  // returns the 1st element
  // drive the req data
end

In reply to chr_sue:

Thanks for the reply.
q.shuffle is not required. Just that 3 sequence items in order has to be driven in 5 cycles.
But how to drive these 3 sequence items in 5 cycles randomly? That is the question.

In reply to ajay.garg1222:

You are driving each data from seq_item with 1 clock cycle and in between there are also 1 cycle. This is 3 plus 2 = 5.