Difficulty: Medium · Puzzle 6 of 6 · Topic: Covergroup and Coverpoint Puzzles
Two coverpoints observe the same signal. Compute both percentages and explain why they differ. Options: none set (all defaults: at_least = 1, weight = 1, auto_bin_max = 64).
covergroup cg with function sample(bit [2:0] mode);
cp_auto: coverpoint mode;
cp_manual: coverpoint mode {
bins legal[] = {[0:5]};
ignore_bins svc = {6,7};
}
endgroup
initial begin
cg c = new();
c.sample(0);
c.sample(1);
c.sample(2);
c.sample(6);
c.sample(7);
endcp_auto on a 3-bit signal has 8 auto bins; cp_manual scores only legal[] bins.
1) cp_auto bins are 0..7 -> 8 bins. Hits are 0,1,2,6,7 -> 5/8 = 62.5%.
2) cp_manual has legal[] over 0..5 -> 6 scored bins. Hits among legal bins are 0,1,2 -> 3/6 = 50%.
3) Samples 6 and 7 are ignored in cp_manual, but counted as valid bins in cp_auto.
4) Note ignore_bins svc is redundant in cp_manual: 6 and 7 are not in legal[] anyway, so they never enter any bin. It documents intent but is not what shrinks the denominator.Answer: cp_auto = 62.5%, cp_manual = 50%. Same samples, different scored bin sets.
Checked by running a model of the rule in a Python model. A model of the scored-bin rule: 8 auto bins give 5/8, while 6 explicit bins give 3/6 on the same samples.
cp_auto scores 6 and 7 as ordinary bins, so the same five samples give 62.5% against 50%. Hits on service modes inflate cp_auto; the explicit legal[] list is what fixes the denominator, not the redundant ignore_bins.
What model is better for signoff if 6 and 7 are service/debug modes excluded by spec? Model answer: The explicit model (cp_manual), because its denominator holds only the six modes the spec requires, so 3/6 = 50% shows real progress. Use ignore_bins (with a spec reference) if they may occur and are not interesting, or illegal_bins if they must never occur.
I would count the scored bins of each coverpoint separately. The auto coverpoint scores 6 and 7 as ordinary bins, so it reports 62.5 percent, and the manual one with an explicit legal list reports 50 percent on the same five samples. The difference is only the denominator and which hits count. The trap is blaming the stimulus, so I would check that the explicit list defines the real legal set.