In reply to sj1992:
Hi,
var_1 changes from value 0 to 1 then from 1 to 2 and so on till 15 but not on consecutive sampling points. I sample on every clock cycle but the value might change after some arbitrary clk cycles. The transition coverage I write does not work. Can we write transition coverage for this case?
bit [3:0] var_1;
var1: coverpoint var_1
{
bins var_1_trans_bin = (0=>1=>2=>3=>4=>5=>6=>7=>8=>9=>10=>11=>12=>13=>14=>15);
bins var_1_bin[] = {[0:15]};
}
I see that the var_1_bin getting covered 100% but not the var_1_trans_bin.
Thanks.
I works for me, but this is very unpractical and non-scalable maybe you can try different approach if you elaborate further on what/why you want to achieve.
module test();
bit [3:0] var_1;
logic [3:0] prev_var_1;
covergroup transition_cg_2;
coverpoint var_1 {
bins var_1_trans_bin = (0=>1=>2=>3=>4=>5=>6=>7=>8=>9=>10=>11=>12=>13=>14=>15);
bins var_1_bin[] = {[0:15]};
}
endgroup
transition_cg_2 cg2 = new();
initial begin
repeat(16) begin
cg2.sample();
$display("prev_var_1 = %0d => var_1 = %0d", prev_var_1, var_1);
prev_var_1 = var_1;
$display("cg2 coverage = %0f", cg2.get_coverage());
var_1++;
end
end
endmodule
KERNEL: prev_var_1 = x => var_1 = 0
# KERNEL: cg2 coverage = 5.882353
# KERNEL: prev_var_1 = 0 => var_1 = 1
# KERNEL: cg2 coverage = 11.764706
# KERNEL: prev_var_1 = 1 => var_1 = 2
# KERNEL: cg2 coverage = 17.647059
# KERNEL: prev_var_1 = 2 => var_1 = 3
# KERNEL: cg2 coverage = 23.529412
# KERNEL: prev_var_1 = 3 => var_1 = 4
# KERNEL: cg2 coverage = 29.411765
# KERNEL: prev_var_1 = 4 => var_1 = 5
# KERNEL: cg2 coverage = 35.294118
# KERNEL: prev_var_1 = 5 => var_1 = 6
# KERNEL: cg2 coverage = 41.176471
# KERNEL: prev_var_1 = 6 => var_1 = 7
# KERNEL: cg2 coverage = 47.058824
# KERNEL: prev_var_1 = 7 => var_1 = 8
# KERNEL: cg2 coverage = 52.941176
# KERNEL: prev_var_1 = 8 => var_1 = 9
# KERNEL: cg2 coverage = 58.823529
# KERNEL: prev_var_1 = 9 => var_1 = 10
# KERNEL: cg2 coverage = 64.705882
# KERNEL: prev_var_1 = 10 => var_1 = 11
# KERNEL: cg2 coverage = 70.588235
# KERNEL: prev_var_1 = 11 => var_1 = 12
# KERNEL: cg2 coverage = 76.470588
# KERNEL: prev_var_1 = 12 => var_1 = 13
# KERNEL: cg2 coverage = 82.352941
# KERNEL: prev_var_1 = 13 => var_1 = 14
# KERNEL: cg2 coverage = 88.235294
# KERNEL: prev_var_1 = 14 => var_1 = 15
# KERNEL: cg2 coverage = 100.000000
Your var_1_bin bin just covers that you had all the values [0:15] in any particular order so you maybe are getting a different sequence than 0,…,15.
HTH,
-R