Explicit bin creation is recommended method. Not all values are interesting or relevant in a cover point, so when the user knows the exact values he is going to cover, he can use explicit bins. You can also name the bins.
program main;
bit [0:2] y;
bit [0:2] values[$]= '{3,5,6};
covergroup cg;
cover_point_y : coverpoint y {
bins a = {0,1};
bins b = {2,3};
bins c = {4,5};
bins d = {6,7};
}
endgroup
cg cg_inst = new();
initial foreach(values[i])
begin y = values[i];
cg_inst.sample();
end
endprogram
In the above example, bins are created explicitly. The bins are named a,b,c and d.
cg cg_inst = new();
initial foreach(values[i])
begin y = values[i];
cg_inst.sample();
end
endprogram
In the above example, variable y is 4 bit width vector. Total possible values for this vector are 16.
But in the cover point bins, we have giving the interested range as 0 to 7. So the coverage report is calculated over the range 0 to 7 only. In this example, we have shown the number bins to be fixed to size 4.
The default specification defines a bin that is associated with none of the defined value bins. The default bin catches the values of the coverage point that do not lie within any of the defined bins. However, the coverage calculation for a coverage point shall not take into account the coverage captured by the default bin.
program main;
bit [0:3] y;
bit [0:2] values[$]= '{3,5,6};
covergroup cg;
cover_point_y : coverpoint y {
bins a[2] = {[0:4]};
bins d = default;
}
endgroup
cg cg_inst = new();
initial foreach(values[i])
begin y = values[i];
cg_inst.sample();
end
endprogram
In the above example, we have specified only 2 bins to cover values from 0 to 4. Rest of values are covered in default bin ~Sd~T which is not using in calculating the coverage percentage.