VLSI DV Interview Puzzles · All levels

Weighted aggregate coverage math

Compute cp_opcode coverage, cp_size coverage, and weighted group coverage.

Puzzle

Difficulty: Hard · Puzzle 2 of 6 · Topic: Coverage Options Puzzles

Compute cp_opcode coverage, cp_size coverage, and weighted group coverage.

Code

systemverilog
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);
end

Hint

First compute each coverpoint percentage, then apply weighted average by option.weight.

Step-by-step solution

diagram
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

Answer: cp_opcode = 50%, cp_size = 100%, weighted aggregate = 62.5%.

Why candidates get it wrong

Teams sometimes average percentages unweighted and report 75%, which is wrong when weights differ.

Interviewer follow-up

If cp_size weight is changed to 0, what aggregate would be reported?

Related topics