Functional coverage Flashcards
How to detect overlapping bins
We can used below option
option.detect_overlap=boolean
Default value = false/0
When true, reports a warning for an overlap between the range list of the two bins of a coverpoint.
Applicable to CG & CP
Can we display uncovered bins
Below option saves uncovered cross-product bins in the coverage database and includes them in the coverage report.’
Applicable to only Cross coverpoint
options.cross_num_print_missing = <num></num>
Default value of num =0;
I want to ensure that only multiple hits to a bin is contributing to coverage
We can customize the atleast count which is 1 by default
It can be applicable to both CG and CP
option.at_least = 10; // only when 10hits are reached, it is counted as covered
What if I am ok with <100 coverage?
We can set the goal of covergroup to give value
covergroup cg;
option.goal = 80;
endgroup
Annotate covergroups
We can add comment to define covergroup
covergroup cg;
option.comment = “Sample CG”;
endgroup
What is per instance coverage
Cases where we want to capture coverage per instance :
Say we have multiple instances of a driver which have CG defined
We have defined a generic CG and need to capture coverage separately for each instance
We use below option to CG
option.per_instance =1
Example of bins of cross coverage
covergroup Covport;
port: coverpoint tr.port {
bins port[] = {[0:$]};
}
kind: coverpoint tr.kind {
bins lo = {[$:5]};
bins hi[] = {[8:$]};
bins misc = default;
}
cross kind, port {
bins all_zero = binsof(port) intersect{0} && binsof(kind) intersect {0};
ignore_bins lo = binsof(kind.lo);
}
endgroup
How do we exclude coverpoints from converage metric
For cases, where we only need cross coverage, and defined a coverpoint to facilitate cross coverage, we can set weight of coverpoint to 0.
addr : coverpoint tr.addr {
option.weight = 0;
}
len : coverpoint tr.len{
option.weight = 0;
}
cross addr,len;
How to create generic cover groups
We can create covergroup, which take args, which are used internally.
This needs to be passed during construction : new()
Signal being passed should be using ref qualified. Otherwise only the signals at new will be sampled.
covergroup cg_addr(ref logic[31:0] addr,input int val) { coverpoint addr { bins low = {[$:val]}; bins high = {[val+1,$]}; } option.per_instance =1; endgroup covergroup cg_addr; cg_addr = new(tr.addr,5);
CG can also take constant as input, but ensure it is not of ref type, but input type
What is cross coverage
Cross coverage is useful when we want to measure coverage of coverpoint combinations
It takes coverpoint or single variable name as argument
Here coverpoints should be local to the covergroup, and should be named
Like coverpoints, we can define bins for cross
covergroup CovPort;
kind: coverpoint tr.kind;
port : coverpoint tr.port;
cross kind, port;
endgroup
Can we catch incorrect traffic
We can use illegal_bins to generate error when we hit the defined bin
coverpoint tr.size {
illegal_bins unaliagned = { 0,1};
}
Do do we remove invalid bins
We can define explicitly all valid bins using “bins” construct.
However, we have huge bin set, but want to exclude for of the values, we can use ignore bins as below :
coverpoint tr.awsize {
–> ignore_bins unaligned = {0,1};
}
When used in combination with auto_bin_max , the value is applied as
{ actual domain - illegal domain } / val
not {actual_domain}/val - illegal_domain
How to track transition coverage
We can add bins to define transition of coverpoints
Egs :
coverpoint tr.len {
bins rise_fall = (0=>1), (1=>0);
}
coverpoint irq {
bins assert_for_3_clks = (0=>1[*3] => 0);
}
coverpoint req {
bins req_for_3_to_5_clks = (0 =>1[*3:5] => 0);
}
How to control coverage sampling
Trigger event
covergroup cp @(event); cp1 : coverpoint addr; endgroup initial begin cp c1 = new(); ->event; addr = 1; -> event; end
As sampling is controlled by event,we can disable sampling,
c1.stop();
c1.start();
Explicit trigger
Then we can call sample() on when we need to collect data
~~~
initial begin
cp c1 = new();
c1.sample();
end
~~~
Implicit trigger present :
Disable CG :
Define a disable condition in covergroup
coverpoint tr.addr iff( !apb.reset_n) {..} coverpoint tr.len iff( error_event);
Examples of wildcards in functional coverage
We can use wildcards in defining list range, like in dynamic lists
coverpoint tr.len { bins low = {2:4]}; bins mid = {5,6}; bins high = { [7:$] }; <--- here $ denotes highest valid value bins misc = default ; }
For defining bins with dontcare conditions :
coverpoint tr.addr[7:0] { --> wildcard bins unaligned_addr { 8'h?1, 8'h?2, 8'h?3, 8'h?5, 8'h?6, 8'h?7}; wildcard bins aligned_addr { 8'h?0, 8'h?4 };