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.

Reserved codes hold the number down
0123legal codes seen4812no exclusions255075reserved ignored33.3366.67100stuck at 75% without exclusions
Scroll horizontally ↔

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.

q[2] = {[0:3]} with ignore_bins {0, 1}Arrows show the order of the two steps: the values are dealt into two bins, then the ignored values are removed.
  • Neutral
  • Result
  • Data
  • Control
CallValueReturnWaiting
q[2] = {[0:3]} with ignore_bins {0, 1}Arrows show the order of the two steps: the values are dealt into two bins, then the ignored values are removed. neutral Values 0 to 3 B = 4 / 2 = 2 neutral q[0] 0, 1 neutral q[1] 2, 3 neutral ignore_bins removes 0 and 1 result Coverage q[1] only dealdealempties
  1. neutral Values 0 to 3B = 4 / 2 = 2
    • deal → q[0]
    • deal → q[1]
  2. neutral q[0]0, 1
  3. neutral q[1]2, 3
    • Coverage
  4. neutral ignore_binsremoves 0 and 1
    • empties → q[0]
  5. result Coverageq[1] only
  1. Deal first

    Two values per bin: q[0] gets 0 and 1, q[1] gets 2 and 3.

    Follow the calls, values and waits
    1. data 0 1: Values 0 to 3 → q[0]
    2. data 2 3: Values 0 to 3 → q[1]
  2. Then remove

    The ignored values 0 and 1 leave q[0] empty. They are not dealt again.

  3. 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).

KindIn the number?A sample that hits it
binsyescounts toward the bin
ignore_binsnonothing happens
illegal_binsnoa run-time error; wins over any other bin
bins x = defaultnocounted 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.

UseWhen the value isWhat you get when it appears
ignore_binspossible but uninteresting, or impossible by constructionnothing
illegal_binsa sign the stimulus itself is brokenan error from the covergroup, at the sample
an assertiona design or protocol rulea 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.

RUNVerilator (coverage build) · simulator service
Edit the code, then run it
Expected: op=0: 33.33% op=5: 66.67% op=13: 66.67% op=9: 100.00%

Check Yourself

Predict the outputThis is the standard's own example of exclusions on automatic bins. Predict the exact output.
module tb;
  bit [2:0] v;
  covergroup cg;
    coverpoint v { option.auto_bin_max = 4; ignore_bins ig = {[0:1], [5:6]}; }
  endgroup
  cg c = new;
  initial begin
    v = 2; c.sample();
    v = 4; c.sample();
    v = 5; c.sample();
    $display("%0.2f%%", c.get_inst_coverage());
  end
endmodule
ConceptA value is listed in both ignore_bins ig = {3}; and illegal_bins bad = {3};. What does sampling 3 do?
ConceptWhy can ignore_bins leave a fixed-count bin array with fewer bins than its [N]?
ConceptWhich value belongs in illegal_bins rather than ignore_bins?

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.

Before
illegal_bins reserved = {[12:15]};
After
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_bins removes values from every bin; sampling them does nothing.
  • illegal_bins removes 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.

Practice

Report a problem with this page