采用如下源码,从仿真log中发现一个问题:当cpu没有发出读写命令,即re&we都为0,monitor也会采样传给reference model。
task cpu_monitor::main_phase(uvm_phase phase);
cpu_transaction tr;
while(1) begin
tr = new("tr");
collect_one_pkt(tr);//采集 DUT interface的值,并传给reference model.
end
endtask
为了屏蔽这种冗余采样,做了如下修改:
task cpu_monitor::main_phase(uvm_phase phase);
cpu_transaction tr;
while(1) begin
tr = new("tr");
if(cif.cpu_re|cif.cpu_we)//添加改行code,当cpu发起读写cmd,再进行采样
collect_one_pkt(tr);
`uvm_info("[cpu_monitor]","end phase", UVM_LOW);
end
endtask
但是仿真过程中发现,仿真时间hang住,uvm_info 打印的时间一直是0时刻,解决办法:
task cpu_monitor::main_phase(uvm_phase phase);
cpu_transaction tr;
while(1) begin
tr = new("tr");
if(cif.cpu_re|cif.cpu_we)//添加改行code,当cpu发起读写cmd,再进行采样
collect_one_pkt(tr);
else
@(posedge top.clk); //加上else 和该语句,仿真正常,且采样符合预期
`uvm_info("[cpu_monitor]","end phase", UVM_LOW);
end
endtask
我理解的原因是:修改之前的while循环里所有操作都不消耗仿真时间,所以处于一直在0时刻判断的情况