Hardware interview practice
SystemVerilog Coverpoint Bins Interview Question
How many ordinary bins does legal create?
coverpoint opcode {
bins legal[] = {[0:3]};
illegal_bins bad = default;
}Answer choices
- A. 1
- B. 3
- C. 4
- D. 256
Concise answer
The answer and the key reason
Deeper explanation
Work through the implementation and tradeoffs
Empty array brackets after a bin name tell SystemVerilog to generate an array of coverage bins. With the finite range `[0:3]`, the tool can assign each distinct value to its own element, giving four independently tracked goals. A sample of 0 increments one legal bin, while samples of 1, 2, or 3 increment their respective bins.
The `illegal_bins bad = default` declaration does not add another ordinary bin. It classifies any value left outside the declared legal set as an illegal occurrence. If `legal` were declared without array brackets, the range could instead be collected into one named bin, reducing coverage resolution even though the same four values remain legal.
What to remember
- Four legal bins
- One bin per range value
- Default catches other values
Practice the complete prompt
