UVM pipelined driver implementation

Hello,

I have a query regarding pipelined driver implementation.
In my driver class,

xyz_seq_item tx;
seq_item_port.get_next_item(tx);
fork
adr_phase();
data_phase();
join_none
seq_item_port.item_done();

task adr_phase();
//adress phase operations
xyz_q[id].q.pushback (tx); //Declare a queue here to push back the sequence item after address phase operations are done
endtask

task data_phase();
xyz_q.q.popfront(tx); //Get the sequence item out of the queue and do the data operations on it
//data phase operations
end task

Now that I have used a fork-join_none , after these tasks are forked off, “seq_item_port.item_done()” is called and the driver can fetch the next sequence item and carry on the data & address phase operations. These get added to the queue and the bus operation continues.

Could someone please tell me if this implementation is correct ?

Thanks

You have some issues here. In addr_phase(), you don’t know who tx is, since that’s a local variable in the bigger task (guessing it’s your run_phase(…)). You’ll also be getting items like crazy there, since you don’t block at all. It’s also more complicated than it needs to be.

I’d do something along these lines:


task run_phase(uvm_phase phase);
  forever begin
    xyz_seq_item tx;
    seq_item_port.get_next_item(tx);
    drive(tx);
    seq_item_port.item_done();
  end
endtask

// block until the address phase is done, at which point a new
// item could be started
task drive(xyz_seq_item item);
  drive_addr_phase(item);
  fork
    drive_data_phase(item);
  join_none
endtask

task drive_addr_phase(xyz_seq_item item);
  // your logic here
endtask

task drive_data_phase(xyz_seq_item item);
  // your logic here
endtask

This code is off the top of my head so it might not compile directly. It avoids having to use any thread synchronization here, so it should be simpler to follow.

In reply to Tudor Timi:

Thanks for the suggestions.
In this case, when the second item is going through address phase the first item will be going through data phase.
Will we need a queue in this case as multiple items might be going through the data phase at a time ??

In reply to Madhu_15:

I was thinking AHB, where only one item is in the address phase, while the other is in the data phase. If you have this situation, then yeah, you might need a queuing mechanism. You should be able to figure out the details yourself.