今天複習到coverage的相關寫法,翻到LRM進行查閱,發現自己之前做過筆記,但時間已久就忘了,現在把他記錄一下方便自己查閱。
coverage有兩大類option: 一類是針對每個covergroup instance的(即每個instance可以單獨指定),一類是針對covergroup type的(即每個covergroup指定);
類似于class 中 靜態變量和local 變量,靜態變量是每個instance所共有,而local 變量是每個instance私有。
先看針對每個covergroup instance的option
Option name | Default | Description |
weight= number | 1 | If set at the covergroup syntactic level, it specifies the weight of this covergroup instance for computing the overall instance coverage of the simulation. If set at the coverpoint (or cross) syntactic level, it specifies the weight of a coverpoint (or cross) for computing the instance coverage of the enclosing covergroup. The specified weight shall be a non-negative integral value. |
goal=number | 100 | Specifies the target goal for a covergroup instance or for a coverpoint or a cross of an instance. |
name=string | unique name |
Specifies a name for the covergroup instance. If unspecified, a unique name for each instance is automatically generated by the tool. |
comment=string | “” | A comment that appears with a covergroup instance or with a coverpoint or cross of the covergroup instance. The comment is saved in the coverage database and included in the coverage report. |
at_least=number | 1 | Minimum number of hits for each bin. A bin with a hit count that is less than number is not considered covered. |
detect_overlap=boolean | 0 | When true, a warning is issued if there is an overlap between the range list (or transition list) of two bins of a coverpoint. |
auto_bin_max=number | 64 | Maximum number of automatically created bins when no bins are explicitly defined for a coverpoint. |
cross_num_print_missing= number |
0 | Number of missing (not covered) cross product bins that shall be saved to the coverage database and printed in the coverage report. |
per_instance=boolean | 0 | Each instance contributes to the overall coverage information for the covergroup type. When true, coverage information for this covergroup instance shall be saved in the coverage database and included in the coverage report. When false, implementations are not required to save instance-specific information. |
get_inst_coverage=boolean | 0 | Only applies when the merge_instances type option is set. Enables the tracking of per instance coverage with the get_inst_coverage built-in method. When false, the value returned by get_inst_coverage shall equal the value returned by get_coverage. |
covergroup g1 (int w, string instComment) @(posedge clk) ;
// track coverage information for each instance of g1 in addition
// to the cumulative coverage information for covergroup type g1
option.per_instance = 1;
// comment for each instance of this covergroup
option.comment = instComment;
a : coverpoint a_var
{
// Create 128 automatic bins for coverpoint “a” of each instance of g1
option.auto_bin_max = 128;
}
b : coverpoint b_var
{
// This coverpoint contributes w times as much to the coverage of an
// instance of g1 as coverpoints "a" and "c1"
option.weight = w;
}
c1 : cross a_var, b_var ;
endgroup
Option assignment statements in the covergroup definition are evaluated at the time that the covergroup is instantiated.
每個option的適用範圍
Option name | covergroup | coverpoint | cross |
---|---|---|---|
name | Yes | No | No |
weight | Yes | Yes | Yes |
goal | Yes | Yes | Yes |
comment | Yes | Yes | Yes |
at_least | Yes(default for coverpoints & crosses) | Yes | Yes |
detect_overlap | Yes (default for coverpoints) | Yes | No |
auto_bin_max | Yes (default for coverpoints) | Yes | No |
cross_num_print_missing | Yes (default for crosses) | No | Yes |
per_instance | Yes | No | No |
針對covergroup type 的option
Option name | Default | Description |
weight= number | 1 | If set at the covergroup syntactic level, it specifies the weight of this covergroup for computing the overall cumulative (or type) coverage of the saved database. If set at the coverpoint (or cross) syntactic level, it specifies the weight of a coverpoint (or cross) for computing the cumulative (or type) coverage of the enclosing covergroup. The specified weight shall be a nonnegative integral value. |
goal=constant_number | 100 | Specifies the target goal for a covergroup type or for a coverpoint or cross of a covergroup type. |
strobe=boolean | 0 | When true, all samples happen at the end of the time slot, like the $strobe system task. |
comment=string | “” | A comment that appears with the covergroup type or with a coverpoint or cross of the covergroup type. The comment is saved in the coverage database and included in the coverage report. |
merge_instances=boolean | 0 | When true, cumulative (or type) coverage is computed by merging instances together as the union of coverage of all instances. When false, type coverage is computed as the weighted average of instances. |
distribute_first=boolean | 0 | When true, instructs the tool to perform value distribution to the bins prior to application of the with_covergroup_expression. |
type_option.member_name = constant_expression ;
covergroup g1 (int w, string instComment) @(posedge clk) ;
// track coverage information for each instance of g1 in addition
// to the cumulative coverage information for covergroup type g1
option.per_instance = 1;
type_option.comment = "Coverage model for features x and y";
type_option.strobe = 1; // sample at the end of the time slot
// compute type coverage as the merge of all instances
type_option.merge_instances = 1;
// comment for each instance of this covergroup
option.comment = instComment;
a : coverpoint a_var
{
// Use weight 2 to compute the coverage of each instance
option.weight = 2;
// Use weight 3 to compute the cumulative (type) coverage for g1
type_option.weight = 3;
// NOTE: type_option.weight = w would cause syntax error.
}
endgroup
Different instances of a covergroup cannot assign different values to type options.
適用範圍:
ref: sv LRM