ignore_bins and illegal_bins
Remove values from the number with ignore_bins, make forbidden values errors with illegal_bins, and know when to assert instead.
You Will Be Able To
- Exclude values that cannot or need not happen with
ignore_bins, and predict the new number. - Mark values that must never happen with
illegal_bins, and say what a hit does. - Explain why exclusions are applied after values are dealt into bins.
- Choose between ignore, illegal and an assertion for a forbidden value.
- Lesson
- C14
- Time
- 25 min
- Runs on
- Coverage build
- Check
- 4 questions
An opcode coverpoint on a 4-bit field sat at 75% for a whole project. Four of its sixteen codes were reserved and never sent. Someone finally marked all four illegal_bins. That night the regression stopped in its first minute, because code 12 was reserved for a debug command the tests did use.
One column per regression milestone. Sixteen automatic bins can never pass 75% when four codes are never sent.
ignore_bins Takes Values Out
ignore_bins name = {set}; removes its values from every bin of the coverpoint (IEEE 1800-2023 19.5.5). Sampling an ignored value does nothing. A bin left with no values drops out of the number.
It works on automatic bins too. A 3-bit coverpoint with ignore_bins never = {7}; has seven bins, so sampling 0 to 6 gives 100%.
Exclusions Come After the Bins Are Dealt
Values are dealt into [N] and automatic bins first; ignored and illegal values are removed afterwards (19.5.5, 19.5.6). An exclusion therefore never moves a value into another bin. It can only empty one.
- Neutral
- Result
- Data
- Control
- Deal first
Two values per bin: q[0] gets 0 and 1, q[1] gets 2 and 3.
Follow the calls, values and waits
- data 0 1: Values 0 to 3 → q[0]
- data 2 3: Values 0 to 3 → q[1]
- Then remove
The ignored values 0 and 1 leave q[0] empty. They are not dealt again.
- Count what is left
Only q[1] counts. A sample of 2 makes the coverpoint 100%.
Read the diagram as text
- Values 0 to 3: B = 4 / 2 = 2
- q[0]: 0, 1
- q[1]: 2, 3
- ignore_bins: removes 0 and 1
- Coverage: q[1] only
- Values 0 to 3 → q[0]: deal
- Values 0 to 3 → q[1]: deal
- ignore_bins → q[0]: empties
- q[1] → Coverage
Had the ignore come first, 2 and 3 would have been dealt into two bins of one value each.
illegal_bins Turns a Value into an Error
illegal_bins name = {set}; also removes its values from the number. In addition, a sample that hits one is a run-time error. Illegal bins take precedence: the error fires even when another bin, or an ignore_bins, also holds the value (IEEE 1800-2023 19.5.6).
| Kind | In the number? | A sample that hits it |
|---|---|---|
bins | yes | counts toward the bin |
ignore_bins | no | nothing happens |
illegal_bins | no | a run-time error; wins over any other bin |
bins x = default | no | counted in x, outside the number |
The four ways a value can be declared in a coverpoint.
Ignore, Illegal or an Assertion?
All three say "this value is not part of the plan". They differ in what happens when it shows up.
| Use | When the value is | What you get when it appears |
|---|---|---|
ignore_bins | possible but uninteresting, or impossible by construction | nothing |
illegal_bins | a sign the stimulus itself is broken | an error from the covergroup, at the sample |
| an assertion | a design or protocol rule | a failure with the time, the signals and a message |
Checking belongs in assertions and scoreboards. illegal_bins is a last line of defence.
A forbidden value that the design might produce is a checking question. Write an assertion: it reports at the right time, with context. Keep illegal_bins for values the stimulus must never create, where an error at the sample is exactly the alarm you want.
Try It
The four groups are dealt first. Removing 12 to 15 empties grp[3], so three bins remain. The reserved 13 changes nothing.
If the bench ever sent 15, the run would stop at that sample. Change illegal_bins kill to ignore_bins and predict the output for the same samples.
op=0: 33.33% op=5: 66.67% op=13: 66.67% op=9: 100.00%Check Yourself
Common Mistakes
Wrong Mark every value the plan does not need as illegal_bins.
A legal but unplanned value then stops the run with an error.
Fix Ignore values that do not matter; make only stimulus-breaking values illegal.
illegal_bins reserved = {[12:15]};ignore_bins reserved = {[12:14]};
illegal_bins kill = {15};Wrong Narrow a range to leave values out, as in bins grp[4] = {[0:11]};.
The values are dealt again, so every group changes size.
Fix Keep the range and remove values with ignore_bins, which never re-deals.
Wrong Use illegal_bins as the only check for a design rule.
It reports at the sample, without the time and signals a debug needs, and only where the covergroup samples.
Fix Check design rules with an assertion; keep coverage for "did it happen".
Remember
ignore_binsremoves values from every bin; sampling them does nothing.illegal_binsremoves values and makes a hit a run-time error, ahead of any other bin.- Exclusions are applied after values are dealt, so they can empty a bin but never move a value.
- An empty bin drops out of the coverage number.
- Design rules belong in assertions; illegal bins are an alarm for broken stimulus.