type_option
Set options for a whole covergroup type: merging, type weights, goal, comment, distribution order and strobed sampling.
You Will Be Able To
- Tell
option(one instance) fromtype_option(the whole type) and say which number each affects. - Predict the type number with
type_option.merge_instancesset and unset, and withtype_option.weighton coverpoints. - Explain what
distribute_firstandstrobechange, and use runnable equivalents where a tool ignores them.
- Lesson
- C25
- Time
- 30 min
- Runs on
- Coverage build
- Check
- 4 questions
Two monitors covered the same link type. One sent only reads and the other only writes, so each instance read 50%. Sign-off asked for the type number and got 50%, the average, although together the two had seen every kind. One line, type_option.merge_instances = 1, gave the union: 100%.
| Instance | Bins hit | Instance number |
|---|---|---|
| p0 | rd | 50% |
| p1 | wr | 50% |
| type, averaged (default) | - | 50% |
| type, merged | rd and wr | 100% |
The same samples give two different type numbers. Which one sign-off wants is a plan decision.
Option Against type_option
Every covergroup, coverpoint and cross has two built-in structs (IEEE 1800-2023 19.10). option belongs to an instance: each instance can hold its own values. type_option belongs to the covergroup type, like a static class member, and is set with constant expressions.
| type_option member | Default | Levels | What it changes |
|---|---|---|---|
| weight | 1 | covergroup, coverpoint, cross | the item's weight in the type number |
| goal | 100 | covergroup, coverpoint, cross | the target a report shows; no number |
| comment | "" | covergroup, coverpoint, cross | the report text; no number |
| strobe | 0 | covergroup | sample once per time slot, at its end |
| merge_instances | 0 | covergroup | type number: union (1) or average (0) of instances |
| distribute_first | 0 | covergroup | spread values into [N] bins before with filters them |
| real_interval (1800-2023) | 1.0 | covergroup, coverpoint | interval width of real bins (lesson C12) |
Table 19-3 and 19-4 of IEEE 1800-2023. strobe and real_interval can only be set in the definition; the others may also be assigned later, as cg::type_option.goal = 90;.
type_option.weight
On a coverpoint or cross, type_option.weight weights it in the type number when instances are merged (19.7.1). When they are averaged, the type number is built from whole instances, weighted by their option.weight. Coverpoint type weights play no part (19.11.3).
On the covergroup, type_option.weight weights the type among all covergroup types in the database, the number $get_coverage() returns (19.9).
type_option.goal
type_option.goal is the target for the type, or for a coverpoint or cross across all instances (19.7.1). Like option.goal, it is for reports and never changes a number.
type_option.comment
type_option.comment describes the covergroup type, or one of its coverpoints or crosses, in the report (19.7.1). Write the plan row the model answers.
type_option.comment = "link model"; in the definition | Standard | Coverage build (measured) |
|---|---|---|
cg::type_option.comment | link model | empty |
c.type_option.comment | link model | empty |
Standard behaviour, not run correctly on this build. Scenario cov-083 in docs/sva-standard-traces/CG.md. The instance option.comment, assigned after construction, does read back (lesson C24).
type_option.merge_instances
The type number can be computed two ways (19.11.3). With merge_instances 0, the default, it is the weighted average of the instances' own numbers. With 1, the instances are merged: a bin is covered if they hit it often enough together. Bins are matched by name.
one and two. Arrows show how each method builds the type number from them.- Model
- Result
- Data
- Average
Each instance contributes its own number, weighted by its
option.weight. - Union
The bins are merged by name:
onefrom x andtwofrom y are both covered.
Read the diagram as text
- instance x: hit one: 50%
- instance y: hit two: 50%
- merge_instances = 0: (50 + 50) / 2 = 50%
- merge_instances = 1: one and two: 100%
- instance x → merge_instances = 0
- instance y → merge_instances = 0
- instance x → merge_instances = 1
- instance y → merge_instances = 1
Union answers "did the system see it?"; average answers "how complete is each instance?".
type_option.distribute_first
By default a with filter runs first, and the surviving values are then dealt into [N] bins (19.5.1.1). type_option.distribute_first = 1; reverses the order: deal first, then filter each bin (19.7.1).
bins q[3] = {[0:8]} with (item % 2 == 0); samples 0, 2 | Bins | Coverage |
|---|---|---|
| default: filter, then deal 5 values | <0> <2> <4,6,8> | 66.67% |
| distribute_first = 1: deal 9 values, then filter | <0,2> <4> <6,8> | standard 33.33%; coverage build 66.67% (ignored) |
The second row is standard behaviour, not run correctly on this build. Scenario cov-085 in docs/sva-standard-traces/CG.md.
type_option.strobe
A covergroup with a clocking event samples every time the event happens, even several times in one time step. type_option.strobe = 1; moves sampling to the end of the time slot, the Postponed region, so it samples once, on settled values, like $strobe (19.3, 19.7.1). It has no effect on sample() calls.
| Event fires with v = 1, then again in the same step with v = 2 | Standard | Coverage build (measured) |
|---|---|---|
| no strobe | two samples: 1 and 2, 100.00% | 100.00% |
| strobe = 1 | one sample, v = 2: 50.00% | 100.00%: ignored |
Standard behaviour for the second row, not run correctly on this build. Scenario cov-007b in docs/sva-standard-traces/CG.md; cov-007 is the same rule on a clock edge.
Try It
Each port covers one kind and one length class: (50 + 50) / 2 with instance weights. Merged, both kinds are covered and only short_ of the lengths: (100 x 3 + 50 x 1) / 4 = 87.5% with the type weights.
Predict the type line with merge_instances removed.
port 0: 50.00% port 1: 50.00% type: 87.50%Check Yourself
Common Mistakes
Wrong Report the default type number for a system whose instances cover different parts of the plan.
The average of instances can read 50% when, together, they covered everything.
Fix Set type_option.merge_instances = 1 when the question is "did the system see it?".
covergroup link_cg ...;
coverpoint kind;
endgroupcovergroup link_cg ...;
type_option.merge_instances = 1;
coverpoint kind;
endgroupWrong Set type_option.weight on coverpoints and expect it to change the average type number.
Without merging, the type number is built from whole instances.
Fix Use coverpoint type weights with merge_instances = 1, or instance option.weight otherwise.
Wrong Rely on distribute_first or strobe on the coverage build.
The build ignores both.
Fix Write the bins as they come out after dealing, and sample once per step.
Remember
optionis per instance;type_optionis per covergroup type, set with constants.merge_instances1 makes the type number the union of instances; 0 averages them by instance weight.- Coverpoint
type_option.weightmatters only when instances are merged. type_option.goalandcommentnever change a number.distribute_firstdeals before filtering, andstrobesamples once per time slot; the coverage build ignores both.