Previous Section Next Section

10.2 Coverage Groups

A coverage group is a struct member defined by the cover keyword. A coverage group contains a description of data items for which data are collected over time. A coverage group has an associated event that tells when to sample and collect data. The event must be declared in the same struct as the coverage group. The syntax for a coverage group definition is as follows:

cover event-type [using coverage-group-option, ...] is {coverage-item-definition; ...};

Table 10-1 defines components of a coverage group definition.

Table 10-1. Components of a Coverage Group Definition

event-type

The name of the group. This must be the name of an event type defined in the same struct. The event must not have been defined in a subtype.

The event is the sampling event for the coverage group. Coverage data for the group are collected every time the event is emitted.

The full name of the coverage group is struct-exp.event-type. The full name must be specified for the show cover command and other coverage commands and methods.

coverage-group-option

Each coverage group can have its own set of options. The options can appear in any order after the using keyword. The coverage group options listed in Table 10-2 can be specified with the using keyword.

coverage-item-definition

The definition of a coverage item.

is also

Coverage groups can be extended like other struct members.

is empty

The empty keyword can be used to define an empty coverage group that will be extended later, using a cover is also struct member with the same name.

Table 10-2 shows options while defining coverage groups.

Table 10-2. Coverage Group Options

Option

Description

no_collect

This coverage group is not displayed in coverage reports and is not saved in the coverage files. This option enables tracing of coverage information and enables event viewing with echo event, without saving the coverage information.

count_only

This option reduces memory consumption because the data collected for this coverage group are reduced. You cannot do interactive, post-processing cross coverage of items in count_only groups. The coverage configuration option count_only sets this option for all coverage groups.

text=string

A text description for this coverage group.

This can only be a quoted string, not a variable or expression. The text is shown at the beginning of the information for the group in the coverage report (displayed with the show cover command).

when=bool-exp

The coverage group is sampled only when bool-exp is TRUE. The bool-exp is evaluated in the context of the parent struct.

global

A global coverage group is a group whose sampling event is expected to occur only once. If the sampling event occurs more than once, Specman Elite issues a DUT error. If items from a global group are used in interactive cross coverage, no timing relationships exist between the items.

radix=DEC|HEX|BIN

Buckets for items of type int or uint are given the item value ranges as names. This option specifies in which radix the bucket names are displayed. A bucket is a group of different values of a coverage item collected for coverage.

The global print radix option does not affect the bucket name radix.

Legal values are DEC (decimal), HEX (hexadecimal), and BIN (binary). The value must be in uppercase letters.

If the radix is not used, int or uint bucket names are displayed in decimal.

weight=uint

This option specifies the grading weight of the current group relative to other groups. It is a nonnegative integer with a default of 1.

Example 10-1 shows sample coverage definitions that use coverage group options.

Example 10-1 Coverage Group Definition
Example shows coverage group definition.
<'
type cpu_opcode: [ADD, SUB, OR, AND, JMP, LABEL];
struct inst {
    reset_done: bool; //Set by some struct in sys. Not shown.
    opcode: cpu_opcode; //Define enumerated type field.
    good_opcode: bool; //Define boolean.
    event info; //Event that defines coverage group name.
                //Coverage samples are collected when the
                //data_change event is emitted.

    cover info using //Define coverage group
               count_only, //count_only option.
               radix = HEX, //Display in hex format.
               weight = 10, //Relative weight compared to
                            //other groups.
               when = (reset_done == TRUE) //Collect coverage only
                                         //when this bool
                                         //expression is true.
    is {
        item opcode; //Item opcode is to be covered.
    };

    run() is also { //Emit the coverage events in the run() method.
          emit info; //Emit the event that causes coverage samples to
                     //be taken.
    };}; //end of struct inst


type cpu_state: [START, FETCH1, FETCH2, EXEC]; //Enumerated type.
struct cpu {
    init_complete: bool; //Set by some struct in sys. Not shown.
    event state_change; //Define event for coverage group.
    cover state_change using //State machine coverage group.
            text = "Main state-machine", //Name of coverage group.
            weight = 5, //Relative weight
            when = (init_complete == TRUE) //Collect sample only if
                                           //bool exp is true.
    is {
    //Coverage of HDL state machine state variable.
    item st: cpu_state = '~/top/cpu/main_cur_state';
    };
    run() is also { //Emit the coverage events in the run() method.
        emit state_change; //Emit the event that causes coverage
    };                     //samples to be taken.

};
'> End of e code

10.2.1 Extending Coverage Groups

A coverage group can also be extended like any other struct member by means of the is also keyword. Example 10-2 shows the extension of the coverage group defined in Example 10-1.

Example 10-2 Extending Coverage Groups
Example shows how to extend coverage groups
<'
extend inst {
    cover info is also { //Extend the coverage group.
        item good_opcode; //Item good_opcode is also to be covered
                          //in addition to item opcode.
    };
}; //end of extension of struct inst
'>

There are three types of items in a coverage group: basic coverage items, transition items, and cross items. Figure 10-1 shows the three types of items in a coverage group. These items are discussed in detail in the following sections.

Figure 10-1. Coverage Group Items

graphics/10fig01.gif

Previous Section Next Section