SV Function Coverage手册笔记

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
cg cg_inst = new;

 

class xyz;
bit [3:0] m_x;
int m_y;
bit m_z;

covergroup cov1 @m_z;  // embedded covergroup

 coverpoint m_x;

 coverpoint m_y;
endgroup

function new(); cov1 = new; endfunction
endclass

coverpoint

object:

  variable

  expression

bins:

  state bins

  transition bins

 

c: coverpoint color;

cross coverpoint

 

Hue: coverpoint pixel_hue;
Offset: coverpoint pixel_offset;

AxC: cross color, pixel_adr;

formal argument

input

ref

covergroup cv (int arg) @(posedge clk);
option.at_least = arg;
coverpoint x;
endgroup

event

 

clocking_event
| with function sample ( [ tf_port_list ] )
| @@( block_event_expression )

 

block_event_expression ::=
block_event_expression or block_event_expression
| begin hierarchical_btf_identifier
| end hierarchical_btf_identifier

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 ::=
{ {attribute_instance} { bins_or_options ; } }
| ;

[ 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:$] };
bins others[] = default;}

with

a: coverpoint x{
bins mod3[] = {[0:255]} with (item % 3 == 0);}

=>

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{
bins sa = (4 => 5 => 6), ([7:9],10=>11,12);
bins sb[] = (4=> 5 => 6), ([7:9],10=>11,12);
bins sc = (12 => 3 [-> 1]);
bins allother = default sequence ;}

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};
ignore_bins ignore_trans = (1=>3=>5);

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};
illegal_bins bad_trans = (4=>5=>6);

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);
coverpoint p1 {

bins b1 = { 1, [2:5], [6:10] };
bins b2 = { -1, [1:10], 15 };
}
coverpoint p2 {
bins b3 = {1, [2:5], [6:10] };
bins b4 = { -1, [1:10], 15 };
}
endgroup

 

For b1, a warning is issued for the range [6:10]. b1 is treated as though it had the specification
{1, [2:5], [6:7]}.
— For b2, a warning is issued for the range [1:10] and for the values –1 and 15. b2 is treated as
though it had the specification { [1:7] }.
— For b3, a warning is issued for the ranges [2:5] and [6:10]. b3 is treated as though it had the
specification { 1, [2:3] }.
— For b4, a warning is issued for the range [1:10] and for the value 15. b2 is treated as though it had
the specification { -1, [1:3] }.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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 ::=
cover_point_identifier
| variable_identifier

 

cross_body_item ::=
function_declaraton
| bins_selection_or_option ;

bins_selection_or_option ::=
{ attribute_instance } coverage_option
| { attribute_instance } bins_selection

 

! 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);
BC: coverpoint b+c;
aXb : cross a, BC;
endgroup

auto-cross variable

bit [3:0] a, b;
covergroup cov @(posedge clk);
aXb : cross a, b;
endgroup

 

covergroup cov3 @(posedge clk);
A: coverpoint a_var { bins yy[] = { [0:9] }; }
CC: cross b_var, A;
endgroup

 

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
bins.

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;
covergroup ct;
coverpoint i { bins i[] = { [0:1] }; }
coverpoint j { bins j[] = { [0:1] }; }
x1: cross i,j;
x2: cross i,j {
bins i_zero = binsof(i) intersect { 0 };
}
endgroup

 

Cross x1 has the following bins:
<i[0],j[0]>
<i[1],j[0]>
<i[0],j[1]>
<i[1],j[1]>

 

Cross x2 has the following bins:

i_zero    // user-specified bin for <i[0],j[0]> and <i[0],j[1]>
<i[1],j[0]> // an automatically generated bin that is retained
<i[1],j[1]> // an automatically generated bin that is retained

 

!

&&

||

c : cross a, b
{
bins c1 = ! binsof(a) intersect {[100:200]};// 4 cross products
bins c2 = binsof(a.a2) || binsof(b.b2);// 7 cross products
bins c3 = binsof(a.a1) && binsof(b.b4);// 1 cross product
}

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]}; }
coverpoint b { bins y[] = {[0:20]}; }
aXb : cross a, b
{
bins one = '{ '{1,2}, '{3,4}, '{5,6} };
}

ignore_bins

covergroup yy;
cross a, b
{
ignore_bins ignore = binsof(a) intersect { 5, [1:3] };
}
endgroup

illegal_bins

covergroup zz(int bad);
cross x, y
{
illegal_bins illegal = binsof(y) intersect {bad};
}
endgroup

 

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.
Cover groups can reference data sets where as cover property references a temporal expression.
http://testbench.in/FILES/bull.PNG
Cover group can be triggered using .sample method ()
Cover property dont have this option.
http://testbench.in/FILES/bull.PNG
Cover group has multiple bins options.
Cover property has only one bin.
http://testbench.in/FILES/bull.PNG
Cover group cannot handle complex temporal relationships.
Cover properties can cover complex temporal expressions.
http://testbench.in/FILES/bull.PNG
Cover group automatically handles the crosses.
Cover properties cannot do crosses.
http://testbench.in/FILES/bull.PNG
Cover group has lot of filtering options.
Cover property has no specific filtering constructs but it can be filtered.
http://testbench.in/FILES/bull.PNG
Cover properties cannot be used in classes.
Cover groups can be used in classes. So, cover groups can reference the variables in class.
http://testbench.in/FILES/bull.PNG
Cover groups are most useful at a higher level of abstractions where as cover property makes sense to use when we want to work at low level signals.

We can mix cover group and cover property to gain the OO and temporal advantages. Using properties for temporal expressions and trigger the cover group.

  • 8
    点赞
  • 79
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值