How the Percentage Is Computed
Compute a covergroup's number by hand: coverpoints, transition bins, crosses, the weighted average and the type number.
You Will Be Able To
- Compute a coverpoint's coverage with user bins, automatic bins, transition bins and empty bins.
- Compute a cross's coverage from its user bins, exclusions and remaining automatic bins.
- Combine items into a covergroup number, and instances into a type number, by weight.
- List the reasons two tools can print different numbers for the same model.
- Lesson
- C26
- Time
- 30 min
- Runs on
- Coverage build
- Check
- 4 questions
Two simulators printed 61.11% and 66.67% for the same covergroup and the same test. Both were right by their own rules: one counted an ignored cross product as a bin and the other did not. A reviewer who could do the arithmetic by hand found the difference in ten minutes.
Each coverpoint
Covered bins over bins, empty bins left out (19.11.1).
Each cross
Covered over user bins plus the automatic bins left (19.11.2).
The covergroup
The weighted average of its coverpoints and crosses (19.11).
The type
The average of instances, or the union of their bins (19.11.3).
A Coverpoint
With user bins, a coverpoint's coverage is covered bins over bins. With automatic bins, the bottom is the smaller of auto_bin_max and 2^M, for M bits (IEEE 1800-2023 19.11.1). In both cases a bin with no value left, for example after ignore_bins, is out of both top and bottom.
- Neutral
- Model
- Data
- Items
Each coverpoint and cross turns its bins into a fraction.
- Instance
The instance averages its items by weight:
get_inst_coverage(). - Type
The type averages or merges the instances:
get_coverage().
Read the diagram as text
- Bins: hit counts, at_least
- Coverpoints: covered / non-empty bins
- Crosses: covered / (Bc + Bu)
- Instance: weighted average of items
- Type: average or union of instances
- Bins → Coverpoints
- Bins → Crosses
- Coverpoints → Instance: option.weight
- Crosses → Instance: option.weight
- Instance → Type: merge_instances
IEEE 1800-2023 19.11, 19.11.1, 19.11.2 and 19.11.3, in that order.
| Coverpoint | Bins in the number | Sample | Coverage |
|---|---|---|---|
3 bits, auto_bin_max = 4, ignore {0} | <1>, <2,3>, <4,5>, <6,7>: 4 | 1 | 1/4 = 25% |
3 bits, auto_bin_max = 4, ignore {0,1} | <2,3>, <4,5>, <6,7>: 3 | 2 | 1/3 = 33.33% |
bins big = {[8:15]} on 3 bits, nothing else | none: denominator 0 | any | left out of the covergroup |
Ignoring a value only removes a bin when it empties it.
Transition Bins
Transition bins are bins of their coverpoint like any other. They share its denominator, and a cross on that coverpoint includes them (19.11.1, 19.6.1). When a cross bin is selected through a transition bin, its last value counts.
A Cross
For a cross (19.11.2), Bu is the number of user bins that count: not ignore or illegal bins. Bb is the number of products all user-defined bins take, ignore and illegal included. Bc, the automatic bins left, is the product of the coverpoints' bin counts minus Bb. Coverage is covered bins over Bc + Bu.
| Cross of two 4-bin coverpoints | Bu | Bb | Bc | Bins |
|---|---|---|---|---|
| no user bins | 0 | 0 | 16 | 16 |
ignore_bins on a = 0 | 0 | 4 | 12 | 12 |
bins one = a=1, ignore_bins b=1 | 1 | 7 | 9 | 10 |
| two user bins, a = 0 and b = 0 | 2 | 7 | 9 | 11 |
Products taken by an ignore never come back as automatic bins. A user bin is one bin, however many products it holds.
The Covergroup and the Type
A covergroup instance is the weighted average of its items (19.11). With merge_instances 0, the type number is the average of the instances, weighted by option.weight. With 1, it is the coverage of the union of their bins, matched by name (19.11.3).
When instances are merged, a bin is covered only when its total hits reach the largest at_least of all instances (19.11.1).
| Merged type, instances with at_least 1 and 2; hits: x one, x two, y two | Standard (19.11.1) | Coverage build (measured) |
|---|---|---|
| type number | one has 1 hit of the 2 needed: 50.00% | 100.00% |
Standard behaviour, not run correctly on this build. Scenario cov-089 in docs/sva-standard-traces/CG.md.
When the Denominator Is Zero
An item whose bins are all empty has a denominator of 0. It drops out of its covergroup. Called on its own, it returns 0.0 if its weight is nonzero and 100.0 if it is zero. The same rules hold for a covergroup whose items all drop out or all weigh 0 (19.11, 19.11.1, 19.11.2).
Why Tools Print Different Numbers
The formulas are fixed, but tools differ in which constructs they support and in a few counting details. The table lists what this course measured on the coverage build. Each row is a lesson section with the standard's number beside the tool's.
| Construct | Lesson | Effect on the number |
|---|---|---|
| declared coverpoint type | C11 | ignored: values keep the expression's type |
| open real bin arrays, tolerance ranges | C12 | 0% or a compile error |
| range in a transition; a bin counted twice in one sample | C15 | compile error; too many hits |
| bare-variable cross; cross set expression; cross_retain_auto_bins | C17 | 0%; bin ignored; option ignored |
| covergroup-level or argument at_least | C23 | ignored: one hit covers a bin |
| distribute_first, strobe | C25 | ignored |
| largest at_least over merged instances | C26 | not applied |
Measured on Verilator master b8e7f1e, 2026-11-12 (tools/probes/cov-w1/probes.mjs).
When two tools disagree, compute the number by hand for a small sample list. The difference usually points at one construct in this table.
Try It
k has 2 of 3 bins. l has 4 bins, three value bins and grew; 1 then 3 covers one, few and grew: 3 of 4, with weight 2. The cross has 3 x 4 = 12 products; the ignore takes cfg with few, many and grew, leaving 9. The samples hit <rd, one>, <wr, few> and <wr, grew>: 3 of 9.
(66.67 + 2 x 75 + 33.33) / 4 = 62.5%. Remove the weight on l and predict the new number.
62.50%Check Yourself
Common Mistakes
Wrong Average the percentages of coverpoints by hand without their weights.
A weight other than 1 changes the result, and weight 0 removes an item entirely.
Fix Multiply each item by its weight and divide by the sum of the weights.
Wrong Count ignored cross products as cross bins.
They are part of Bb: they leave the cross and do not come back as automatic bins.
Fix Subtract every product a user, ignore or illegal bin takes, then add the counting user bins.
Wrong Compare type numbers from tools without checking merge_instances.
An average and a union of the same instances can differ a lot.
Fix Say which method the plan wants and set type_option.merge_instances to match.
Remember
- Coverpoint coverage is covered over non-empty bins; automatic bins use min(auto_bin_max, 2^M).
- Transition bins share their coverpoint's denominator and take part in crosses.
- Cross coverage is covered over Bc + Bu, with Bc the products no user-defined cross bin takes.
- A covergroup is the weighted average of its items; the type is the average or the union of instances.
- Zero denominators drop out; all-zero item weights give 0.0 (100.0 if the covergroup weight is 0 too).