Functional coverage Flashcards
(25 cards)
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 };
When do we need to define bins
Typically auto created bins cover the domain on all possible values, based on size of coverpoint variable/expression
However, we may want to define explicit bins if
Create a grouping on bins
coverpoint tr.addr {
bins high = { [7:10] };
bins mid= { 5,6 };
bins<- low = { [0:4] };
}
Sometimes expected values are not power of 2
coverpoint ->(tr.size + tr.len + 5’h0)<- {
bins len[]<- = { [0:23] };
}
How to we limit number of bins created
We can use auto_bin_max option to control count of bins.
Can be used for CG or CP
options.auto_bin_max = <val></val>
Where do you add covergroup
It is always best to define CG at the boundary btw TB and RTL
Sampling must wait stimulus is actually received by the DUT.
Care must be taken to discard stimulus coverage for error injection cases. Have separate CG for error stimulus
Best to add CG to static classes, like ENV,DRV, etc.
Do not define CG in dynamic objections such as TXs.
What are bins?
They define the domain of possible values of a cover point.
They are automatically created for a defined CP., if nothing is explicitly specified.
We can limit the number of bins created using
coverpoint tr.addr {
options.auto_bin_max = <val>;</val>
}
What is cover group? Elaborate on this?
Collection of cover points which are sampled at the same time
Definition
covergroup <name> (<optional>) <optional wait event);</optional></name>
endgroup
Creation :
It always has to be created using “new()”
Can take arguments in new function
Trigger :
Explicit sample :
cg.sample();
Event triggered sampling
covergroup cg @(posedge clk);
What is cover point
Its a sampling point, which can be a variable or expression
Eg :
coverpoint tr.addr;
coverpoint {tr.len,tr.size};
When you will say that verification is completed?
Measures used to ensure verification completeness
Code coverage
Functional coverage
Bug rate
Each of these metrics help in deciding verification closure
High CC, Low FC
Feature missing in Design
Feature covered, but test unable to reach it, may need to fine tune stimulus
High FC, Low CC
Inadequate vplan
Unreachable code
High BR
Design unstable??
What is the importance of coverage in SystemVerilog verification?
Coverage is a generic term for measuring progress to complete design verification
Used as metric for verification completion
What is code coverage
Measures how much of the design implementation is exercised by the tests
lines of code(line coverage),
which paths through the code (path coverage)
expressions (expression coverage),
variables values (toggle coverage),
states and transitions in a state machine (FSM coverage).