Merging SystemVerilog Covergroups by Example - Verification Horizons - Verification Academy
Merging SystemVerilog Covergroups by Example - Verification Horizons - Verification Academy
THE BASE EXAMPLE UNION_MERGE.SV The example then instantiates the covergroup inside a
module named dut (green box). The testbench (blue box)
covergroup c1_cg (ref bit x); instantiates two copies of dut named: duta and dutb that has
their x input tied to either a constant one or constant zero.
option.per_instance = 1; The covergroup is sampled on the positive edge of clk.
type_option.merge_instances = 1;
32
You might be a person who likes looking directly at the code The coverpoint c1_cg::x also shows the number of hits it
or if you are like me, you would get a lot more out of the had for each bin: 2 in this case. Which is the union of duta
structural block diagram below. and dutb. In this example, you can use the INST and the
c1_cg::x coverage as both measurements are available;
both measurements also include full bin information.
We can see that the duta instance only had hits for the
bin _0 while dutb only had hits for the bin _1 – exactly as
we expected, we tied them to constants of course. So
each INST is 50% covered because each is hitting half of
their described bins. But, because we set the covergroup
options to do a union merge of all possible covergroups of
this type, we get the “overall coverpoint” called c1_cg::x Figure 4 Mentor Questa View of Covergroups
being marked as 100%. in weighted_merge.sv
33
The merge used in this example, is taking all of the What you see below is that Mentor Questa did not pull
instances of the covergroup and giving you the average out what I called the “overall coverpoint” that was named
across every coverpoint – the weighted average merge. It c1_cg::x as it did before. It doesn’t know that the duta and
doesn’t have visibility into what bins are covered anymore; dutb covergroups are the same; therefore, it can’t pull out
that is why you can’t expand it and see the _0 and _1 bins. the covergroup c1_cg as a shared coverage component.
In this example, you can use either the INST or the c1_cg::x
as both measurements are available; but, bin coverage is
only available for INST instance coverage.
34
If you just want to have a single number, the union, If you have multiple layers of environments and test
to represent your coverage, you can turn off an option benches you have to drag along all of the covergroup INST
for the covergroup: data with you too; you would likely also have to do tricks in
your simulator to normalize the path to the INST coverage
option.per_instance = 0 to merge the coverage databases properly.
type_option.merge_instances = 1
There are times when it makes sense to keep INST data;
such as, if you need to answer the question: “did you send
command x to every core in the design?” That question
could not be answered without INST data. Right now, with
this implementation, you could only answer with: “we sent
the command x to at least one core in the design and we
sent that command n times.”
WHY DO IT
Union Merge with INST
The reason to do this is to reduce the amount of data that 1 1 0
union_merge.sv
the coverage database has to hold. Imagine having 1024
cores in your design that each has an instance of your Weighted Average Merge
covergroup in them. You would have 1024 INST values
0 0 0
weighted_merge.sv
plus the “overall covergroup”.
Only Instance Coverage
— — 1
There are also problems when merging across simulations. module_merge.sv
If you have to merge those 1024 cores’ covergroups, the
Union Merge w/o INST
simulator is going to update each of the 1024 covergroups 0 1 0
efficient_merge.sv
INST coverage data as well as calculating the “overall
covergroup” for every simulation. That takes a lot more time
Figure 10 Table of Covergroup Possibilities
than just updating the bins of the “overall covergroup”.
35
SUMMARY
This article through: source code, diagrams, and screen
captures from Mentor Questa showed how the choices
in implementing a covergroup effect what data will be
available in the coverage database. The covergroup
choices that can be made are summarized in a provided
table that allows for quick reference of the common ways of
configuring covergroups that will meet the required need.
Covergroups are a powerful verification tool to see what
conditions the design has encountered. Informed with a
few examples of how the simulator uses the configuration
options of covergroups, your next covergroup will be even
more effective at capturing exactly what you need to verify.
REFERENCES
• Source Code for All Examples is Available on GitHub
at the link below under the “covmerge” folder:
https://github.com/tenthousandfailures/blog.git
• IEEE STD 1800-2012 SystemVerilog LRM
• This paper is based off of posts that first appeared
on my blog Ten Thousand Failures:
http://tenthousandfailures.com
• Dave Rich blog post “SystemVerilog Coding Guidelines:
Package import versus `include”:
http://blogs.mentor.com/verificationhorizons/
blog/2010/07/13/package-import-versus-include/
36
VERIFICATION
ACADEMY
The Most Comprehensive Resource for Verification Training
20
20 Video
Video Courses
Courrses Available
Available Covering
Covering
• Intelligent
Intelligent Testbench
Testbench Automation
Automation
• Metrics
Metrics inin SoC
SoC Verification
Verification
• Verification
Verification Planning
Planning
• Basic
Basic and
and Advanced
Advanced UVM
UVM
• Assertion-Based
Assertion-Based Verification
Verification
• FPGA
FPGA Verification
Verification
• Testbench
Testbench Acceleration
Acceleration
• Power
Power Aware
Aware Verification
Verificatio
on
• Analog
Anallog Mixed-Signal
Mixed-SSignal Verification
Verification
n
UVM
UVM and
and Coverage
Coverage Online
Online Methodology
Methodology Cookbooks
Cookbo
ooks
Discussion
Discus n Forum
ssion Forum with
with more
more than
than 4400
4400 topics
topic
cs
UVM
M Connect
UVM ct and
Connec d UVM
and UVM Express
s Kits
Express Kits
www.
w ww. verificationacademy.com
verrific
cationacademy.com
Editor: Tom Fitzpatrick
Program Manager: Rebecca Granquist
To subscribe visit:
www.mentor.com/horizons