Tutorials
Learn More
Cross coverage
The cross-coverage allows having a cross product (i.e. cartesian product) between two or more variables or coverage points within the same covergroup. In simple words, cross-coverage is nothing but a set of cross-products of variables or coverage points.
Syntax:
<cross_coverage_label> : cross <coverpoint_1>, <coverpoint_2>,..., <coverpoint_n>
Example:
bit [7:0] addr, data;
bit [3:0] valid;
bit en;
covergroup c_group @(posedge clk);
cp1: coverpoint addr && en; // labeled as cp1
cp2: coverpoint data; // labeled as cp2
cp1_X_cp2: cross cp1, cp2; // cross coverage between two expressions
valid_X_cp2: cross valid, cp2; // cross coverage between variable and expression
endgroup : c_group
Coverage constructs
iff construct
The expression within the iff construct provides feasibility to exclude the coverpoint in the coverage if an expression is evaluated as false.
Example:
module func_coverage;
logic [3:0] addr;
covergroup c_group;
cp1: coverpoint addr iff(!reset_n) // coverpoint addr is covered when reset_n is low.
endgroup
c_group cg = new();
...
...
endmodule
binsof and intersect construct in functional coverage
binsof construct in coverage
The binsof construct is used to yield bins of its expression.
Syntax:
binsof (<expression>)
Where,
An expression can be either a single variable or an explicitly defined coverage point.
Example:
bit [7:0] var1, var2;
covergroup c_group @(posedge clk);
cp1: coverpoint var1 {
bins x1 = { [0:99] };
bins x2 = { [100:199] };
bins x3 = { [200:255] };
}
cp2: coverpoint var2 {
bins y1 = { [0:74] };
bins y2 = { [75:149] };
bins y3 = { [150:255] };
}
cp1_X_cp2: cross cp1, cp2 {
bins xy1 = binsof(cp1.x1);
bins xy2 = binsof(cp2.y2);
bins xy3 = binsof(cp1.x1) && binsof(cp2.y2);
bins xy4 = binsof(cp1.x1) || binsof(cp2.y2);
}
endgroup
In the above example, coverage points cp1 and cp2 include a set of cover bins for variables var1 and var2. The cp1_X_cp2 denotes the cross product of var1 and var2 with specified cross-bins.
If no additional cross bins were specified (i.e. cp1_X_cp2: cross var1, var2), then it would have resulted in 9 cross products listed as:
<x1, y1>, <x1, y2>, <x1, y3>,
<x2, y1>, <x2, y2>, <x2, y3>,
<x3, y1>, <x3, y2>, <x3, y3>.
The cross bin xy1: It results in 3 cross products listed as
<x1, y1>, <x1, y2>, <x1, y3>
The cross bin xy2: It results in 3 cross products listed as
<x1, y2>, <x2, y2>, <x3, y2>
The cross bin xy3: It results in 1 cross-product listed as
<x1, y2>
The cross bin xy4: It results in 5 cross products listed as
<x1, y1>, <x1, y2>, <x1, y3>, <x2, y2>, <x3, y2>
intersect construct in coverage
The intersect construct is generally used in conjunction with the binsof construct which is used to exclude or include a set of values of bins that intersect a desired set of values.
Syntax:
binsof(<coverpoint>) intersect {<range of values>}
Meaning
bins |
Description |
binsof(cp) intersect {r} |
The bins of coverpoint cp whose values intersect the range specified by r |
!binsof(cp) intersect {r} |
The bins of coverpoint cp whose values do not intersect the range specified by r |
Example:
bit [7:0] var1, var2;
covergroup c_group @(posedge clk);
cp1: coverpoint var1 {
bins x1 = { [0:99] };
bins x2 = { [100:199] };
bins x3 = { [200:255] };
}
cp2: coverpoint var2 {
bins y1 = { [0:74] };
bins y2 = { [75:149] };
bins y3 = { [150:255] };
}
cp1_X_cp2: cross cp1, cp2 {
bins xy1 = binsof(cp1) intersect {[100:200]};
bins xy2 = !binsof(cp1) intersect {[100:200]};
bins xy3 = !binsof(cp1) intersect {99, 125, 150, 175};
}
endgroup
In the above example, coverage points cp1 and cp2 include a set of cover bins for variables var1 and var2. The cp1_X_cp2 denotes the cross product of var1 and var2 with specified cross-bins.
If no additional cross bins were specified (i.e. cp1_X_cp2: cross var1, var2), then it would have resulted in 9 cross products listed as:
<x1, y1>, <x1, y2>, <x1, y3>,
<x2, y1>, <x2, y2>, <x2, y3>,
<x3, y1>, <x3, y2>, <x3, y3>.
The cross bin xy1: The x2 and x3 of cp1 intersect with value range [100:200]. It results in 6 cross products listed as
<x2, y1>, <x2, y2>, <x2, y3>,
<x3, y1>, <x3, y2>, <x3, y3>.
The cross bin xy2: The x1 alone do not intersect the value range [100:200]. It results in 3 cross products listed as
<x1, y1>, <x1, y2>, <x1, y3>
The cross bin xy3: The x3 alone do not intersect with range of values 99, 125, 150, 175. It results in 3 cross products listed as
<x3, y1>, <x3, y2>, <x3, y3>
Excluding cross product using ignore_bins and illegal_bins construct
In the above example, cross-product bins can be excluded as
cp1_X_cp2: cross cp1, cp2 {
ignore_bins xy1 = binsof(cp1) intersect {[100:200]};
ignore_bins xy2 = !binsof(cp1) intersect {[100:200]};
ignore_bins xy3 = !binsof(cp1) intersect {99, 125, 150, 175};
}
The cross bin xy1: It results into exclusion of 6 cross products listed as
<x2, y1>, <x2, y2>, <x2, y3>,
<x3, y1>, <x3, y2>, <x3, y3>.
The cross bin xy2: It results in the exclusion of 3 cross products listed as
<x1, y1>, <x1, y2>, <x1, y3>
The cross bin xy3: It results in the exclusion of 3 cross products listed as
<x3, y1>, <x3, y2>, <x3, y3>
Similarly, illegal bins can also be specified as
cp1_X_cp2: cross cp1, cp2 {
illegal_bins xy1 = binsof(cp1) intersect {[100:150]};
illegal_bins xy2 = !binsof(cp1) intersect {[100:150]};
illegal_bins xy3 = !binsof(cp1) intersect {99, 125, 150, 175};
}
Functional Coverage