Browse Source

aswini

main
aswini 6 months ago
parent
commit
71801b0b5f
2 changed files with 128 additions and 0 deletions
  1. +83
    -0
      driver.sv
  2. +45
    -0
      seq.sv

+ 83
- 0
driver.sv View File

@@ -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


+ 45
- 0
seq.sv View File

@@ -0,0 +1,45 @@
class wr_seq extends uvm_sequence #(wrap_txn);
`uvm_object_utils(wr_seq)
wrap_txn txn;
function new(string name = "wr_seq");
super.new(name);
endfunction

task body();
txn=wrap_txn::type_id::create("txn");
start_item(txn);
assert(txn.randomize() with {wr_rd == 1;});
finish_item(txn);
endtask

endclass

class rd_seq extends uvm_sequence #(wrap_txn);
`uvm_object_utils(rd_seq)
wrap_txn txn;
function new(string name = "rd_seq");
super.new(name);
endfunction

task body();
txn=wrap_txn::type_id::create("txn");
start_item(txn);
assert(txn.randomize() with {wr_rd ==0;});
finish_item(txn);
endtask
endclass

class seq extends uvm_sequence#(wrap_txn);
`uvm_object_utils(seq)
wr_seq w_s;
rd_seq r_s;
function new(string name = "seq");
super.new(name);
endfunction
task body();
`uvm_do(w_s);
`uvm_do(r_s);
endtask
endclass


Loading…
Cancel
Save