covergroup CovPort;
options.auto_bin_max = 8; //所有的coverpoint auto_bin数量是8
coverpoint tr.port
{ option.auto_bin_max = 2} //特定的covepoint auto_bin数量2
endgroup
covergroup CovKind;
coverpoint tr.kind{
bins zero = {0}; //1个仓代表kind==0
bins lo = {[1:3] , 5}; //1个仓代表1:3和5
bins hi[] = {[8:$]}; //8个独立的仓代表8:15
bins misc = default; //1个仓代表剩余所有值
} //没有分号
endgroup
注意coverpoint定义使用{ }而不是begin...end大括号结尾没带分号,和end一样。
covergroup CoverPort;
coverpoint port iff
(!bus_if.reset); //满足条件才可以采样
endgroup
initial begin
CovPort ck = new();
#1ns;
ck.stop(); //关掉,任何采样都不起作用
bus_if.reset = 1;
#100ns bus_if.reset = 0;
ck.reset();
...
end
针对任何一个covergoup实例,都可以进行使能采样。 不同的coverpoint可以设置if的条件。
covergroup CoverPort;
coverpoint port{
(bins t1 = (0 => 1),(0 => 2),(0 => 3));
}
endgroup
bit [2:0] port;
covergroup CoverPort;
coverpoint port{
wildcsrd bins even = {3'b??0};
wildcsrd bins odd= {3'b??1};
}
endgroup
bit [2:0] low_ports_0_5; //只使用数值0-5
covergroup CoverPort;
coverpoint low_ports_0_5{
ignore_bins hi = {[6:7]}; //忽略数值6-7
}
endgroup
bit [2:0] low_ports_0_5; //只是用数值0-5
covergroup CoverPort;
coverpoint low_ports_0_5{
illegal_bins hi {[6:7]}; //如果出现6-7便会报错
}
endgroup
class Transaction;
rand bit [3:0] kind;
rand bit [2:0] port;
endclass
Transaction tr;
covergroup CovPort;
kind: coverpoint tr.kind;
kind: coverpoint tr.port;
cross kind, port;
endgroup
covergroup Covport;
port: coverpoint tr.port
{bins port[] = {[0:$]}; //0-8个bin
}
kind:coverpoint tr.kind { //kind11个bin
bins zero = {0};
bins lo = {[1:3]};
bins hi[] = {[8:$]};
bins misc = default;
}
cross kind, port{
ignore_bins hi = binsof(port) intersect{7}; 对于port来说为7时和kind所有组合都排除
ignore_bins md = binsof(port) intersect{0} && binsof(port) intersect{9:11};
ignore_bins lo = binsof(kind.lo) ;
}
endgroup
class Transaction;
rand bit a,b;
endclass
covergroup CrossBinName;
a: coverpoint tr.a
{bins a0 = {0};
bins a1 = {1};
option.weight = 0;} //不计算覆盖率
b: coverpoint t.b
{ bins b0 = {0};
bins b1 = {1};
option.weight = 0;} //不计算覆盖率
ab: cross a,b
{ bins a0b0 = binsof(a.a0) && binsof(b.b0); //指定一个状态
binsof(b.b0);
bins a1b0 = binsif(a.a1) && binsof(b.b0);
bina b1 = binsof(b.b1);}
endgroup
————————————————
版权声明:本文为CSDN博主「胡九筒」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Jay_who/article/details/105900815