Difficulty: Medium · Puzzle 1 of 6 · Topic: Coverage Options Puzzles
Compute final percentages for each coverpoint. Options set: cp_addr has option.auto_bin_max = 4 (at_least stays 1); cp_err has option.at_least = 3 (weight stays 1).
covergroup cg with function sample(bit [3:0] addr, bit err);
cp_addr: coverpoint addr {
option.auto_bin_max = 4;
}
cp_err: coverpoint err {
option.at_least = 3;
bins zero = {0};
bins one = {1};
}
endgroup
initial begin
cg c = new();
c.sample(0, 0);
c.sample(1, 1);
c.sample(2, 0);
c.sample(15,1);
c.sample(8, 1);
endaddr values are grouped into 4 auto bins; err bins need at least 3 hits each.
1) cp_addr has 4 grouped bins over 0..15.
2) Samples hit groups 0..3, 8..11, and 12..15 -> 3/4 = 75%.
3) cp_err counts are zero=2 and one=3.
4) With at_least=3, only one bin is covered -> 1/2 = 50%.Answer: cp_addr = 75%, cp_err = 50%.
Checked by running a model of the rule in a Python model. A model of the option rules: auto_bin_max = 4 groups 16 values into 4 bins, and at_least = 3 leaves one bin covered.
A touched bin is not covered until it meets threshold. Grouped auto bins also change denominator intuition.
How many additional err=0 samples are required to make cp_err reach 100%? Model answer: One. zero has 2 hits and needs 3; one already has 3, so a single extra sample with err = 0 gives 2/2 = 100%.
I would apply each option separately. With auto_bin_max of 4 the address coverpoint has grouped bins, and its result is 75 percent. With at_least of 3 the error coverpoint is 50 percent, because a touched bin is not covered until it meets the threshold. The trap is calling a bin covered after one hit when at_least is higher, so I would check the hit counts per bin.