Skip to content

Coverpoint definition improvements

Compare
Choose a tag to compare
@amiq-consulting amiq-consulting released this 09 Oct 09:52
· 64 commits to master since this release

This release contains new functionality and changes that add to the quality of the library.
See details below.

New Coverpoint definition method

New

int data_value = 0;
// The coverpoint samples the value returned by the evaluation of the "data_value * 2" expression.
// The evaluation is done at the call to the sample() function of the parent covergroup.
COVERPOINT(int, data_cvp, data_value * 2) {
    illegal_bin<int>("illegal_zero", 0),
    bin<int>("positive", interval(1,INT_MAX)),
    bin<int>("negative", interval(-1,INT_MIN))
};

Old

// Step 2: bind variable to coverpoint
int SAMPLE_POINT(data_value, data_cvp);
// Step 1:  declare coverpoint
coverpoint<int> data_cvp = coverpoint<int> (
    this,
    illegal_bin<int>("illegal_zero", 0),
    bin<int>("positive", interval(1,INT_MAX)),
    bin<int>("negative", interval(-1,INT_MIN))
);
// Step 3: update coverpoint variable and sample it 
void sample(int data) {
    this->data_value = data;
    covergroup::sample();
}

Benefits for the new syntax:

  1. Gets rid of the extra step of using SAMPLE_POINT(...)) macro which has the following problems:
    • A segmentation fault would be generated if SAMPLE_POINT(...); was declared after its associated coverpoint is instantiated (Note above: Step 2 precedes Step 1)
    • Relied on the user manually binding a sample variable to the coverpoint, which is error prone
    • Restricted sampling to be made on the value of a variable, not supporting complex/compound expressions
  2. Adds support for sample expressions & sample conditions
  3. Custom covergroup sample function is no longer required
  4. It is much clearer, easier to use and much more similar to SystemVerilog standard coverpoint definitions.

The old definition syntax is still (currently) supported, but considered deprecated and will be removed in the future!

Sample condition example

int data_value = 0;
int threshold = 0;
// The 4th argument represents the sample condition. Similar to sample expression, the condition 
// is evaluated and checked at the call to the sample() function of the parent covergroup.
// In this case, the coverpoint is sampled if the value of the threshold variable is bigger than 50.
COVERPOINT(int, data_cvp, data_value * 2, threshold > 50) {
    illegal_bin<int>("illegal_zero", 0),
    bin<int>("positive", interval(1,INT_MAX)),
    bin<int>("negative", interval(-1,INT_MIN))
};

New Coverpoint definition restriction

Coverpoints must contain at least one bin; Empty coverpoints are no longer allowed!
Note: this constraint is valid for the new definition method only!

New Bin definition restrictions

  • Bin name must now be specified; Unnamed bins are no longer allowed!
    • Note: The name must be the first argument to the constructor!
  • The bin must contain at least one value/interval; Empty bins are no longer allowed!

Example:

auto my_bin = bin<int>(
    "power_of_2",
    1,              // {1}
    interval(2,3),  // [2:3]
    interval(7,4),  // [4:7]
    interval(15,8)  // [8:15]
);

If any of the coverpoint/bin definition restrictions are not met, compilation will fail!