# Question on uvm\_driver w.r.t uvm\_sequence\_item

**URL:** <https://verificationacademy.com/forums/t/question-on-uvm-driver-w-r-t-uvm-sequence-item/45518>\
**Category:** UVM\
**Created:** [January 11, 2024, 1:24am UTC](https://verificationacademy.com/forums/t/question-on-uvm-driver-w-r-t-uvm-sequence-item/45518 "2024-01-11T01:24:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sv\_uvm\_learner](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sv\_uvm\_learner](https://verificationacademy.com/forums/u/sv_uvm_learner)\
**Post date:** [January 11, 2024, 1:24am UTC](https://verificationacademy.com/forums/t/question-on-uvm-driver-w-r-t-uvm-sequence-item/45518/1 "2024-01-11T01:24:50Z")

</div>

This is an interview question :  
Implement a uvm driver with following conditions

1. Sequence items have 64 bit data field and transaction id
2. Driver drives only 32 bits of the data on the interface. Lower 32 bits are driven first for a given sequence item.
3. Upper 32 bits may or may not immediately follow the lower 32 bits. For a given sequence item, lower 32 bits will be driven first, then d-words from **other** sequence items may be driven, and upper 32 bits will be driven after that. This flow is randomized.

Can someone help with this?

Pseudo code of my understanding :

```auto
task run_phase: 

forever begin
seq_item_port.get_next_item(req);

fork
   task_1 ; //drive the lower 32 bits of the data on the interface
   task_2 : //drive the upper 32 bits of the data on the interface
join_none

seq_item_port.item_done();
end

```

It is not clear to me if this seq\_item will still be available once the `seq_item_port.item_done()` is executed. If it not going to be available, then I think my idea won’t work.  
How can we keep info from previous sequence items while also working on the next sequence item?

Thanks.

---

<div class="post-metadata">

**Author:** ![kranthikiranufl1](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/f4b2a3/32.png) [@kranthikiranufl1](https://verificationacademy.com/forums/u/kranthikiranufl1)\
**Post date:** [February 11, 2024, 8:05pm UTC](https://verificationacademy.com/forums/t/question-on-uvm-driver-w-r-t-uvm-sequence-item/45518/2 "2024-02-11T20:05:47Z")

</div>

> [@sv\_uvm\_learner](#):
>
> This is an interview question :  
> Implement a uvm driver with following conditions
> 
> 1. Sequence items have 64 bit data field and transaction id
> 2. Driver drives only 32 bits of the data on the interface. Lower 32 bits are driven first for a given sequence item.
> 3. Upper 32 bits may or may not immediately follow the lower 32 bits. For a given sequence item, lower 32 bits will be driven first, then d-words from **other** sequence items may be driven, and upper 32 bits will be driven after that. This flow is randomized.

This is a question on pipelined driver. Here the sequence item is executed in tow stages (lower 32-bit data and higher 32-bit data). So you will need to implement a pipelined driver which can execute two sequence items in parallel but in different stages of execution.

The code looks something like the following:  
Class my\_driver extends uvm\_driver #(my\_seq\_item);  
`uvm\_component\_utils(my\_driver)

```
 semaphore S1;

```

task build\_phase(uvm\_phase phase);  
S1 = new(1);

endtask

task run\_phase(uvm\_phase phase);  
wait\_for\_reset();  
fork  
drive\_data();  
drive\_data();  
join  
endtask

task drive\_data();  
forever begin  
S1.get\_lock();  
seq\_item\_port.get(req);  
send\_low\_data(req);  
S1.release\_lock();  
send\_high\_data(req);  
seq\_item\_port.put();  
end  
endtask

You have to use get() and put() instead of get\_next\_item() and item\_done() pair in order to achieve parallelism.

---

<div class="post-metadata">

**Author:** ![Mahantha\_Deeksha\_S\_B](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/mahantha_deeksha_s_b/32/1072_2.png) [@Mahantha\_Deeksha\_S\_B](https://verificationacademy.com/forums/u/Mahantha_Deeksha_S_B)\
**Post date:** [February 13, 2024, 2:01pm UTC](https://verificationacademy.com/forums/t/question-on-uvm-driver-w-r-t-uvm-sequence-item/45518/3 "2024-02-13T14:01:46Z")

</div>

if your task\_1 and task\_2 consumes time and if you are sending another item immediately i think i will override to the current req in this case it would be better if we copy it to another handle and execute the threads,

if no other items are there means there will be a chance that your sim will exit before you even finish the routines(if time consumed), since it will end the body of sequence and in turn it will end the start method and if no delay given will drop the test objection.  
if you want to do pipelined driver then there is article in this website or use fork join\_any and use the next item to drive some routine while the other is executing or,

```auto
class pipelined_driver extends uvm_driver #(item);
   item req_que [$];
   int max_pipeline_depth = 2;
   `uvm_component_utils(pipelined_driver)
   //////constructor
   task run_phase(uvm_phase phase);
      fork
         get_and_drive();
         drive_transfers();
      join
   endtask : run_phase
   task get_and_drive();
      while(req_que.size() < max_pipeline_depth)begin
         seq_item_port.get_next_item(req);
         $cast(rsp,req.clone());
         rsp.set_id_info(req);
         req_que.push_back(rsp);
         seq_item_port.item_done();
      end
   endtask : get_and_drive
   task drive_transfer();
      item cur_req;
      while(1)begin
         wait(req_que.size() > 0);
         cur_req = req_que.pop_front();
         send_to_dut(cur_req);
         rsp_port.write(cur_req);
      end
   endtask : drive_transfer
endclass : pipelined_driver

```
