Options for Reporting and Checking
Name and annotate instances, ask for overlap warnings and missing-cross lists, and keep per-instance numbers under merging.
You Will Be Able To
- Name an instance with
option.nameand describe it withoption.comment, in a form every tool reads back. - Say what
option.detect_overlapandoption.cross_num_print_missingdo, and that neither changes the number. - Use
option.get_inst_coverageto keep per-instance numbers undertype_option.merge_instances.
- Lesson
- C24
- Time
- 25 min
- Runs on
- Coverage build
- Check
- 5 questions
A regression report listed eight covergroup instances, all called port_cg with a tool-made suffix. One was at 40%, and the team had to guess which port it was. Two lines, a name and a comment set when each instance was built, would have said "port 5, the slow port".
| Instance | Without a name | With option.name and option.comment |
|---|---|---|
| p0 | port_cg_1 | port0: the slow port |
| p1 | port_cg_2 | port1 |
| ... | ... | ... |
Names and comments change only what a report shows; every number stays the same.
Report Options and the Number
Most options in this lesson change what the coverage report shows. Only one of them can change a number a method returns.
get_inst_coverage() returns.- Neutral
- Report
- Result
- Data
- Report only
Name, comment, overlap warnings and the missing-product list appear in the report.
- A returned number
Under
merge_instances,option.get_inst_coveragedecides whether the method returns the instance or the type number.
Read the diagram as text
- option.name: instance name
- option.comment: free text
- detect_overlap: a warning
- cross_num_print_missing: a list
- option.get_inst_coverage: with merging
- Coverage report: names, notes, warnings, lists
- get_inst_coverage(): the value returned
- option.name → Coverage report
- option.comment → Coverage report
- detect_overlap → Coverage report
- cross_num_print_missing → Coverage report
- option.get_inst_coverage → get_inst_coverage()
The sections below take the options one at a time.
option.name
option.name is the instance's name in the coverage database and report. Unset, the tool makes a unique name for each instance (IEEE 1800-2023 19.7). It can be set in the definition, from an argument, or after construction; set_inst_name() (lesson C22) also sets it.
| How the name is set | Standard (19.7) | Coverage build (measured) |
|---|---|---|
| not set | a unique name per instance | empty for every instance |
option.name = nm; in the definition, new("port0") | port0 | empty |
c.option.name = "port0"; after new | port0 | port0 |
The first two rows are standard behaviour, not run correctly on this build. Scenario cov-076 in docs/sva-standard-traces/CG.md.
option.comment
option.comment is a string saved with the instance, coverpoint or cross and printed in the report (19.7). Use it for the "why" a reader needs: which plan row, which port, what a weight of 0 means.
| How the comment is set | Standard | Coverage build (measured) |
|---|---|---|
option.comment = "..."; in the covergroup definition | saved and read back | reads back empty |
option.comment in a coverpoint | saved for that coverpoint | ignored: "Ignoring unsupported coverage option" |
c.option.comment = "..."; after new | saved and read back | saved and read back |
The first two rows are standard behaviour, not run correctly on this build. Scenario cov-077 in docs/sva-standard-traces/CG.md.
option.detect_overlap
Bins of a coverpoint may overlap: a value then counts for each bin that holds it. option.detect_overlap = 1; asks the tool to warn when two bins of a coverpoint overlap (19.7), so accidental overlaps are caught. It can be set in the covergroup, as a default, or in a coverpoint.
bins lo = {[0:5]}; bins mid = {[4:9]}; with detect_overlap = 1, sample 4 | Standard | Coverage build (measured) |
|---|---|---|
| warning | overlap of lo and mid reported | none: "Ignoring unsupported coverage option: detect_overlap" |
| number | 100.00%: 4 covers both bins | 100.00% |
The warning is standard behaviour; the number is the same either way. Scenario cov-078 in docs/sva-standard-traces/CG.md.
option.cross_num_print_missing
option.cross_num_print_missing = N; asks the report to list up to N cross products that were never hit (19.7). The default is 0. It is set on a cross, or in the covergroup as the default for its crosses, and it never changes the number.
option.get_inst_coverage
With type_option.merge_instances = 1, the type number is the union of every instance's bins. A tool need not then keep each instance's own number, so get_inst_coverage() returns the type number unless option.get_inst_coverage = 1 (19.7). The option can only be set in the definition.
| merge_instances | option.get_inst_coverage | x.get_inst_coverage() (x hit 1 of 2) | type number (x and y together) |
|---|---|---|---|
| 1 | 1 | x's own: 50.00% | union: 100.00% |
| 1 | 0 | the type number: 100.00% | 100.00% |
| 0 | either | x's own: 50.00% | average |
Measured on the coverage build; it agrees with the standard.
Try It
Each port hit one bin, so each instance is at 50%. The merged type number is the union of both: 100%.
Names and comments set after construction read back here. Predict the first line with option.get_inst_coverage = 1 removed.
port0 (the slow port): 50.00% port1: 50.00% type: 100.00%Check Yourself
Common Mistakes
Wrong Leave instances unnamed in a bench with many ports.
The report shows tool-made names, so nobody can tell which port has the hole.
Fix Set option.name for each instance, after construction on the coverage build.
foreach (pc[k]) pc[k] = new;foreach (pc[k]) begin
pc[k] = new;
pc[k].option.name = $sformatf("port%0d", k);
endWrong Expect detect_overlap to remove an overlap.
It only warns; the overlapping value still counts for both bins.
Fix Fix the ranges once the warning names them.
Wrong Merge instances and read per-port numbers without option.get_inst_coverage = 1.
Every port then returns the merged type number.
Fix Set option.get_inst_coverage = 1 in the definition when you merge.
Remember
option.namenames an instance (unique by default in the standard); on the coverage build set it after construction.option.commentannotates the report; on the coverage build assign it to the instance after construction.option.detect_overlapwarns about overlapping bins; the build ignores it, and overlaps still count twice.option.cross_num_print_missinglists unhit cross products in the report and never changes the number.- With
merge_instances,option.get_inst_coverage = 1keeps each instance's own number.