1、covergroup |
2、coverpoint |
bins |
3、cross coverpoint |
|
|
4、options |
|
|
5、methods |
|
|
6、systemtasks |
|
|
7、coverage computation |
|
|
cover property |
8、cover |
|
1、covergroup
我以前的领导告诉我:任何事,要有一种做的方法,还要有一种检查的方法。在验证中,随机是一种高效产生激励以覆盖待测空间的方法,与此同时,我们还需要一种检查待测空间是否真的被覆盖、是否足够覆盖的方法,也就是验证中常说的覆盖率收集。
覆盖率种类 |
特点 |
方法步骤 |
代码覆盖率 |
与设计无关 |
仿真工具独立完成 |
功能覆盖率 |
与设计相关
|
1、验证者在验证环境中加入相应语句: covergroup cover property 2、仿真工具编译执行上述语句 |
功能覆盖率不一定用coverage or cover property实现,但SV提供的这两种语法,相当于在EDA软件层搭建了一种专门的轮子,可大大减少验证者的coding工作量,且运行效率更高。
covergroup可被看成一种SV Built-In Class,因为它的语法结构和用法实在是太像class了。covergroup可以(往往)用在class中,这和“covergroup像class”这一说法并不矛盾,因为这和class可以用在class中是一样的。
covergroup |
|
covergroup cg; ... endgroup
class xyz; covergroup cov1 @m_z; // embedded covergroup coverpoint m_x; coverpoint m_y; function new(); cov1 = new; endfunction |
coverpoint |
object: variable expression bins: state bins transition bins
|
c: coverpoint color; |
cross coverpoint |
|
Hue: coverpoint pixel_hue; AxC: cross color, pixel_adr; |
formal argument |
input ref |
covergroup cv (int arg) @(posedge clk); |
event |
|
clocking_event
block_event_expression ::= |
coverage options |
|
option.member_identifier = expression type_option.member_identifier= constant_expression |
2、coverpoint
coverpoint
coverpoint |
coverpoint expression [ iff ( expression ) ] bins_or_empty |
bins_or_empty ::= |
|
[ wildcard ] bins_keyword bins_keyword::= bins | illegal_bins | ignore_bins |
|
{ covergroup_range_list } [ with ( with_covergroup_expression ) ] |
|
[ iff ( expression ) ] |
|
default [ iff ( expression ) ] |
|
default sequence [ iff ( expression ) ] |
bins
[] $ default |
coverpoint v_a{ bins a = { [0:63],65 }; bins b[] = { [127:150],[148:191] }; bins c[] = { 200,201,202 }; bins d = { [1000:$] }; |
||
with |
a: coverpoint x{ |
||
=> |
3 => 2 1,5 => 6, 7 |
||
[* m:n] |
3 [* 5] is equivalent to 3=>3=>3=>3=>3 3 [* 3:5] is equivalent to ( 3=>3=>3 ), ( 3=>3=>3=>3 ), ( 3=>3=>3=>3=>3 ) |
||
[-> m:n] |
3 [-> 3] is equivalent to ...=>3...=>3...=>3 1 => 3 [ -> 3] => 5 is equivalent to 1...=>3...=>3...=>3 =>5 |
||
[= m:n] |
1 => 3 [=2] => 6 is equivalent to 1...=>3...=>3...=>6
coverpoint v_a{ |
||
auto_bin_max |
If a coverage point does not define any bins, SystemVerilog automatically creates state bins. |
||
wildcard |
wildcard bins g12_15 = { 4'b11?? }; wildcard bins g12_15_array[] = { 4'b11?? }; wildcard bins T0_3 = (2'b0x => 2'b1x); wildcard bins T0_3_array[] = (2'b0x => 2'b1x); |
||
ignore_bins |
All values or transitions associated with ignored bins are excluded from coverage. ignore_bins ignore_vals = {7,8}; |
||
illegal_bins |
All values or transitions associated with illegal bins are excluded from coverage. If an illegal value or transition occurs, a runtime error is issued. illegal_bins bad_vals = {1,2,3}; |
||
Value resolution |
bit [2:0] p1; // type expresses values in the range 0 to 7 bit signed [2:0] p2; // type expresses values in the range –4 to covergroup g1 @(posedge clk); bins b1 = { 1, [2:5], [6:10] };
For b1, a warning is issued for the range [6:10]. b1 is treated as though it had the specification |
3、cover_cross
cover_cross |
[ cross_identifier : ] cross list_of_cross_items [ iff ( expression ) ] cross_body
list_of_cross_items ::= cross_item , cross_item { , cross_item } cross_item ::=
cross_body_item ::= bins_selection_or_option ::=
|
! select_condition |
|
select_expression && select_expression |
|
select_expression || select_expression |
|
select_expression with ( with_covergroup_expression ) [ matches integer_covergroup_expression ] |
|
cross_set_expression [ matches integer_covergroup_expression ] |
|
select_condition ::= binsof ( bins_expression ) [ intersect { covergroup_range_list } ] |
|
auto-cross expression |
covergroup cov2 @(posedge clk); |
auto-cross variable |
bit [3:0] a, b;
covergroup cov3 @(posedge clk);
Variable b_var automatically creates 16 bins (auto[0]...auto[15])
No cross coverage bins shall be created for coverpoint bins that are specified as default, ignored, or illegal |
User-defined cross bins
|
User-defined cross bins and automatically generated bins can coexist in the same cross. Automatically generated bins are retained for those cross products that do not intersect cross products specified by any user-defined cross bin.
int i,j;
Cross x1 has the following bins:
Cross x2 has the following bins: i_zero // user-specified bin for and
|
! && || |
c : cross a, b |
with match |
bins apple = X with (a+b < 257) matches 127; bins cherry = (binsof(b) intersect {[0:50]} && binsof(a.low) intersect {[0:50]}) with (a==b) ); bins plum = binsof(b.two) with (b > 12) || binsof(a.low) with (a & b & mask); |
cross set '{m,n} |
coverpoint a { bins x[] = {[0:10]}; } |
ignore_bins |
covergroup yy; |
illegal_bins |
covergroup zz(int bad); |
4、options
struct // covergroup option declaration { string name ; int weight ; int goal ; string comment ; int at_least ; int auto_bin_max ; int cross_num_print_missing ; bit detect_overlap ; bit per_instance ; bit get_inst_coverage ; } option;
struct // coverpoint option declaration { int weight ; int goal ; string comment ; int at_least ; int auto_bin_max ; bit detect_overlap ; } option;
struct // cross option declaration { int weight ; int goal ; string comment ; int at_least ; int cross_num_print_missing ; } option;
struct // covergroup type_option declaration { int weight ; int goal ; string comment ; bit strobe ; bit merge_instances ; } type_option;
struct // coverpoint and cross type_option declaration { int weight ; int goal ; string comment ; } type_option; |
5、methods
6、systemtasks
$set_coverage_db_name( filename ) |
sets the file name of the coverage database into which coverage information is saved at the end of a simulation run. |
$load_coverage_db( filename ) |
loads from the given file name the cumulative coverage information for all coverage group types. |
$get_coverage ( ) |
returns as a real number in the range of 0 to 100 the overall coverage of all coverage group types. This number is computed as previously described. |
7、coverage computation
略
8、cover property
以下内容来自:http://testbench.in/CO_17_COVER_PROPERTY.html
Comparison Of Cover Property And Cover Group. |