Previous Section Next Section

10.3 Basic Coverage Item

A basic coverage item can be one of the following three elements.

A basic coverage item can be specified with options that control how coverage data are collected and reported for the item. The item can be an existing field name or a new name. If you use a new name for a coverage item, you must specify the item's type and the expression that defines it. The syntax for a basic coverage group item is as follows:

item item-name[:type=exp] [using coverage-item-option, ...];

Table 10-3 describes the important coverage item options. These options can be specified with the definition of each basic coverage item.

Table 10-3. Basic Coverage Item Options

Option

Description

per_instance

Coverage data are collected and graded for all the other items in a separate listing for each bucket of this item.

text=string

A text description for this coverage item. This can only be a quoted string, not a variable or expression.

when=bool-exp

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

at_least=num

The minimum number of samples for each bucket of the item. Anything less than num is considered a hole.

ranges ={range(parameters);}

Create buckets for this item's values or ranges of values.

ignore=item-bool-exp

Defines values that are to be completely ignored. They do not appear in the statistics at all. The expression is a boolean expression that can contain a coverage item name and constants.

illegal=item-bool-exp

Defines values that are illegal. An illegal value causes a DUT error.

radix=DEC|HEX|BIN

Specifies the radix used to display coverage item values.

weight=uint

Specifies the weight of the current item relative to other items in the same coverage group. It is a non-negative integer with a default of 1.

name

Assigns an alternative name for a cross or transition item.

Example 10-3 illustrates basic coverage items.

Example 10-3 Basic Coverage Items
Example shows three types of basic coverage items:
- Fields in a local struct
- Fields in another struct
- HDL signals
An item must have a name if it is assigned to a field
in another struct or an HDL signal. For fields in a local
struct, the field name can be the item name.
See the item options with each item.

<'
type cpu_opcode: [ADD, SUB, OR, AND, JMP, LABEL];
type cpu_reg: [reg0, reg1, reg2, reg3];
struct inst {
    opcode: cpu_opcode;
    op1: cpu_reg;
    op2: byte;
    event inst_driven;
    cover inst_driven is { //Three types of items
        //Field op1 in local struct, see item options
        item op1 using weight = 5, radix = DEC;
        //Field op2 in local struct, see item options
        item op2 using ignore = 0, radix = HEX, at_least = 10;
        //Name op2_big equal to boolean expression, see item options
        item op2_big: bool = (op2 >= 64) using weight = 10;
        //Name op3 equal to field in another struct
        item op3: bool = sys.header.op3;
        //Name hdl_sig equal a HDL variable value
        item hdl_sig: int = '~/top/sig_1';
    };
};
'>

10.3.1 Basic Coverage Item Ranges

When one is covering int/uint types, it is not practical or necessary to cover the entire range of values for a 32-bit integer. Therefore, it is necessary to create a bucket for each boundary value or a range of values. Buckets can be created by means of the ranges option. Each bucket counts the number of samples within its range. The syntax for the ranges option is as follows:

ranges = {range(parameters); range(parameters); ...}
range(range: range, name: string, every-count: int, at_least-num: int);

The arguments to range() are shown in Table 10-4 below.

Table 10-4. Arguments to range() for Basic Coverage Item

range

The range for the bucket. It must be a literal range such as "[1..5]", of the proper type. Even a single value must be specified in brackets (for example "[7]"). If you specify ranges that overlap, values in the overlapping region go into the first of the overlapping buckets. The specified range for a bucket is the bucket name. That is, the buckets above are named "[1..5]" and "[7]".

name

A name for the bucket. If you use the name parameter, you cannot use an every-count value. You must enter UNDEF for the every-count parameter.

every-count

The size of the buckets to create within the range. These buckets get automatically created by the every-count parameter. If you use the every-count parameter, you cannot use a name. You must enter an empty string ("") as a placeholder for the name parameter.

at-least-num

A number that specifies the minimum number of samples required for a bucket. If the item occurs fewer times than this, a hole is marked. This parameter overrides the global at_least option and the per-item at_least option. The value of at-least-num can be set to zero, meaning "do not show holes for this range."

Example 10-4 illustrates the ranges option.

Example 10-4 Ranges Option for Basic Coverage Item
Example of basic coverage group item using the ranges option
<'
struct pcc {
    pc_on_page_boundary: uint (bits: 15); //Local field
    pc: uint (bits: 15); //Local field
    stack_change: byte; //Local field

    event pclock; //Coverage group event
    cover pclock is { //Define coverage group
        item pc_on_page_boundary using //Cover the local field
            ranges = { //Ranges option
                range([0], "0"); //Only one value (0) in bucket
                range([4k], "4k"); //Only one value (4k) in bucket
                range([8k], "8k"); //Only one value (8k) in bucket
                range([12k], "12k"); //Only one value (12k) in bucket
                range([16k], "16k"); //Only one value (16k) in bucket
                range([20k], "20k"); //Only one value (20k) in bucket
                range([24k], "24k"); //Only one value (24k) in bucket
                range([28k], "28k"); //Only one value (28k) in bucket
                range([0..32k-1], "non-boundary"); //Default buckets
            };

        item pc using radix = HEX, //Cover the local field
        ranges = { //Ranges option
                //range is 0..4k-1, name = page_0
                //Cannot use every_count(UNDEF) due to name for range
                //at_least = 4 samples needed in this bucket
                range([0..4k-1], "page_0", UNDEF, 4);
                //range is 4k..32k-1, no name
                //every_count = 8k, creates buckets of 8k size
                //at_least = 2 samples needed in this bucket
                range([4k..32k-1], "", 8k, 2);
            };
        item stack_change using //Cover the local field
            //Range is 0..32 divided into buckets of size 1
            //i.e. 33 buckets
            ranges = { range( [0..32], "", 1); };
    };
    run() is also {
        emit pclock; //Collect coverage
    };
};
'>
Previous Section Next Section