Difficulty: Medium · Puzzle 2 of 6 · Topic: Coverage Options Puzzles
Compute cp_opcode coverage, cp_size coverage, and weighted group coverage. Options set: cp_opcode option.weight = 3, cp_size option.weight = 1 (at_least = 1, auto_bin_max default).
covergroup cg with function sample(bit [1:0] opcode, bit size);
cp_opcode: coverpoint opcode {
option.weight = 3;
bins op[] = {[0:3]};
}
cp_size: coverpoint size {
option.weight = 1;
bins s0 = {0};
bins s1 = {1};
}
endgroup
initial begin
cg c = new();
c.sample(0,0);
c.sample(1,1);
c.sample(1,0);
endFirst compute each coverpoint percentage, then apply weighted average by option.weight.
1) cp_opcode has 4 bins (0..3), hit bins are 0 and 1 -> 2/4 = 50%.
2) cp_size has 2 bins, both hit -> 2/2 = 100%.
3) Weighted group coverage = (3*50 + 1*100) / (3+1).
4) Result = 62.5%.Answer: cp_opcode = 50%, cp_size = 100%, weighted aggregate = 62.5%.
Checked by running a model of the rule in a Python model. A model of weighted aggregation: (3*50 + 1*100) / 4 = 62.5%.
Teams sometimes average percentages unweighted and report 75%, which is wrong when weights differ.
If cp_size weight is changed to 0, what aggregate would be reported? Model answer: Only cp_opcode contributes, so the group reports 50%; cp_size still shows 100% on its own line.
I would weight each coverpoint, not average the percentages. The opcode coverpoint is 50 percent with weight 3, and size is 100 percent with weight 1, so the aggregate is 62.5 percent. The trap is the unweighted average of 75 percent. I would next check whether the weights reflect real importance in the plan.