|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
class ahbl_trans extends uvm_sequence_item;
class ahbl_mst_basic_seq extends uvm_sequence#(ahbl_trans);
class ahbl_mst_burst_seq extends ahbl_mst_basic_seq;
class ahbl_mst_sqr extends uvm_sequencer#(ahbl_trans);
class ahbl_mst_drv extends uvm_driver#(ahbl_trans);
//------------------------------------------
// Data, Interface, port Members
//------------------------------------------
virtual ahbl_if vif;
ahbl_trans pkt_apha = null; //packet address-phase
ahbl_trans pkt_dpha = null; //packet data-phase
uvm_sequence_item item;
//Factory Registration
//
`uvm_component_utils(ahbl_mst_drv)
//----------------------------------------------
// Methods
// ---------------------------------------------
// Standard UVM Methods:
extern function new(string name = "ahbl_mst_drv", uvm_component parent);
extern virtual function void build_phase(uvm_phase phase);
extern virtual task main_phase(uvm_phase phase);
// User Defined Methods:
extern task drive_lcyc_pkt_dpha(ref ahbl_trans pkt);
extern task drive_lcyc_pkt_apha(ref ahbl_trans pkt);
extern task drive_lcyc_pkt_idle();
endclass
//Constructor
function ahbl_mst_drv::new(string name = "ahbl_mst_drv", uvm_component parent);
super.new(name, parent);
endfunction
//Build_Phase
function void ahbl_mst_drv::build_phase(uvm_phase phase);
super.build_phase(phase);
if(!uvm_config_db#(virtual ahbl_if)::get(this,"","vif",vif))
`uvm_fatal("my_driver", "Error in Getting interface")
endfunction
//Main_Phase
task ahbl_mst_drv::main_phase(uvm_phase phase);
while(1) begin
@(vif.mst_cb);
if(!vif.mst_cb.hresetn) begin
vif.mst_cb.hsel <= 1'b0;
vif.mst_cb.haddr <= 32'b0;
vif.mst_cb.htrans <= IDLE;
vif.mst_cb.hsize <= BYTE;
vif.mst_cb.hburst <= SINGLE;
vif.mst_cb.hprot <= 4'b0;
vif.mst_cb.hwrite <= 1'b0;
vif.mst_cb.hwdata <= 32'b0;
vif.mst_cb.clk_ratio<= 4'h1;
pkt_dpha = null;
pkt_apha = null;
end
else begin
//transfer data
if(pkt_dpha != null) begin
drive_lcyc_pkt_dpha(pkt_dpha);
if(vif.mst_cb.hready & (pkt_dpha.hburst == SINGLE | pkt_dpha.last_beat())) begin
seq_item_port.item_done();
pkt_dpha = null;
pkt_apha = null;
end
end
if(pkt_apha != null) begin
//transfer address
drive_lcyc_pkt_apha(pkt_apha);
end
else begin
`uvm_info(get_type_name(),"BEFORE get next item",UVM_LOW)
seq_item_port.get_next_item(pkt_apha);//(pkt_apha);
`uvm_info(get_type_name(),"AFTER get next item",UVM_LOW)
if(pkt_apha != null) begin
drive_lcyc_pkt_apha(pkt_apha);
pkt_apha.print();
`uvm_info(get_type_name(), "ahbl_mst_drv successfully get a new AddressPhase pkt", UVM_LOW)
end
else begin
drive_lcyc_pkt_idle();
//`uvm_info(get_type_name(), "ahbl_mst_drv didn't get a new AddressPhase pkt", UVM_LOW)
end
end
end
end
endtask
task ahbl_mst_drv::drive_lcyc_pkt_dpha(ref ahbl_trans pkt);
if(vif.mst_cb.hready)
vif.mst_cb.hwdata <= pkt.hwrite ? pkt.nxt_hrwdata() : 32'd0;
endtask
task ahbl_mst_drv::drive_lcyc_pkt_apha(ref ahbl_trans pkt);
if((vif.mst_cb.hready)) begin
vif.mst_cb.hsel <= pkt.hsel;
vif.mst_cb.haddr <= ((pkt.htrans_ro() != IDLE)&(pkt.htrans_ro() != BUSY)) ? pkt.nxt_haddr() : vif.haddr;
vif.mst_cb.htrans <= pkt.nxt_htrans();
vif.mst_cb.hsize <= pkt.hsize;
vif.mst_cb.hburst <= pkt.hburst;
vif.mst_cb.hprot <= pkt.hprot;
vif.mst_cb.hwrite <= pkt.hwrite;
vif.mst_cb.clk_ratio<= pkt.clk_ratio;
this.pkt_dpha <= this.pkt_apha;
end
endtask
task ahbl_mst_drv::drive_lcyc_pkt_idle();
vif.mst_cb.hsel <= 1'b0;
vif.mst_cb.haddr <= 32'b0;
vif.mst_cb.htrans <= IDLE;
vif.mst_cb.hsize <= BYTE;
vif.mst_cb.hburst <= SINGLE;
vif.mst_cb.hprot <= 4'b0;
vif.mst_cb.hwrite <= 1'b0;
vif.mst_cb.clk_ratio<= 4'h1;
endtask
仿真发现sequence里面能够对事物随机化成功,在driver中卡在了get_next_item()那,但是我检查了各个类继承的参数感觉都没问题,有人知道问题在哪吗?编译能通过,运行时报[sqr_i] send_request failed to cast sequence item |
|