Whitepaper Using Coverage With Vcs On Solvnet
Whitepaper Using Coverage With Vcs On Solvnet
March 2023
Copyright Notice and Proprietary Information
2023 Synopsys, Inc. All rights reserved. This Synopsys software and all associated documentation are proprietary to
Synopsys, Inc. and may only be used pursuant to the terms and conditions of a written license agreement with
Synopsys, Inc. All other use, reproduction, modification, or distribution of the Synopsys software or the associated
documentation is strictly prohibited.
Disclaimer
SYNOPSYS, INC., AND ITS LICENSORS MAKE NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH
REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Trademarks
Synopsys company and certain product names are trademarks of Synopsys, as set forth at http://www.synopsys.com/
company/legal/trademarks-brands.html.
All other product or company names may be trademarks of their respective owners.
Third-Party Links
Any links to third-party websites included in this document are for your convenience only. Synopsys does not endorse
and is not responsible for such websites and their practices, including privacy practices, availability, and content.
Synopsys, Inc.
690 E. Middlefield Road
Mountain View, CA 94043
www.synopsys.com
ii
Contents
1. Overview
2. Verification Planning
3. Code Coverage
Control-Flow Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3
Value Coverage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
4. Functional Coverage
Basic Rules for Covergroup Merging . . . . . . . . . . . . . . . . . . . . . 4-2
Covergroup Shapes in a Design . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Covergroup Shape Changes Due to Edits . . . . . . . . . . . . . . . . . 4-4
Feedback
iii
6. Targeting Parts of Your Design
8. Generating Reports
Metrics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Ratios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Trend Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
Navigating Coverage Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
9. Convergence
Constant Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-2
Adaptive Exclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3
Feedback
iv
Overview Overview
1-1
1
Overview 1
VCS® provides industry-leading coverage and planning capabilities
for SystemVerilog, VHDL, and mixed-language designs. A wide
range of coverage metrics are available, with detailed control
available to users. The power and flexibility of VCS' coverage tools
provide support for many different coverage methodologies, but the
range of options available may be a bit overwhelming for new users.
Overview
1-1
Overview
• “Verification Planning”
• “Code Coverage”
• “Functional Coverage”
• “Managing Coverage Data Files”
• “Targeting Parts of Your Design”
• “Merging Coverage Data”
• “Generating Reports”
• “Convergence”
• “Test Grading”
1-2
Verification Planning Verification Planning
2-1
2
Verification Planning 1
The purpose of planning is to create and maintain consistent links
between the verification specification and the tests, coverage and
other data collected to provide actionable information, organized by
the plan specification, towards functional verification sign off. A
linked verification plan provides traceability from the specification
details to the individual-measured metric values.
The figure below shows how the specifications, plans, and data
come together to track progress and status. Links to the
specifications ensure that every feature in the specification has a
corresponding feature in the plan. Links to verification data ensure
that anything below target (low coverage, tests failing, etc.) is
presented and linked to the feature to highlight needed action and
owners.
Verification Planning
2-1
Verification Planning
The best way to create a verification plan is to start with the written
specification documents. Create a top-level plan feature for each
major feature in the specification, and then fill in sub-features to
match. At its most basic, the goal of a plan is to see which parts of
the project are on track and which need help, so dividing features
into areas of responsibility is a good way to start.
2-2
Verification Planning Verification Planning
2-3
If you want to link objects to the plan that do not yet exist in the
database, you can enter their names as sources in the plan. When
they are added to the design in later iterations, Verdi automatically
finds them and annotates their scores in the design. For example,
you can use the name of a covergroup that will be written later as a
source. You can also use wildcard expressions, so if you have a
naming convention for sources, you can have Verdi automatically
find any matching sources.
Verification Planning
2-3
Verification Planning
2-4
Code Coverage Code Coverage
3-1
3
Code Coverage 1
When deciding what metrics and options to use, it is important to
remember that each metric has a cost - in simulation overhead, to
some degree, but more importantly in coverage closure overhead.
Once you commit to a certain set of metrics, you are committing the
time it takes to develop tests, analyze results, apply waivers/
exclusions, and, ultimately, reach your coverage goals.
There are two types of information that code coverage monitors. The
first is control-flow coverage that tracks which lines, paths, and
branches are taken - the flow of execution through each executable
statement in the SystemVerilog or VHDL code. Control-flow metrics
include line coverage and branch coverage.
The second type is value coverage that monitors what values signals
and expressions take on during simulation. Value-coverage metrics
include condition coverage, toggle coverage, and FSM coverage,
which track the values (or value transitions) for signals and variables.
Code Coverage
3-1
Code Coverage
If your design has less procedural code, use the following compile
options:
3-2
Code Coverage Code Coverage
3-3
• “Control-Flow Coverage”
• “Value Coverage”
Control-Flow Coverage
Code Coverage
3-3
Code Coverage
x = a ? y : ( b ? z : w );
// branch 1: a is true, assign y
// branch 2: a is false and b is true, assign z
// branch 3: a and b are both false, assign w
In the next example, there are four branches (one for each of the
true/false arms of the two if statements).
if (a)
x <= 1'b0; // branch 1
else
x <= 1'b1; // branch 2
if (b)
y <= 1'b0; // branch 3
else
y <= 1'b1; // branch 4
Value Coverage
3-4
Code Coverage Code Coverage
3-5
VCS tracks two expressions - the 'or' expression and the 'and'
expression. When -cm_cond obs is given, the 'and' expression is
only monitored when the value of a is zero, as the values of b and d
have no effect on the result if a is true.
Code Coverage
3-5
Code Coverage
To invoke toggle coverage, use the -cm tgl option. For example:
3-6
Functional Coverage Functional Coverage
4-1
4
Functional Coverage 1
Functional coverage consists of two metric types: covergroups and
cover properties/assertions. Functional coverage is not
automatically discovered from the HDL code. It is explicitly created
by you or IP vendors and specifically targeted to the intended
functionality or implementation of the design.
Functional Coverage
4-1
Functional Coverage
module mymod;
…
mygroup g1 = new(x, y, z);
endmodule
top.a4b::addum
top.a4a::addum
top.a4c::addum
4-2
Functional Coverage Functional Coverage
4-3
$unit(test.v)::addum
When a covergroup is split into shapes this way, VCS uses the base
name of the group and adds the parameter values that differentiate
the shapes. For example, if a parameter p is used to determine the
number of bins in a coverpoint, we might have the following in the
report:
$unit(test.v)::addum::SHAPE{p=16}
$unit(test.v)::addum::SHAPE{p=32}
Functional Coverage
4-3
Functional Coverage
$unit(test.v)::addum
$unit(test.v)::addum
While it is not the default, the best option when the covergroup
models are changing frequently is to use the flexible merging options
supported by VCS.
Flexible merging allows you to merge the data from the latest
versions of your covergroup models with the data collected from
previous versions. In the flexible merging flow, you can change the
number of bins in a coverpoint, add or delete coverpoints, modify
crosses, and so on, and, still merge the data and retain a single
covergroup that accumulates all the data for the different versions.
4-4
Functional Coverage Functional Coverage
4-5
This switch takes only the coverage data that matches the reference
version. If your Friday version has an 8-bit Q, then that is what you
see in the report. As you used union merge, you get the coverage
data for coverpoint P from both versions of the group.
Functional Coverage
4-5
Functional Coverage
You should decide what merging strategy you should use early on
and run test merges to make sure it satisfies your needs.
4-6
Managing Coverage Data Files Managing Coverage Data Files
5-1
5
Managing Coverage Data Files 1
Using coverage produces some additional files and directories at
compile and simulation time. This section discusses how to manage
the creation of those files, and how to merge coverage data from
multiple simulation runs.
When you compile with VCS, the executable name you specify
determines the name of the daidir created. For example:
When coverage is enabled, the same name is used for creating the
VDB directory, which contains compile-time coverage-related
information. For example, the following command creates the
mysimv.vdb directory, containing all compile-time coverage data:
Test Names
When you run simulations with coverage, you specify names for your
coverage results. These names are used to uniquely identify the
sources of your coverage data at report time.
For example, to run two sets of tests, run1 and run2, and save the
data for each set into its own VDB directory, use the following:
5-2
Managing Coverage Data Files Managing Coverage Data Files
5-3
/proj/march/run7/t1dir/t1
/proj/march/run7/t1dir/t2
/proj/march/run7/t2dir/t1
/proj/march/run7/t2dir/t2
5-4
Targeting Parts of Your Design Targeting Parts of Your Design
6-1
6
Targeting Parts of Your Design 1
At compile time, you can tell VCS to monitor code coverage for only
parts of your design, for example, to ignore external IP when
monitoring coverage. You can also choose to apply different metrics
on different blocks.
Even if you collect coverage for the entire design, you can do the
same kind of filtering at report time. Both of these features are based
on a 'hier' file.
Keyword Meaning
tree Specifies a subtree in the design
hierarchy.
module Specifies a specific module.
moduletree Specifies a subtree of a specific
module, everywhere it is instantiated.
node Specifies a specific signal.
assert Specifies an assertion or cover
property.
library Specifies a library.
file Specifies a specific source file.
For example, a hier file consisting of the following line means that
only this tree is monitored for any type of coverage:
+tree top.HNTO_0.HNWOV_0
Whereas, the following in the hier file means that everything should
be monitored except for the specified module:
-module Wovmod
These hier files can be used at either compile time or report time.
When used at compile time, in some cases they can improve
simulation performance, as coverage instrumentation can be
removed. You can also specify that only certain metrics be collected
or excluded from regions of the design. For more details, see the
Coverage Technology Reference Guide.
6-2
Merging Coverage Data Merging Coverage Data
7-1
7
Merging Coverage Data 1
After running multiple simulation runs, the next step is to merge all
the coverage data from those runs. Once the data is merged, you
can generate reports or load the merged data into Verdi to analyze
the results.
Merging is done with the urg command. To merge data, you need to
provide the compile-time VDB directory and then any simulation-
produced VDB directories. The basic merge command is as follows:
This command reads all of the specified VDB directories and merges
them to create a new VDB named merged.vdb. The -noreport
switch indicates that we do not want to generate a report at the same
time (it is better to generate reports separately).
• “Mapping”
• “Test Data”
Mapping
Mapping is what URG calls for merging the coverage results from
different subsets of the design. A common use of mapping is to
merge the coverage results collected for a sub-block onto the SOC
coverage model of the full design. For example, the coverage for the
md3 block in the figure below is merged onto all instances of its top
module in the base design using the URG -map option:
7-2
Merging Coverage Data Merging Coverage Data
7-3
Test Data
By default, URG retains the list of all test records in the final merged
VDB. Using the example from Section, “Test Names” , there are two
test records in each of t1dir.vdb and t2dir.vdb.To merge these
two records together, use the following command:
/run1/test1
/run1/test2
/run2/test1
/run2/test2
By default, URG does not keep track of which test covered which
object in the merged VDB. Once the merged VDB is created, you
can still see which objects are covered, but by default you cannot see
which tests are responsible. To retain this test correlation
information, you must also provide the -show tests switch when
created the merged VDB:
We do not retain every test name that covered every object. It does
not make sense to keep track of every test that caused your clock to
toggle, for example. You can change the maximum number of tests
saved per covered object using the -db_max_tests option:
7-4
Merging Coverage Data Merging Coverage Data
7-5
Retaining the test correlation data has another benefit - you can do
test grading on the merged VDB. In previous releases, you had to
keep all the simulation-time VDBs to perform grading.
7-6
Generating Reports Generating Reports
8-1
8
Generating Reports 1
You generate a report by passing the names of all directories
containing coverage data to URG's -dir option. The first directory
passed should be compile-time directories. For example:
• “Metrics”
• “Ratios”
Generating Reports
8-1
Generating Reports
• “Trend Charts”
• “Navigating Coverage Reports”
Metrics
If you want to report only certain metrics, use the -metric flag:
Ratios
There are many options that affect how the report is generated and
how scores are computed. The -hier option to URG is already
discussed in Chapter Chapter 6, "Targeting Parts of Your Design". It
is also recommended to use the -show ratios option. This option
has two effects:
8-2
Generating Reports Generating Reports
8-3
Trend Charts
URG then generates a trend chart that you can load in your browser.
For more on trend charts, see the Coverage Technology User Guide.
From any page that displays module or instance names, you can
click on those names and be taken to the detailed coverage report
for that region.
Generating Reports
8-3
Generating Reports
8-4
Convergence Convergence
9-1
9
Convergence 1
Any complex design may have code that is structurally unreachable,
or value combinations that can never happen. As code coverage is
automatically extracted from the HDL description, there can many of
these uninteresting or unreachable objects.
When you are trying to verify the design, you have to exclude these
impossible or do not-care coverage targets so you can focus testing
on the parts of the design that can happen. This section explains
some ways to remove impossible or uninteresting parts of the design
from coverage monitoring.
Convergence
9-1
Convergence
• “Constant Analysis”
• “Adaptive Exclusion”
Constant Analysis
Start with VCS' built-in constant analysis feature. You should always
use the -cm_seqnoconst switch if you are using code coverage:
9-2
Convergence Convergence
9-3
- instance: test_jukebox.jb1
expression: attention[9:5]
declaration: jukebox.v:436
value: 0 always
locations:
- location: jukebox.v:899
inputs:
- input: hold[4:0]
Adaptive Exclusion
Convergence
9-3
Convergence
To exclude lines from coverage, for example, you click the green
circle next to them in the Coverage Details pane. After excluding
objects, you then click the Recalculate button in Verdi, which
updates the coverage scores. The snapshot below shows that
line 247 is excluded and the Recalculate button is clicked:
9-4
Convergence Convergence
9-5
This is why Verdi preserves your exclusions as-is when the design
changes, without intervention, unless the object being monitored or
the control code around it has changed. And for exclusions whose
objects have changed, Verdi Exclusion Manager walks you through
each one so you can decide if the exclusions still apply, or tell Verdi
what if anything needs to change.
Convergence
9-5
Convergence
9-6
Test Grading Test Grading
10-1
10
Test Grading 1
Grading, or test ranking, means comparing the effectiveness of tests
for coverage. Grading is useful when you want to eliminate
redundant tests from a test suite or put tests in best-first order.
If you did not use -show tests when creating your merged VDB,
or you have merged yet at all, you can use the -parallel switch to
do a parallel merge and then grade the tests:
Some useful options for grading are given in the table below. Provide
these options anywhere after the "-grade" option on the URG
command line:
Options Description
indexlimit N Retains at most N tests per covered object. Higher N
uses more memory and time but produces more
precise grading results
cost Grades tests to minimize the total cost (CPU time,
[cputime|simtim simulation cycles, or clock time) instead of minimizing
e|clocktime] the number of tests
testfile Generates a file 'gradedtests.txt' in the urgReport
directory that is a simple list of the graded tests, in
order.
Feedback
10-2