SV Functional Coverage

How to write a bins for 32 bit variable in system verilog functional coverage?
For e.g we have bit [31:0] data; if we write explicit bins for that then it will have 2**32 possible values.
Can anyone explain this?

1 Like

Creation of bins depends on the specification given and the stimulus you gonna provide on the 32 bit data line as per the SPEC.
For example,

data_cp : coverpoint data {
                           bins low = {[0 : 1023]};
                           bins low_1 = {[1024 : 2047]};
                           ...........
                           ...........
                           bins high = {[2**32 - 1024 : 2**32 - 1]};
                           }

Thank you for answer.
I know this way and I also told to interviewer same answer but he asked me is there any other way to write it.

I believe the option auto_bin_max can be used

data_cp : coverpoint data {
option.auto_bin_max=32;
}

you can try to use wildcard bins. something like this.

wildcard bins bin_min = { 4’b11?? };
wildcard bins bin_med = { 4’b0??? };
wildcard bins bin_max = { 4’b1??? };

Thank You for answer.
But if we do calculation of this it means 2^32 = 4294967296

i.e. 4294967296 / 32 = 134217728

So each bin will be created like this…

[0: 134217727]
[134217727: 268435455]…so on
Total 32 bins will be created.

Do we do like this in real time also?

  • can you please elaborate this for 32 bit variable?