Tutorials

Protocols

Learn More

Coverage options control how SystemVerilog creates bins, counts hits, combines coverage values, stores results, and reports progress. They do not generate stimulus; they change how the coverage model behaves.

There are two types of options which are 

  1. Specific to an instance of a covergroup
  2. Specific to the covergroup type as a whole.

option and type_option

A covergroup can have many instances. Use option for the behavior or reporting of one instance, and use type_option for settings shared by the complete covergroup type.

Feature

option

type_option

Scope

One covergroup instance

The complete covergroup type

Can instances differ?

Yes, when the option permits it

No; all instances share the value

Typical syntax

option.goal = 90;

type_option.goal = 90;

Typical use

Per-interface tracking or instance weighting

Type-wide reporting, comments, or sampling behavior

covergroup c_group;
  option.per_instance = 1;          // Instance-specific setting
  type_option.comment = "Bus FC";  // Shared type setting
endgroup

Type A: Specific to an instance of a covergroup

Each instance of the covergroup can have an instance-specific option.

Syntax:

option.<option_name> = <expression>;

Where,

option – a built-in member of any coverage group.

<option_name> – supported options are specified in the below table.

Option name

Description

Allowed in Syntactic level

Weight = number

[Default value = 1]

1. If it is set at the covergroup syntactic level, then it specifies the weight of this covergroup instance for computing the overall instance coverage of the simulation. 

2. If it is set at coverpoint or cross syntactic level, then it specifies the weight of a coverpoint or a cross for computing the instance coverage of the enclosing covergroup.

covergroup, coverpoint, cross

name = string

Specifies a name for the covergroup instance. If it is not specified, the tool will generate a unique name for each instance.

covergroup

per_instance = boolean

[Default value = False/0]

Each covergroup instance contributes to the overall coverage information for the coverage type. If it is true, coverage information for this covergroup instance is also tracked.

covergroup

goal = number

[Default value = 90]

Specifies target goal for coverpoint or cross or covergroup instance.

covergroup, coverpoint, cross

comment = string

Saves comment in coverage database and includes in the coverage report for an instance of covergroup, coverpoint, and cross.

covergroup, coverpoint, cross

at_least = number

[Default value = 1]

Specifies the minimum number of hits for each bin. If the bin is hit less than the specified number, then it is not considered.

covergroup, coverpoint, cross

detect_overlap=boolean

[Default value = False/0]

When it is true, it reports a warning for an overlap between the range list of the two bins of a coverpoint.

covergroup, coverpoint

auto_bin_max = number

[Default value = 64]

When no bins are explicitly specified for a coverpoint, it denotes the maximum number of automatically created bins.

covergroup, coverpoint

cross_auto_bin_max = number

Denotes the maximum number of automatically created cross-product bins for a cross.

covergroup cross

cross_num_print_missing = number

[Default value = 0]

Saves uncovered cross-product bins in the coverage database and includes them in the coverage report.

covergroup, cross

Example for specific to an instance of a covergroup

module func_coverage;
  bit [7:0] addr, data;
  covergroup c_group;
    option.per_instance = 1;
    option.comment = "This is the comment";
    
    cp1: coverpoint addr {
      option.weight = 2;
      option.auto_bin_max = 32;
    }
    cp2: coverpoint data;
    cp1_X_cp2: cross cp1, cp2 {
      option.cross_auto_bin_max = 32;
    }
  endgroup : c_group

  c_group cg = new();
  
  initial begin  
    forever begin
      cg.sample();
      #5;
    end
  end
  
  initial begin
    $monitor("At time = %0t: addr = %0d, data = %0d", $time, addr, data);
    repeat(5) begin
      addr = $random;
      data = $random;
      #5;
    end
    $display("Coverage = %f", cg.get_coverage());
    $finish;
  end
  
endmodule

Output:

At time = 0: addr = 36, data = 129
At time = 5: addr = 9, data = 99
At time = 10: addr = 13, data = 141
At time = 15: addr = 101, data = 18
At time = 20: addr = 1, data = 13
Coverage = 7.389323

Type B: Specific to the covergroup type as a whole

It specified a particular feature or property of the covergroup type as a whole. They are analogous to static data members of classes.

Syntax:

type_option.<option_name> = <expression>;

Where,

type_option – a built-in member of any coverage group.

<option_name> – supported options are specified in the below table.

Option name

Description

Allowed in Syntactic level

Weight = constant_number

[Default value = 1]

1. If it is set at the covergroup syntactic level, then it specifies the weight of this covergroup instance for computing the overall instance coverage of the simulation. 

2. If it is set at coverpoint or cross syntactic level, then it specifies the weight of a coverpoint or a cross for computing the instance coverage of the enclosing covergroup.

covergroup, coverpoint, cross

goal = number

[Default value = 90]

Specifies target goal for coverpoint or cross or covergroup instance.

covergroup, coverpoint, cross

comment = string

Saves comment in coverage database and includes in the coverage report for an instance of covergroup, coverpoint, and cross.

covergroup, coverpoint, cross

strobe = constant_number

[Default value = 0]

Similar to the $strobe system task, if it sets to 1, sampling is done at the end of the time slot.

covergroup

Example for specific to the covergroup type as a whole

module func_coverage;
  bit [7:0] addr, data;
  covergroup c_group;
    option.per_instance = 1;
    type_option.comment = "This is the comment";
    type_option.strobe = 1;
    
    cp1: coverpoint addr {
      type_option.weight = 2;
    }
    cp2: coverpoint data;
    cp1_X_cp2: cross cp1, cp2;
  endgroup : c_group

  c_group cg = new();
  
  initial begin  
    forever begin
      cg.sample();
      #5;
    end
  end
  
  initial begin
    $monitor("At time = %0t: addr = %0d, data = %0d", $time, addr, data);
    repeat(5) begin
      addr = $random;
      data = $random;
      #5;
    end
    $display("Coverage = %f", cg.get_coverage());
    $finish;
  end
  
endmodule

Output:

At time = 0: addr = 36, data = 129
At time = 5: addr = 9, data = 99
At time = 10: addr = 13, data = 141
At time = 15: addr = 101, data = 18
At time = 20: addr = 1, data = 13
Coverage = 6.286621

Common Mistakes

  • Using ‘goal’ as if it removes bins. It changes the reporting target; it does not delete coverage requirements.
  • Using ‘at_least’ as a sample counter for the whole covergroup. It is a per-bin hit threshold.
  • Expecting ‘per_instance = 1’ to create instances. Covergroup objects still need to be constructed with new().
  • Assuming ‘cross_num_print_missing’ limits cross-bin creation. It controls how many missing bins are saved or reported.
  • Changing bin-construction options after the covergroup has already been constructed.
  • Calling ‘sample()’ as well as using an automatic clocking event for the same transfer, causing duplicate samples.
  • Comparing exact percentages between simulators without checking automatic-bin and cross settings.