使用场景:在soc验证中,很多需要通过cpu通过总线路由去配制寄存器,这个过程非常耗时,特别是当subsys有很多寄存器需要配置的时候,非常痛苦。下面介绍一种大大缩短配置寄存器时间的方法:
task apb_force_write(input reg [31:0] paddr, input reg [31:0] pwdata);
// force apb signals
@(posedge p_sequencer.vc0_vpss_aclk);
uvm_hdl_force("SUBSYS_PATH.psel_s0`", 1);
uvm_hdl_force("SUBSYS_PATH.pwrite_s0`", 1);
// uvm_hdl_force("SUBSYS_PATH.pstrb_s0`", 4'hf);
uvm_hdl_force("SUBSYS_PATH.paddr_s0`", paddr);
uvm_hdl_force("SUBSYS_PATH.pwdata_s0`", pwdata);
@(posedge p_sequencer.vc0_vpss_aclk);
uvm_hdl_force("SUBSYS_PATH.penable_s0`", 1);
// wait for pready
do begin
@(posedge p_sequencer.vc0_vpss_aclk);
end while (p_sequencer.vc0_vpss_pready == 0);
// release apb signals
uvm_hdl_release("SUBSYS_PATH.psel_s0`");
uvm_hdl_release("SUBSYS_PATH.pwrite_s0`");
uvm_hdl_release("SUBSYS_PATH.pwdata_s0`");
uvm_hdl_release("SUBSYS_PATH.penable_s0`");
uvm_hdl_release("SUBSYS_PATH.paddr_s0`");
$display("[WRITE_REG], addr = %h, data = %h",paddr,pwdata);
endtask
task apb_force_read(input reg [31:0] paddr, output reg [31:0] prdata);
@(posedge p_sequencer.vc0_vpss_aclk);
uvm_hdl_force("SUBSYS_PATH.paddr_s0`",paddr);
uvm_hdl_force("SUBSYS_PATH.pwrite_s0`",0);
uvm_hdl_force("SUBSYS_PATH.psel_s0`" ,1);
@(posedge p_sequencer.vc0_vpss_aclk);
uvm_hdl_force("SUBSYS_PATH.penable_s0`",1);
@(posedge p_sequencer.vc0_vpss_aclk);
while(p_sequencer.vc0_vpss_pready==0)begin
@(posedge p_sequencer.vc0_vpss_aclk);
end
uvm_hdl_force("SUBSYS_PATH.paddr_s0`" ,0);
uvm_hdl_force("SUBSYS_PATH.psel_s0`" ,0);
uvm_hdl_force("SUBSYS_PATH.penable_s0`",0);
prdata = p_sequencer.vc0_vpss_prdata;
uvm_hdl_release("SUBSYS_PATH.paddr_s0`" );
uvm_hdl_release("SUBSYS_PATH.psel_s0`" );
uvm_hdl_release("SUBSYS_PATH.penable_s0`");
uvm_hdl_release("SUBSYS_PATH.pwdata_s0`");
uvm_hdl_release("SUBSYS_PATH.pwrite_s0`");
$display("[READ_REG], addr = %h, data = %h",paddr,prdata);
end
只需要将信号按照apb的时序force到寄存器的入口就可以,可以缩短99%的时间,这里的SUBSYS.PATH 就是subsys寄存器入口的hierarchy。