How to implement transition coverage on non consecutive sampling points

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.

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

In reply to rgarcia07:

Hi Garcia,

In your example, you are changing the value after each sampling condition. So you are hitting the transition coverage. But in my case, the value might not change after each sample. I do see that the values are coming in order from 0 to 15.

Thanks.

In reply to sj1992:

So that means you have a stimulus problem you are not providing the “right” test or sequencing.
I’m assuming you are randomizing things so it will be “difficult” to hit that specific condition/pattern.
-R

In reply to rgarcia07:

Hi,

The issue is that the value does not change constantly at each sampling point. I sample at every posedge of clk but there is a iff clause to my coverpoint where I check the cover bins. Since the bins are getting hit at non-consecutive sampling point the transition bin is not getting covered.

Thanks.

In reply to sj1992:

You last comment is hard to understand without more details. You should be able to create an iff clause for the bin that is true only when var_1 transitions using $changed.

There is no transition bin syntax that allows for indefinite repetition. A cover directive has much more expressive syntax and would be much more scalable. But it requires a whole new area of learning SystemVerilog.

Also, you are not supposed to be using a covergroup as a checker, if this is just a counter, knowing that it had all the values 0-15 should be good enough for coverage.

Note that the iff clause needs to be on the sampling event clock, not on the coverpoint or bin.
See 0004735: There is no clear definition of how iff should behave for coverpoint with transition bins or for transition bin itself - Accellera Mantis