我开发了一个简单的 uvm 测试台来验证一个简单的加法器。我也使用功能覆盖率来监控覆盖率。加法器是 8 位,输入a
和b
输出c
是 9 位。
我已经rand logic
为a
和开发了 8 位的事务b
。按顺序,我已经运行了repeat(100)
它,它会随机化并驱动a
到b
DUT。对于这种情况,功能覆盖率的最佳情况是 (100/256)*100%,即假设不会重复任何值,约为 40%。我在记分牌中对覆盖范围进行采样,并在 env 中获取覆盖结果。
这是我的代码片段
// monitor class
covergroup cg;
a : coverpoint sb_item.a;
b : coverpoint sb_item.b;
endgroup
...
function void write(input input_seq_item i);
sb_item = i;
if(sb_item.c == sb_item.a + sb_item.b)
begin
`uvm_info("SB","OK!",UVM_LOW)
cg.sample();
end
else
`uvm_error("SB",$sformatf("ERROR! %b + %b = %b", sb_item.a, sb_item.b, sb_item.c), UVM_LOW)
endfunction
// env class
...
task run_phase(uvm_phase phase);
sb.cg.stop();
phase.raise_objection(this);
sb.cg.start();
seq.start(sqr);
phase.drop_objection(this);
sb.cg.stop();
`uvm_info("env",$sformatf("The coverage collected is %f",sb.cg.a.get_coverage()),UVM_LOW);
endtask
...
当我运行代码时,我得到了大约 81 的覆盖率。结果如下所示
# KERNEL: UVM_INFO /home/runner/monitor.sv(56) @ 996: uvm_test_top.env.sb [SB] OK!
# KERNEL: UVM_INFO /home/runner/env.sv(34) @ 996: uvm_test_top.env [env] The coverage collected is 85.937500
# KERNEL: UVM_INFO /home/build/vlib1/vlib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 996: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
# KERNEL: UVM_INFO /home/build/vlib1/vlib/uvm-1.2/src/base/uvm_report_server.svh(855) @ 996: reporter [UVM/REPORT/SERVER]
# KERNEL: --- UVM Report Summary ---
# KERNEL:
# KERNEL: ** Report counts by severity
# KERNEL: UVM_INFO : 204
# KERNEL: UVM_WARNING : 0
# KERNEL: UVM_ERROR : 0
# KERNEL: UVM_FATAL : 0
# KERNEL: ** Report counts by id
# KERNEL: [Driver] 100
# KERNEL: [RNTST] 1
# KERNEL: [SB] 100
# KERNEL: [TEST_DONE] 1
# KERNEL: [UVM/RELNOTES] 1
# KERNEL: [env] 1
# KERNEL:
# RUNTIME: Info: RUNTIME_0068 uvm_root.svh (521): $finish called.
# KERNEL: Time: 996 ns, Iteration: 61, Instance: /top, Process: @INITIAL#14_0@.
# KERNEL: stopped at time: 996 ns
# VSIM: Simulation has finished. There are no more test vectors to simulate.
exit
# FCOVER: Covergroup Coverage data has been saved to "fcover.acdb" database.
# VSIM: Simulation has finished.
谁能解释我在这里犯了什么错误?覆盖范围是否在所有运行中累积?