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) from type_option (the whole type) and say which number each affects.
  • Predict the type number with type_option.merge_instances set and unset, and with type_option.weight on coverpoints.
  • Explain what distribute_first and strobe change, 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%.

InstanceBins hitInstance number
p0rd50%
p1wr50%
type, averaged (default)-50%
type, mergedrd and wr100%

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 memberDefaultLevelsWhat it changes
weight1covergroup, coverpoint, crossthe item's weight in the type number
goal100covergroup, coverpoint, crossthe target a report shows; no number
comment""covergroup, coverpoint, crossthe report text; no number
strobe0covergroupsample once per time slot, at its end
merge_instances0covergrouptype number: union (1) or average (0) of instances
distribute_first0covergroupspread values into [N] bins before with filters them
real_interval (1800-2023)1.0covergroup, coverpointinterval 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 definitionStandardCoverage build (measured)
cg::type_option.commentlink modelempty
c.type_option.commentlink modelempty

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.

Average or UnionTwo instances of one type, each with bins one and two. Arrows show how each method builds the type number from them.
  • Model
  • Result
  • Data
Average or unionTwo instances of one type, each with bins `one` and `two`. Arrows show how each method builds the type number from them. model instance x hit one: 50% model instance y hit two: 50% result merge_instances= 0 (50 + 50) / 2 = 50% result merge_instances= 1 one and two: 100%
  1. model instance xhit one: 50%
    • merge_instances = 0
    • merge_instances = 1
  2. model instance yhit two: 50%
    • merge_instances = 0
    • merge_instances = 1
  3. result merge_instances = 0(50 + 50) / 2 = 50%
  4. result merge_instances = 1one and two: 100%
  1. Average

    Each instance contributes its own number, weighted by its option.weight.

  2. Union

    The bins are merged by name: one from x and two from 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, 2BinsCoverage
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 = 2StandardCoverage build (measured)
no strobetwo samples: 1 and 2, 100.00%100.00%
strobe = 1one 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.

RUNVerilator (coverage build) · simulator service
Edit the code, then run it
Expected: port 0: 50.00% port 1: 50.00% type: 87.50%

Check Yourself

Predict the outputPredict the exact output.
module tb;
  covergroup cg with function sample(bit [1:0] a);
    coverpoint a { bins one = {1}; bins two = {2}; }
  endgroup
  cg x = new, y = new;
  initial begin
    x.sample(1);
    y.sample(1); y.sample(2);
    $display("%0.2f%%", cg::get_coverage());
  end
endmodule
ConceptWhy can two instances not give type_option.weight different values?
ConceptA covergroup samples on @(posedge clk), and a glitch makes clk rise twice in one time step. Which option makes it sample once per step?
ConceptWith merge_instances 0, what decides how much each instance counts in the type number?

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?".

Before
covergroup link_cg ...;
  coverpoint kind;
endgroup
After
covergroup link_cg ...;
  type_option.merge_instances = 1;
  coverpoint kind;
endgroup

Wrong 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

  • option is per instance; type_option is per covergroup type, set with constants.
  • merge_instances 1 makes the type number the union of instances; 0 averages them by instance weight.
  • Coverpoint type_option.weight matters only when instances are merged.
  • type_option.goal and comment never change a number.
  • distribute_first deals before filtering, and strobe samples once per time slot; the coverage build ignores both.

Practice

Report a problem with this page