Hardware Reference
In-Depth Information
Example 18.6.
covergroup
cover_delay @(
posedge
clk);
dl_pt:
coverpoint
delay {
bins
delays [100]: {[10:110]};
}
dt_pt:
coverpoint
data;
dlXdt:
cross
dt_pt, dl_pt;
endgroup
cover_delay cover_delay_inst =
new
();
t
The
covergroup
definition is named
cover_delay
.The
covergroup
tracks two
variables,
delay
and
data
. They are identified by using the keyword
coverpoint
and by labeling them
dl_pt
and
dt_pt
, respectively. The variable values are
read whenever the clocking event
@(
posedge
clk)
occurs and are recorded into
individual bins according to their values.
For
dl_pt
, there is an array
delays
of 100 bins into which the occurrence counts
of values of
delay
in the range
[10:110]
are maintained. In other words, when the
recorded value of
delay
is
10
the bin
delays[0]
is incremented; if it is, say, 100
then the bin
delays[90]
is incremented; etc.
For
dt_pt
, the bins are allocated automatically. By default, there are at
most 64 bins, but that value can be changed by an optional specification
auto_bin_max=number
of the
covergroup
. If the value range of the sampled
variable is less than the specified maximum, the number of bins is that of the
variable range. If the range is larger than the maximum, then the variable values are
uniformly distributed over the bins.
The cross correlation
dlXdt
of the values of
delay
and
data
is specified using
the keyword
cross
. This defines a set of pairs of values consisting of the Cartesian
product of the sets of bins of
coverpoint
sof
dl_pt
and
dt_pt
. In this way, the
user can observe the correlated pairs of values of
data
and
delay
that occurred
during the simulation.
The clocking event can be replaced by an interface definition of the
sample
method as follows:
covergroup
cover_delay
with function
sample(
int unsigned
delay,
logic
[7:0] data);
In this case, the coverage is triggered when the method
sample
is called. The
actual arguments must be type-compatible with the formal arguments of the method.
Note that the formal argument names match exactly those of the
coverpoint
variables
delay
and
data
. In this way, the same
covergroup
instance can read
different variables passed as actuals to instances of the
sample
function and collect
the coverage information in the same bins. Using the method is especially helpful
when new instances of the variables are created over and over, as in the example
in the following section where local variables are passed to a
covergroup
instance.
When no clocking event or sample method is explicitly specified, the default
sample
method is available to trigger sampling of
coverpoint
variable values.
Search WWH ::
Custom Search