Options That Change the Number
Weight the parts of a covergroup, demand several hits per bin, set goals, and know what per_instance does and does not change.
You Will Be Able To
- Predict a covergroup's number when its coverpoints and crosses have different weights, including weight 0.
- Require several hits per bin with
option.at_least, at the level where the tool honours it. - Say why
option.goalnever changes the number. - Explain what
option.per_instancecontrols, and read per-instance numbers with the right method.
- Lesson
- C23
- Time
- 30 min
- Runs on
- Coverage build
- Check
- 4 questions
A FIFO plan said "fill the FIFO completely at least five times". The covergroup had a full bin that one fill covered. It read 100% after the first fill, and a bug that needed the third fill shipped. A single option.at_least = 5; would have kept that bin open.
One column per time the FIFO fills. With the default of 1, the first fill closes the bin.
option.weight
A covergroup's number is the weighted average of its coverpoints and crosses (IEEE 1800-2023 19.11). Each item's option.weight defaults to 1. An item with weight 0 drops out of both the top and the bottom of the average.
| Items (coverage, weight) | Covergroup |
|---|---|
| a (100%, 1), b (0%, 1) | 50% |
| a (100%, 3), b (0%, 1) | (300 + 0) / 4 = 75% |
| a (100%, 1), b (0%, 0) | 100 / 1 = 100% |
| a, b, cross with weight 2: 100%, 50%, 50% | (100 + 50 + 100) / 4 = 62.5% |
A weight set on the covergroup itself weights whole instances in the type number instead (19.11.3).
- Model
- Data
- Weighted items
Each item adds its coverage times its weight to the top, and its weight to the bottom.
- Weight 0
diradds nothing to either side, so it can never move the number.
Read the diagram as text
- common: 3 of 6, weight 1
- rare: 1 of 2, weight 3
- dir: weight 0
- Covergroup: (50 x 1 + 50 x 3) / 4 = 50%
- common → Covergroup: 50 x 1
- rare → Covergroup: 50 x 3
- dir → Covergroup: left out
The weights decide how much each hole costs in the final number.
If every item has weight 0, the bottom of the average is 0. The method then returns 0.0, or 100.0 if the covergroup's own weight is also 0 (19.11).
option.goal
option.goal is the target percentage for an instance, a coverpoint or a cross, 100 by default (19.7). Report tools compare the number against it. It does not change the number itself.
option.at_least
option.at_least = N; means a bin needs N hits to count as covered (19.7). Set in a coverpoint or cross, it applies there. Set in the covergroup, it is the default for every coverpoint and cross (Table 19-2).
| Where at_least = 2 is set; samples 1, 1, 2 | Standard (19.7) | Coverage build (measured) |
|---|---|---|
| in the coverpoint | one covered, two not: 50.00% | 50.00% |
| in the covergroup | the same default: 50.00% | 100.00%: ignored |
| in the coverpoint, from a covergroup argument | 50.00% | 100.00%: ignored |
The last two rows are standard behaviour, not run on this build (scenarios cov-074 in docs/sva-standard-traces/CG.md and cov-053 in CF.md).
option.per_instance
Every instance contributes to its covergroup type's number. option.per_instance = 1; also asks the tool to keep each instance's own data in the coverage database and report (19.7). It can only be set in the covergroup definition.
| Method | Returns | Changed by per_instance? |
|---|---|---|
inst.get_inst_coverage() | that instance's number | no |
inst.get_coverage() or type::get_coverage() | the type number over all instances | no |
| the coverage report | type, plus each instance when per_instance is 1 | yes |
per_instance decides what is saved and printed. The methods compute the same numbers either way.
So a per-port report must call get_inst_coverage() on each port's instance. get_coverage() returns the type number, the same for every port.
auto_bin_max, Once More
option.auto_bin_max also changes the number, through the bin count of coverpoints with no bins of their own (lesson C13). Set in the covergroup, it is the default for every such coverpoint; it does not apply to crosses (Table 19-2).
Try It
common has 6 bins at weight 1, rare 2 bins at weight 3, and dir weight 0. The first overflow is one hit short of at_least 2, so it changes nothing. The second covers overflow: rare goes to 50%, which weighs 3.
The underflow is one hit short too. After six samples: (3/6 x 1 + 1/2 x 3) / 4 = 50%. Predict the last line with option.weight = 1 in rare.
ev=1: 4.17% ev=2: 8.33% ev=7: 8.33% ev=3: 12.50% ev=7: 50.00% ev=0: 50.00%Check Yourself
Common Mistakes
Wrong Set option.at_least once in the covergroup on the coverage build.
The standard makes it the default for every coverpoint, but the build ignores it there.
Fix Set it in each coverpoint or cross that needs it.
covergroup cg;
option.at_least = 4;
cp: coverpoint ev;
endgroupcovergroup cg;
cp: coverpoint ev {
option.at_least = 4;
}
endgroupWrong Lower option.goal to make a report show a smaller hole.
The goal does not change the number; it only moves the line the report compares against.
Fix Fix the bins or the stimulus, and keep goals for real sign-off targets.
Wrong Read per-port numbers with get_coverage().
It returns the type number, the same for every instance.
Fix Call get_inst_coverage() on each port's instance.
Remember
- A covergroup is the weighted average of its items, and weight 0 removes an item. All-zero item weights give 0.0, or 100.0 when the covergroup weighs 0.
option.goalis a target for reports and never changes the number.option.at_leastsets the hits a bin needs; on the coverage build set it per coverpoint or cross, as a constant.option.per_instancecontrols what is saved and reported, not what the methods return.get_inst_coverage()is one instance;get_coverage()is the type.