---------------断言检查写在testbench中或RTLcode中、或单独assert()括号中为1;
APBACTIVE:用来控制APB时钟的开断;
如果psel为高判断同一时刻APBACTIVE也为高;(但是APBACTIVE一直为高也符合要求)
property p_psel_high_then_apbactive_high;
@(posedge pclk) disable iff(!hresetn)
apb_if_i.psel |-> apbactive;
endproperty
如果APBACTIVE上翻为高,则下一个周期psel必须为高;
property p_apbactive_high_then_psel_high;
@(posedge pclk) disable iff(!hresetn)
$rose(apbactive) |=> apb_if_i.psel;
endproperty
断言检查hresp_hready两个信号的关系:当想回应error时,hresp为高的同一个周期hready为高,且前一个周期hready为低;
property p_hresp_hready;
@(posedge hclk) disable iff(!hresetn)
ahbl_if_i.hresp |-> ahbl_if_i.hready && !$past(ahbl_if_i.hready);
endproperty
assert:
a_psel_high_then_apbactive_high: assert property(p_psel_high_then_apbactive_high);
a_apbactive_high_then_psel_high: assert property(p_apbactive_high_then_psel_high);
a_hresp_hready : assert property(p_hresp_hready);
----------------覆盖率:文件在env下func_cov.sv
代码覆盖率(目标是DUT代码):对整个测试过程中被执行的代码的衡量,它能测量源代码中的哪些语句在测试中被执行,哪些语句尚未被执行。高百分比的代码覆盖率不等于高质量的有效测试。通常很难100%,比如一些冗余设计,错误状态触及不到;(block代码块运行了多少、toggle每个变量上下翻转了没有)
功能覆盖率:判断有没有实现想要的功能点;力争100%
——在env中定义的的cov:判断ahb传过来的pkt,各个操作是不是都有组合做过;HSIZE3种,HBUTST8种,HWRITE2种,是不是都组合检测过,以及haddr的边界值和中间随机区域分成四块;
class func_cov extends uvm_object;
covergroup cg with function sample(ahbl_tran ahb_pkt,apb_tran apb_pkt);
option.per_instance = 1;
//haddr的边界值有没有读到
haddr:coverpoint ahb_pkt.haddr[15:0] {bins a1 = {16'h0000};
bins a2 = {16'h0001};
bins a3 = {16'h0002};
bins a4 = {16'h0003};
bins a5 = {16'hffff};
bins a6 = {16'hfffe};
bins a7 = {16'hfffd};
bins a8 = {16'hfffc};
bins a9[4] = {[16'h0004:16'hfffb]};//把中间的随机区域分为4块看有没有命中
}
hwrite:coverpoint ahb_pkt.hwrite;
hburst:coverpoint ahb_pkt.hburst;
hsize :coverpoint ahb_pkt.hsize;c
//四个coverpoint cross在一起判断是否组合过
cross haddr,hwrite,hburst,hsize;
endgroup
function new(string name="func_cov");
super.new(name);
cg=new();
cg.set_inst_name({get_full_name,".",name,".cg"});
endfunction
endclass
例化在scb中:因为信息总会到达scb中检测;在check_pkt循环中不断调用sample观测;
func_cov fcov;
fcov = new("fcov");build phase例化;
fcov.cg.sample(ahb_pkt,apb_pkt);check_pkt循环中不断调用sample观测
——在tb中使用cov:直接在tb的module中定义
检查HCLK_PCLK各个比率是否都随机到;因为比率在仿真刚开始就去确定了,所以在每次松开reset时监测就可以;当随机跑了很多次后merge就可以收集到这个覆盖率;
covergroup cg_hclk_pclk_ratio();
option.per_instance = 1;
option.name = "cg_hclk_pclk_ratio";
hclk_pclk_ratio: coverpoint HCLK_PCLK_RATIO[3:0] {
bins h0 = {4'h1};
bins h1 = {4'h2};
bins h2 = {4'h4};
bins h3 = {4'h8};}
endgroup
always@(posedge hresetn)begin
cg_hclk_pclk_ratio_i.sample();
end