VLSI DV Interview Puzzles · All levels

illegal_bins vs ignore_bins accounting

Compute legal coverage and classify each sampled value as legal, ignored, or illegal.

Puzzle

Difficulty: Medium · Puzzle 5 of 6 · Topic: Covergroup and Coverpoint Puzzles

Compute legal coverage and classify each sampled value as legal, ignored, or illegal.

Code

systemverilog
covergroup cg with function sample(bit [3:0] req_len);
  cp_len: coverpoint req_len {
    bins short = {[1:4]};
    bins long  = {[5:8]};
    ignore_bins keepalive = {0};
    illegal_bins too_big  = {[9:15]};
  }
endgroup

initial begin
  cg c = new();
  c.sample(0);
  c.sample(3);
  c.sample(6);
  c.sample(10);
  c.sample(2);
  c.sample(15);
end

Hint

Only short and long are legal scored bins in the denominator.

Step-by-step solution

diagram
1) Legal bins are short and long -> denominator 2.
2) Hits: short hit by 3 and 2, long hit by 6.
3) Value 0 is ignored (keepalive), values 10 and 15 are illegal.
4) Legal coverage is 2/2 = 100% with two illegal hits logged.

Answer

Answer: Legal coverage is 100% (short and long both hit). Sample classification: ignored={0}, illegal={10,15}, legal={3,6,2}.

Why candidates get it wrong

Ignore and illegal activity can be present even when legal coverage is 100%, so closure does not imply protocol correctness.

Interviewer follow-up

Would you keep too_big as illegal_bins or move it to assertions for better debug diagnostics?

Related topics