|
|
@@ -0,0 +1,83 @@ |
|
|
|
class driver extends uvm_driver #(wrap_txn); |
|
|
|
`uvm_component_utils(driver) |
|
|
|
virtual axi_if vif; |
|
|
|
wrap_txn txn; |
|
|
|
function new(string name ="driver",uvm_component parent); |
|
|
|
suoer.new(name,parent); |
|
|
|
endfunction |
|
|
|
|
|
|
|
function void build_phase(uvm_phase phase); |
|
|
|
super.build_phase(phase); |
|
|
|
txn = wrap_txn::type_id::create("txn",this); |
|
|
|
if(!uvm_config_db #(axi_if)::get(this,"","vif",vif)) |
|
|
|
`uvm_error("build phase","driver virtual interface failed") |
|
|
|
endfunction |
|
|
|
|
|
|
|
task run_phase(uvm_phase phase); |
|
|
|
forever |
|
|
|
begin |
|
|
|
seq_item_port.get_next_item(txn); |
|
|
|
drive_logic(txn); |
|
|
|
seq_item_port.item_done(); |
|
|
|
end |
|
|
|
endtask |
|
|
|
|
|
|
|
task drve_logic(wrap_txn txn); |
|
|
|
begin |
|
|
|
`uvm_info("AXI_DRIVER",$sformatf("driver started"),UVM_LOW); |
|
|
|
@(vif.drv_cb); |
|
|
|
vif.arst<=1; |
|
|
|
@(vif.drv_cb); |
|
|
|
vif.arst<=0; |
|
|
|
if(wr_rd <= 1) |
|
|
|
begin |
|
|
|
vif.awid <= txn.awid; |
|
|
|
vif.awaddr<= txn.awaddr; |
|
|
|
vif.awburst <= txn.awburst; |
|
|
|
vif.awsize <= txn.awsize; |
|
|
|
vif.awlen <= txn.awlen; |
|
|
|
vif.awlock <= txn.awlen; |
|
|
|
vif.awprot <= txn.awprot; |
|
|
|
vif.awcache<= txn.awcache; |
|
|
|
vif.awvalid <= 1; |
|
|
|
wait(vif.drv_cb.awready == 1); |
|
|
|
vif.awvalid <= 0; |
|
|
|
@(vif.drv_cb); |
|
|
|
for(int i =1;i<=vif.awlen+1;i++) |
|
|
|
begin |
|
|
|
vif.wid <= txn.wid; |
|
|
|
vif.wdata<= txn.wdata.pop_front(); |
|
|
|
vif.wstrb <= txn.wstrb; |
|
|
|
vif.awvalid <= 1; |
|
|
|
if(i == vif.awlen+1) |
|
|
|
vif.wlast <= txn.wlast; |
|
|
|
else |
|
|
|
vif.wlast <= 0; |
|
|
|
wait(vif.wready == 1); |
|
|
|
vif.wvalid <= 0; |
|
|
|
end |
|
|
|
@(vif.drv_cb); |
|
|
|
vif.bid <= txn.bid; |
|
|
|
vif.bresp <= txn.bresp; |
|
|
|
vif.bvalid <= 1; |
|
|
|
wait(vif.bready == 1); |
|
|
|
vif.bvalid <= 0; |
|
|
|
end |
|
|
|
else |
|
|
|
begin |
|
|
|
vif.arid <= txn.arid; |
|
|
|
vif.araddr<= txn.araddr; |
|
|
|
vif.arburst <= txn.arburst; |
|
|
|
vif.arsize <= txn.arsize; |
|
|
|
vif.arlen <= txn.arlen; |
|
|
|
vif.arlock <= txn.arlen; |
|
|
|
vif.arprot <= txn.arprot; |
|
|
|
vif.arcache<= txn.arcache; |
|
|
|
vif.arvalid <= 1; |
|
|
|
wait(vif.drv_cb.arready == 1); |
|
|
|
vif.arvalid <= 0; |
|
|
|
@(vif.drv_cb); |
|
|
|
end |
|
|
|
end |
|
|
|
endtask |
|
|
|
|