返回介绍

20.2 定义覆盖模型:covergroup

发布于 2020-09-09 22:55:56 字数 7001 浏览 1325 评论 0 收藏 0

The covergroup construct encapsulates the specification of a coverage model. Each covergroup specification can include the following components:

  • A clocking event that synchronizes the sampling of coverage points
  • A set of coverage points
  • Cross coverage between coverage points
  • Optional formal arguments
  • Coverage options
The covergroup construct is a user-defined type. The type definition is written once, and multiple instances of that type can be created in different contexts. Similar to a class, once defined, a covergroup instance can be created via the new() operator. A covergroup can be defined in a module, program, interface, or class.

covergroup_declaration ::=        // from Annex A.2.11
    covergroup covergroup_identifier[([tf_port_list])][coverage_event];
        {coverage_spec_or_option;}
    endgroup [: covergroup_identifier]

coverage_spec_or_option ::=
    {attribute_instance} coverage_spec
  | {attribute_instance} coverage_option;

coverage_option ::=
    option.member_identifier = expression
  | type_option.member_identifier = expression

coverage_spec ::=
    cover_point
  | cover_cross

coverage_event ::=
    clocking_event
  | @@(block_event_expression)

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

hierarchical_btf_identifier :: =
    hierarchical_tf_identifier
  | hierarchical_block_identifier
  | hierarchical_identifier [class_scope] method_identifier

variable_decl_assignment ::=           // from Annex A.2.4
    ...
  | [covergroup_variable_identifier] = new[(list_of_arguments)] // 16

16. It shall be legal to omit the covergroup_variable_identifer from a covergroup
    instantiation only if this implicit instantiation is within a class that has no
    other instantiation of the covergroup.

Syntax 20-1—Covergroup syntax (excerpt from Annex A)

The identifier associated with the covergroup declaration defines the name of the coverage model. Using this name, an arbitrary number of coverage model instances can be created. For example:

covergroup cg; ... endgroup
cg cg_inst = new;

The above example defines a covergroup named cg. An instance of cg is declared as cg_inst and created using the new operator.

A covergroup can specify an optional list of arguments. When the covergroup specifies a list of formal arguments, its instances must provide to the new operator all the actual arguments that are not defaulted. Actual arguments are evaluated when the new operator is executed. A ref argument allows a different variable to be sampled by each instance of a covergroup. Input arguments will not track value of their arguments; they will use the value passed to the new operator.

If a clocking event is specified, it defines the event at which coverage points are sampled. If the clocking event is omitted, users must procedurally trigger the coverage sampling. This is done via the built-in sample() method (see Section 20.7). Optionally, the strobe option can be used to modify the sampling behavior. When the strobe option is not set (the default), a coverage point is sampled the instant the clocking event takes place, as if the process triggering the event were to call the built-in sample() method. If the clocking event occurs multiple times in a time step, the coverage point will also be sampled multiple times. The strobe option (see Section 20.6.1) can be used to specify that coverage points are sampled in the postponed region, thereby filtering multiple clocking events so that only one sample per time slot is taken.

As an alternative to a clocking event, a coverage group accepts a block event expression to indicate that the coverage sample is to be triggered by the start or the end of execution of a given named block, task, function, or class method. Block event expressions that specify the begin keyword followed by a hierarchical identifier denoting a named block, task, function, or class method shall be triggered immediately before the corresponding block, task, function, or method begins executing its first statement. Block event expressions that specify the end keyword followed by a hierarchical identifier denoting a named block, task, function, or class method shall be triggered immediately after the corresponding block, task, function, or method executes its last statement.Block event expressions that specify the end of execution shall not be triggered if the block, task, function, or method is disabled.

A covergroup can contain one or more coverage points. A coverage point can be a variable or an expression. Each coverage point includes a set of bins associated with its sampled values or its value-transitions. The bins can be explicitly defined by the user or automatically created by the tool. Coverage points are discussed in detail in Section 20.4.

enum { red, green, blue } color;
covergroup g1 @(posedge clk);
    c: coverpoint color;
endgroup

The above example defines coverage group g1 with a single coverage point associated with variable color. The value of the variable color is sampled at the indicated clocking event: the positive edge of signal clk. Since the coverage point does not explicitly define any bins, the tool automatically creates 3 bins, one for each possible value of the enumerated type. Automatic bins are described in Section 20.4.2.

A coverage group can also specify cross coverage between two or more coverage points or variables. Any combination of more than two variables or previously declared coverage points is allowed. For example:

enum { red, green, blue } color;
bit [3:0] pixel_adr, pixel_offset, pixel_hue;

covergroup g2 @(posedge clk);
    Hue: coverpoint pixel_hue;
    Offset: coverpoint pixel_offset;
    AxC: cross color, pixel_adr; // cross 2 variables (implicitly declared
    // coverpoints)
    all: cross color, Hue, Offset; // cross 1 variable and 2 coverpoints
endgroup

The example above creates coverage group g2 that includes 2 coverage points and two cross coverage items. Explicit coverage points labeled Offset and Hue are defined for variables pixel_offset and pixel_hue. SystemVerilog implicitly declares coverage points for variables color and pixel_adr in order to track their cross coverage. Implicitly declared cover points are described in Section 20.5.

A coverage group can also specify one or more options to control and regulate how coverage data is structured and collected. Coverage options can be specified for the coverage group as a whole, or for specific items within the coverage group, that is, any of its coverage points or crosses. In general, a coverage option specified at the covergroup level applies to all of its items unless overridden by them. Coverage options are described in Section 20.6.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文