Write the driver code for a driver that needs to send packets immediately every time it sees something from the sequencer, and move on if nothing is there. The driver should simultaneously be checking for responses from the DUT and match that response to one of the previously driven packets. Send the response back to the sequence.
class my_driver extends uvm_driver#(my_tx);
virtual my_intf vif;
int id_queue[$];
function new(string name="",uvm_component parent);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual my_intf)::get(this,"","vif",vif))
`uvm_fatal(get_type_name(),"Virtual interface not found")
endfunction
task run_phase(uvm_phase phase);
forever begin
fork
begin
seq_item_port.get_next_item(req);
id_queue.push_back(req.id);
drive_tx(req);
seq_item_port.item_done();
end
begin
@(posedge vif.clk);
if(vif.valid==1) begin
my_tx rsp = my_tx::type_id::create("rsp")
rsp.id = vif.id;
foreach(id_queue[i]) begin
if(rsp.id == id_queue[i].id)begin
rsp = id.queue[i];
id_queue.delete(i);
break;
end
end
seq_item_port.item_done(rsp);
end
end
end
endtask
endtask
Is my solution correct for this question?