Chapter 9 - Functional Coverage
Chapter 9 - Functional Coverage
Vinay Reddy
Department of Electronics & Communication Engineering
1
VERIFICATION OF DIGITAL SYSTEMS
Chapter 9
Functional Coverage
Vinay Reddy
Department of Electronics and Communication Engineering
2
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Functional coverage is a user-defined metric that measures how much of the design
specification, as enumerated by features in the test plan, has been exercised.
What is a test?
3
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
4
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage The covergroup construct is a user-defined type.
Covergroup
covergroup cov_grp_name ( [coverage_event] );
cross coverpoint_name,coverpoint_name;
endgroup
5
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage The covergroup construct is a user-defined type.
Covergroup
6
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
7
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
8
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage Edit code - EDA Playground
9
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
16 address options
10
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
16 address options
11
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
12
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
13
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Types of Covergroups :
Standalone
Embeded covergroup
15
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
16
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
17
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
18
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
19
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
20
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
21
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
22
VERIFICATION OF DIGITAL SYSTEMS
Chapter 9
Functional Coverage
Textbook Part
Vinay Reddy
Department of Electronics and Communication Engineering
23
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Coverage
What is Coverage?
Coverage is a generic term for measuring progress to complete design verification.
Coverage Types
Code Coverage
Functional Coverage
Bug rate
Assertion Coverage
25
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Code Coverage
Can measure:
which paths through the code and expressions have been executed (path coverage)
which single bit variables have had the values 0 or 1 (toggle coverage)
which states and transitions in a state machine have been visited (FSM Coverage)
26
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Code coverage measures how thoroughly the tests have exercised the
“implementation” of the design specification, and not the verification plan.
Reset logic missing in the above D-FF specification. However, code coverage
report would show full coverage. 27
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Functional Coverage
This can be useful in constrained random verification (CRV) to know what features
have been covered by a set of tests.
For example, the verification plan for the D-FF discussed earlier would mention not
only its data storage but also how it resets to a known state. 28
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Figure 9.1 shows the feedback loop to analyze the coverage results and decide on which actions to
take in order to converge on 100% coverage.
29
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Bug Rate
An indirect way to measure coverage is to look at the rate at which fresh bugs are
found.
Every time the rate slows down, it is necessary to find different ways to create
corner cases.
30
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Assertion Coverage
Assertions check relationships between design signals, either once or over a
period of time.
“cover property” statement can be used to look for interesting signal values or
design states.
How often the assertions are triggered during a test can be measured using
assertion coverage.
31
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
If the coverage levels are steadily growing -> you may just need to run existing tests with
new random seeds, or even just run longer tests.
If the coverage growth has started to slow -> you can add additional constraints to generate
more “interesting” stimuli.
When you reach a plateau -> some parts of the design are not being exercised, so you need
to create more tests.
Lastly, when your functional coverage values near 100%, check the bug rate.
If bugs are still being found, you may not be measuring true coverage for some areas of your
design.
32
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
33
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
3. Measuring Completeness
-> All coverage measurements and the bug rate need to be checked to see if the goal has been met.
34
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Coverage comparison
The tests are not exercising the full design, perhaps from
an inadequate verification plan.
35
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
36
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Samples 9.3 and 9.4 have part of a coverage report from VCS.
To improve your functional coverage, the easiest strategies are to run more simulation cycles, or
to try new random seeds.
37
The at least column specifies how many hits are needed before a bin is considered covered.
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
38
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
If the transaction contains an error, it needs a different cover point created just for error
handling.
39
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Anatomy of a Cover Group
Defining a Cover Group in a Class
If the cover group is defined in a class, it is known as
an embedded covergroup.
40
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
https://www.edaplayground.com/x/JPtQ
41
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
42
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
43
VERIFICATION OF DIGITAL SYSTEMS
Chapter 9
Functional Coverage
bins – Conceptual Part
Vinay Reddy
Department of Electronics and Communication Engineering
44
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
45
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Total no of bins : 6
46
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Total no of bins : 8
47
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
49
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
50
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
51
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
52
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
53
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
54
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
55
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Conditions on bins
Conditions on Coverpoints
Conditions on cross 56
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
57
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
58
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
2 bins
2 bins
4 bins
Total : 8 bins
59
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
60
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
61
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
No of bins 4
No of bins 4
62
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
63
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
64
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
65
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
66
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
67
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
68
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
69
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
4 bins
4 bins
6 bins
These are not covered, hence auto bins are
created for this combination of cross
3 bins
Total – 17 bins 70
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
71
VERIFICATION OF DIGITAL SYSTEMS
Chapter 9
Functional Coverage
bins – Textbook Part
Vinay Reddy
Department of Electronics and Communication Engineering
72
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Data Sampling
When you specify a variable or expression in a cover point, SystemVerilog creates a number of “bins”
to record how many times each value has been seen.
These bins are the basic units of measurement for functional coverage.
73
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
To calculate the coverage for a point, you first have to determine the total number of possible
values, also known as the domain.
A cover point that is a 3-bit variable has the domain 0:7 and is normally divided into eight bins.
If, during simulation, values belonging to seven bins are sampled, the report will show 7/8 or 87.5%
coverage for this point.
All these points are combined to show the coverage for the entire group, and then all the groups are
combined to give a coverage percentage.
74
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
System Verilog automatically creates bins for cover points. It looks at the domain of the
sampled expression to determine the range of possible values.
For an expression that is N bits wide, there are 2 ^ N possible values. For the 3-bit variable
dst , there are 8 possible values.
75
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
For example, a 16-bit variable has 65,536 possible values, so each of the 64 bins covers 1024 values.
76
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Sample 9.12 used auto_bin_max as an option for the cover point only. You can also use it
as an option for the entire group as shown in Sample 9.14 .
77
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Sampling Expressions
78
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Sampling Expressions
For example, sampling a 3-bit header length (0:7) plus a 4-bit payload length (0:15) creates only 2 4 or
16 bins, which may not be enough if your transactions can actually be from 0 to 22 bytes long.
81
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
When you define the bins, you are restricting the values used for coverage to those that
are interesting to you.
SystemVerilog no longer automatically creates bins, and it ignores values that do not fall
into a predefined bin.
More importantly, only the bins you create are used to calculate functional coverage.
You get 100% coverage only as long as you get a hit in every specified bin.
82
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
In Sample 9.20 , the $ in the range for bin neg represents the negative number
furthest from zero: 32¢h8000_0000, or -2,147,483,648.
The $ in bin pos represents the largest signed positive value, 32’h7FFF_FFFF, or
2,147,483,647.
83
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Conditional Coverage
You can use the iff keyword to add a condition to a cover point.
84
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Here is part of the coverage report from VCS, Sample 9.24 showing the bins
for the enumerated types.
85
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Transition Coverage
You can specify state transitions for a cover point.
For example, you can check if dst ever went from 0 to 1, 2, or 3 as shown in Sample 9.25 .
86
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
You use the wildcard keyword to create multiple states and transitions.
87
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Ignoring Values
you can let SystemVerilog automatically create bins, and then use ignore_bins
to tell which values to exclude from functional coverage calculation like in Sample
9.27 .
88
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
If you define bins either explicitly or by using the auto_bin_max option, and then ignore
them, the ignored bins do not contribute to the calculation of coverage.
In Sample 9.28 , four bins are initially created using the auto_bin_max option: 0:1, 2:3, 4:5,
and 6:7.
However, then the uppermost bin is eliminated by ignore_bins , so in the end only three bins
are created.
89
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Illegal Bins
Some sampled values not only should be ignored, but also should cause an error if they are seen.
This is best done in the testbench’s monitor code, but can also be done by labeling a bin with illegal_bins.
90
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
If a cover group is used on a state machine, you can use bins to list the
specific states, and transitions for the arcs.
91
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Cross Coverage
Cross coverage measures what values were seen for two or more cover points
at the same time.
Note that when you measure cross coverage of a variable with N values, and of
another with M values, SystemVerilog needs N X M cross bins to store all the
combinations.
92
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
94
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
95
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
96
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
97
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
98
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
99
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
100
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
101
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
Excluding Cover Points from the Total Coverage Metric
If you are only sampling a variable or expression in a coverpoint to be used in a cross
statement, you should set its weight to 0 so that it does not contribute to the total coverage.
102
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
103
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
104
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
105
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
106
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
When new values are ready (such as when a transaction has completed), your
testbench triggers the cover group.
This can be done directly with the sample function, as shown in Sample 9.5 , or by
using a coverage event in the covergroup definition. 107
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
108
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
109
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
110
VERIFICATION OF DIGITAL SYSTEMS
Functional Coverage
111
THANK YOU
Vinay Reddy
Department of Electronics & Communication Engineering
[email protected]
+91 9945730244
112