Difficulty: Medium · Puzzle 5 of 6 · Topic: Coverage Options Puzzles
A teammate sets option.auto_bin_max = 2 on cp_addr hoping to keep the bin count small, but the coverpoint also lists bins. Find the real number of scored bins and the percentage. Options set: option.auto_bin_max = 2 on cp_addr (at_least = 1, weight = 1). Values that fall in no bin are simply not counted.
covergroup cg with function sample(bit [5:0] addr);
cp_addr: coverpoint addr {
option.auto_bin_max = 2;
bins low_page[4] = {[0:15]};
bins top = {63};
}
endgroup
initial begin
cg c = new();
c.sample(0);
c.sample(5);
c.sample(40);
c.sample(63);
endauto_bin_max only sizes the automatic bins that a coverpoint gets when it lists no bins of its own.
1) The coverpoint lists explicit bins, so no automatic bins are created and auto_bin_max = 2 has no effect.
2) low_page[4] splits 0..15 into 4 bins of 4 values: [0:3], [4:7], [8:11], [12:15]. top is 1 more bin -> 5 scored bins.
3) Samples: 0 hits low_page[0], 5 hits low_page[1], 63 hits top. 40 is in no bin and is ignored (there is no default bin).
4) 3 of 5 bins hit -> 3/5 = 60%.Answer: 5 bins are scored (4 from low_page[4] plus top) and coverage is 60%. auto_bin_max = 2 does nothing here; sample 40 counts for nothing.
Checked by running a model of the rule in a Python model. A model of the bin rule: explicit bins mean no auto bins, so there are 5 scored bins and 3 are hit.
Expecting auto_bin_max = 2 to give 2 bins (or to regroup the explicit bins). The option only governs automatic bins; the moment you write bins, you own the bin list, and an unlisted value such as 40 is silently dropped rather than flagged.
If you delete both bins lines and set option.auto_bin_max = 4, what is the percentage with the same samples? Model answer: Without explicit bins the 64 values are split into 4 automatic bins of 16: [0:15], [16:31], [32:47], [48:63]. Samples 0 and 5 hit the first, 40 the third and 63 the fourth, so 3/4 = 75%.
I would notice the coverpoint lists explicit bins, so auto_bin_max does nothing. Five bins are scored, four from the low_page array plus top, and coverage is 60 percent. The sample 40 falls in no bin and is silently dropped. The trap is expecting two bins from auto_bin_max, so I would check whether an unlisted value like 40 should be a bin or an error.