Tutorials
Protocols
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. It helps find missing combinations that individual coverpoints cannot reveal.
Syntax:
<cross_coverage_label> : cross <coverpoint_1>, <coverpoint_2>,..., <coverpoint_n> A label is strongly recommended because it makes the cross easy to identify in the coverage report.
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 item | What is crossed | Important behavior |
cp1 | Expression addr && en | A Boolean result, so the coverpoint is effectively one bit |
cp2 | Eight-bit data | Automatic bins are created for data values unless explicit bins are declared |
cp1_X_cp2 | cp1 x cp2 | Measures each Boolean-result/data-bin combination |
valid_X_cp2 | valid x cp2 | An implicit coverpoint is created for valid, then crossed with cp2 |
The expression addr && en does not cover individual address values. It evaluates to 1 only when addr is nonzero and en is 1; otherwise it evaluates to 0.
If the intention is to cover address values only while enable is active, write:
cp_addr: coverpoint addr iff (en);
cp_data: coverpoint data iff (en);
addr_X_data: cross cp_addr, cp_data iff (en);
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 reset_n | Expression !reset_n | Does cp1 sample? |
0 | 1 | Yes |
1 | 0 | No |
Because reset_n is normally an active-low reset, this example samples while reset is asserted. To sample normal operation after reset is released, use iff (reset_n).
binsof and intersect construct in functional coverage
binsof construct in coverage
binsof() selects bins from a coverpoint. Inside a cross, it is used to group selected Cartesian products into named cross bins.
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> The && keeps only products that satisfy both selections. || keeps products that satisfy either selection. The shared product <x1,y2> appears once in the union, so xy4 contains five products rather than six.
Value to bin mapping:
Sampled values | Coverpoint bins | Named cross bins hit |
var1=50, var2=20 | x1, y1 | xy1 and xy4 |
var1=50, var2=100 | x1, y2 | xy1, xy2, xy3, and xy4 |
var1=150, var2=100 | x2, y2 | xy2 and xy4 |
var1=220, var2=200 | x3, y3 | None of xy1-xy4 |
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> cp1 bin | Range | Intersects [100:200]? | Intersects {99,125,150,175}? |
x1 | 0-99 | No | Yes, at 99 |
x2 | 100-199 | Yes | Yes, at 125, 150, and 175 |
x3 | 200-255 | Yes, at 200 | No |
Cross bin | Selected cp1 bins | Resulting cross products |
xy1 | x2 and x3 | 6 products: each selected x-bin crossed with y1, y2, and y3 |
xy2 | x1 | 3 products: <x1,y1>, <x1,y2>, <x1,y3> |
xy3 | x3 | 3 products: <x3,y1>, <x3,y2>, <x3,y3> |
A bin is selected when any value in that bin intersects the requested set. The entire coverpoint bin then participates in the selected cross products.
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};
} Ignore bin | Excluded cp1 bins | Number of excluded products |
xy1 | x2 and x3 | 6 |
xy2 | x1 | 3 |
xy3 | x3 | 3 |
Use ignore_bins only for combinations that are outside the verification goal, such as architecturally unsupported combinations. Document the reason for every exclusion.
Treat the three declarations as selection examples. If xy1 and xy2 are both used exactly as shown, their complementary selections exclude all nine products, leaving no useful cross-coverage goal.
Avoiding Cross-Coverage Explosion
The number of cross products is the product of the participating bin counts. Crosses can therefore become very large.
Crossed coverpoints | Bin calculation | Cross products |
4 operation bins x 3 mode bins | 4 x 3 | 12 |
16 address bins x 8 data bins | 16 x 8 | 128 |
256 address bins x 256 data bins | 256 x 256 | 65,536 |
Create meaningful bins before crossing large fields. Cross only combinations that answer a verification-plan question.
Common Mistakes
- Assuming that two fully covered coverpoints guarantee every combination was tested.
- Crossing raw wide variables and unintentionally creating thousands of bins.
- Using addr && en when the intention is to cover address values while enable is high.
- Writing iff(!reset_n) while intending to sample only after active-low reset is released.
- Forgetting that binsof(cp1.x1) selects every cross product containing x1.
- Ignoring combinations without documenting why they are outside the coverage goal.
- Using illegal_bins as the only checker for behavior that must fail the test.
Functional Coverage