Cover group

module def_cov_point;

class trx;
rand bit [2:0]a;
rand bit [3:0]b;


endclass


covergroup c;
  ADDRESS : coverpoint tr.a+tr.b{
    // This should create 11 bins
    bins low[]          = {[0:10]};
    // This should create 10 bins
    bins med[]         = {[11:20]};
  }

endgroup
trx tr;
c c1;

initial begin 
tr = new;
c1 = new;
repeat(10) begin 
tr.randomize();
c1.sample();

end

end
endmodule

here in this code, onlky 15 bins are getting created why not 20 bins as specified in code?

In reply to rakesh reddy:

tr.a+tr.b will be converted to 4 bit output. so 16 bins max.

In reply to kranthi445:

But these 2 lines
bins low = {[0:10]};
// This should create 10 bins
bins med = {[11:20]};
are used to create 20 bins not 16 bins

*In reply to rakesh reddy:*Because the bin values 17, 18, 19, and 20 are eliminated because they are out-of-bounds for the range specified.

In reply to rakesh reddy:

bins med= [{11:20}]; will create bins from [{11:15}] bins 16,17,18,19,20 are eliminated because your 4bit output can not hold values of 16,17,18,19,20.

bins low={[0:11]} // this will create 11 bins 0 to 10
bins med=[{11:20}] // this will create 5 bins 11 to 15

Hi Dave,

i am adding a 3 bit number and a 4 bit number, so effective number of bins will be 16.but adding a 4 bit and 3 bit number may result in 5 bit number (Eg: 15+8 = 23 which is maximum possible result)
So i need to create 23 bins
So bins len = {[0:22]}
can be used to create 23 bins
Is this Correct?

*In reply to rakesh reddy:*Except that according to the 1800-2012 LRM table 11-21, the length of a + b is max(L(a),L(b)) in a self-determined context. You need to write

  ADDRESS : coverpoint 5'(tr.a+tr.b) {
    // This should create 11 bins
    bins low[]          = {[0:10]};
    // This should create 10 bins
    bins med[]         = {[11:20]};
  }

In reply to dave_59:
if i do this then 32 bins are created i need only 23 bins

In reply to rakesh reddy:

use
options.auto_bin_max=24

In reply to kranthi445:

See the following example from LRM


bit [9:0] v_a; 
covergroup 
cg @(
posedge 
clk);
coverpoint
 v_a
{
bins 
a = { [0:63],65 };
bins b[] = { [127:150],[148:191] };    // note overlapping values
bins c[] = { 200,201,202 };
bins d = { [1000:$] }; 
bins others[] = 
default;
}
endgroup

In the example above, the first
bins
construct associates bin awith the values of variable v_abetween 0 and63, and the value 65. The second binsconstruct creates a set of 65 bins b[127], b[128],…b[191]. Like-wise, the third bins construct creates 3 bins: c[200], c[201], and c[202].
The fourth bins construct asso-ciates bin d with the values between 1000 and 1023 ($ represents the maximum value of v_a).
Every value thatdoes not match bins a, b, c, or d
is added into its own distinct bin

In this way i also want to create 23 bins but it is not happening

In reply to rakesh reddy:
Can you show the code again? I get 21 bins (values 0-20)

In reply to dave_59:

module def_cov_point;
 
class trx;
rand bit [2:0]a;
rand bit [3:0]b;
 
 
endclass
 
 
covergroup c;
  ADDRESS : coverpoint tr.a+tr.b{
    // This should create 11 bins
    bins low[]          = {[0:10]};
    // This should create 10 bins
    bins med[]         = {[11:20]};
  }
 
endgroup
trx tr;
c c1;
 
initial begin 
tr = new;
c1 = new;
repeat(10) begin 
tr.randomize();
c1.sample();
 
end
 
end
endmodule

In reply to rakesh reddy:

But you didn’t add the cast as I said my post.