hisingh
1
Hi All,
I want to create bin for coverage with below requirements
- Requirement 1
Let take a variable bit [n-1:0] xyz.
Where n can vary from 1-20.
Bins will be like for n = 3
bin1 = {0,1};
bin2 = {2,3};
bin3 = {4,5,6,7};
- Requirement 2
Transition coverage of ranges for above xyz
bin1 = (0,1 => 2,3);
bin2 = (2,3 => 4,5,6,7);
Note - Based on parameter “n” I want to generate coverbins.
Looking for a generic solution.
Thanks
dave_59
2
In reply to hisingh:
This can be done by creating an array of covergroups.
let range(v,i) = v inside { [(i==0 ? 0: 2**i):2**(i+1)-1]}; // '?:' fix so 2**0 is 0
covergroup m(int I, ref cp);
req1: coverpoint range(cp,I) {
bins hit = {1};
}
req2: coverpoint {range(cp,I),range(cp,I+1} {
bins hit = (2'b10 => 2'b01);
endgroup
m cg[n];
foreach(cg[i]) cg[i] = new(i,xyz);
Just realized that you will need another fix so that req2 has one less coverpoint when I=N-1.
In reply to dave_59:
Can you please elaborate range(v,i). If its function or struct or any keyword?
In reply to hisingh:
The let construct is almost like a macro, but with more formal semantics. See section 11.12 Let construct in the IEEE 1800-2017 SystemVerilog LRM