SlideShare a Scribd company logo
SystemVerilog Verification
Lecture 11
Coverage
1/28/2013 Krispan Inc. Confidential 1
Coverage types
• Coverage is a generic term used to measure the progress of verifying a
design. Two types of Coverage Code and Functional
– Code coverage:
• Here you are measuring how many lines of code have been
executed(line coverage).
• Which paths through the code and expressions have been
executed(path coverage)
• Which states and transitions have been executed(FSM)
• Single bit variable transitions from 0 or 1 (toggle coverage)
• Most Simulators include a code coverage tool.
• Code Coverage checks how accurately your tests exercised the
implementation of the design specifiacation and not the verification plan.
• 100% code coverage does not mean your design is completely verified
1/28/2013 Krispan Inc. Confidential 2
Code Coverage
• The code coverage tool will not catch mistakes you make
– Suppose your design implementation is missing a feature from the
design specification. Code Coverage will not catch it.
– Suppose you forget to implement the reset logic in your flop. Code
coverage will not catch it. It will report that every line in the code is
exercised.
module dff ( output logic q,
input logic clk, d, reset_low);
always @(posedge clk or negedge reset_low) begin
q <= d;
end
endmodule
• The reset logic was not implemented. Code Coverage tool will not catch it.
1/28/2013 Krispan Inc. Confidential 3
TestBench with Functional Coverage
1/28/2013 Krispan Inc. Confidential 4
test
Generator
Driver
DUT
Assertions
Scoreboard checker
monitor
Test
Environment
Functional
Coverage
Functional Coverage
• Functional Coverage tells you how much of the design is exercised.
• If the design is exercised completely for all possible scenarios then
the coverage is 100%.
• Create a test plan with the list of tests that are needed from the
design specification.
• Look at the coverage results, then decide on what actions one
needs take in order to achieve 100% coverage
• First action is to run the existing tests with more seeds to see if you
can achieve 100% coverage.
• Next step is to write more constraints and see if that fulfils the
cause.
• Write Directed tests only if absolutely necessary
1/28/2013 Krispan Inc. Confidential 5
Coverage Convergence
• For e.g. if we are looking at coverage metrics for processors
– Did we cover all instructions
– Did we cover all addressing modes
– Did we cover all valid combinations of instructions and
addressing modes.
• Functional coverage identifies tested and untested areas of
your design and makes sure you test for all
– Corner cases
– All states in a state machine and transitions are verified
• Use a combination of seeds, constraints and directed tests if
needed to increase your coverage to 100%.
1/28/2013 Krispan Inc. Confidential 6
Functional Coverage
1/28/2013 Krispan Inc. Confidential 7
Design Specification Verification Plan
design
tests
Coverage
database
pass
Coverage
Analysis
Debug
Functional Coverage
• You can see from the previous diagram you test for pass/fail
of a test.
– Pass gives you the coverage analysis
– Fail has no significance
– Functional Coverage data is discarded if the test failed due to design
bug.
– The Coverage data gives you the verification metrics and gives you a
measure of how many items in the verification plan is complete which
is based on the design specifications
– If the design does not match the specifications then the coverage
values have no meaning.
– Analyze coverage with multiple runs with different seeds, more
constraints, and directed tests if needed to achieve the coverage goal.
1/28/2013 Krispan Inc. Confidential 8
covergroup
• As we have seen before functional coverage starts with
writing of the verification plan from design specification
• Then in SystemVerilog we write an executable version using
covergroup and cover points
• covergroup construct is a keyword that encapsulates the
specification of a coverage model. It may include a clocking
event that samples values of variables and expressions which
are called cover points.
• Cover groups are defined using the keyword covergroup and
endgroup.
• A covergroup instance can be created using the new operator.
1/28/2013 Krispan Inc. Confidential 9
covergroup
• Coverage model definiton
– Encapsulated in the covergroup construct defined by the user
– Clocking events for sampling variables or expressions which are cover
points . This is done using the keyword coverpoint
– Cross coverage between coverage points using keyword cross
– Optional coverage options
• SystemVerilog functional coverage enables
– Variable and expression coverage as well as cross coverage
– Automatic and/or user-defined coverage bins
– Filtering conditions (illegal values, values to ignore, etc.)
– Automatic coverage sample triggering by events and sequences
• – Dynamic query of coverage information via built-in methods
1/28/2013 Krispan Inc. Confidential 10
covergroup
• Syntax is
covergroup buslogic;
……..
……..
endgroup
buslogic bl;
bl = new;
• An instance of buslogic covergroup bl is created by assigning
bl to new
1/28/2013 Krispan Inc. Confidential 11
covergroup example
program test1(busifc.TB ifc)
class BusTransaction;
//properties variables (data portion)
rand bit [31:0] data; //random variables
rand bit [3:0] port; //16 possible ports
endclass
covergroup portdata
coverpoint bt.port; // Measure coverage
endgroup
initial begin
BusTransaction bt;
portdata pd;
pd = new(); // Instantiate group
bt = new();
repeat (32) begin // Run a few cycles
assert(bt.randomize); // Create a transaction
ifc.cb.port <= bt.port; // and transmit
ifc.cb.data <= bt.data; // onto interface
pd.sample(); // Gather coverage
@ifc.cb; // Wait a cycle
end end endprogram
1/28/2013 Krispan Inc. Confidential 12
covergroup example
• In this example a random transaction is created and driven to
the interface.
• Testbench samples the value of the port field using the
portdata covergroup.
• 16 possible values, 32random transactions. Did your
testbench have enough coverage
• vcs will generate a coverage report which gives you a
summary of your coverage.
• If coverage does not satisfy your requirements then you can
rerun with a new seed value, add more constraints etc.
1/28/2013 Krispan Inc. Confidential 13
Sample of vcs® output
• Coverpoint Coverage report
• CoverageGroup: portdata
• Coverpoint: bt.port
• Summary
• Coverage: 50
• Goal: 100
• Number of Expected auto-bins: 16
• Number of User Defined Bins: 0
• Number of Automatically Generated Bins: 7
• Number of User Defined Transitions: 0
• Automatically Generated Bins
• Bin # hits at least
• ================================
• auto[1] 7 1
• auto[2] 7 1
• auto[3] 1 1
• auto[4] 5 1
• auto[5] 4 1
• auto[6] 2 1
• auto[7] 6 1
• ================================
1/28/2013 Krispan Inc. Confidential 14
Sample of vcs® output
• This is just how the vcs output would look like. It is not a real
output.
• You can see testbench generated the values for ports
1,2,3,4,5,6,7 but nothing was generated for
0,8,9,10,11,12,13,14,15.
• The at least option specifies how many hits are needed
before a bin is covered.
• The easiest way to improve coverage is to try to generate
more random transactions (more simulation cycles) or to try
new seed values.
1/28/2013 Krispan Inc. Confidential 15
Coverage bins
• Bins can be created implicitly or explicitly
• When you specifiy coverpoints if you do not specify any bins then
implicit bins are created.
• In the example vcs file we were trying the coverage on each port
and since there are 16 ports it will automatically create 16 bins
• The number of bins to be created can be controlled by using the
auto_bin_max parameter.
covergroup portdata
coverpoint bt.port;
{ option.auto_bin_max = 8; }
endgroup
• In this case total bins created will be 8 half of 16 and 1 bin for
2 ports
1/28/2013 Krispan Inc. Confidential 16
Coverage Bins
• Explicit bin creation is the preferred way. Not all cover points
are of interest to the user so he can use explicit bins if he
knows exactly what he wants to cover. You can also name the
bins
covergroup portdata
coverpoint bt.port {
bins portzero = {0}; // 1 bin for port0
bins portone = {[1:5], 7}; // 1 bin for ports 1:5, and 7
bins porttwo = {6, [8:15]}; // 1 bin for ports 6, 8:15
}
endgroup // portdata
• In this case we created 3 bins as shown above.
1/28/2013 Krispan Inc. Confidential 17
Conditional Coverage
• You can add the iff keyword to add a condition to the
coverpoint
covergroup portdata
coverpoint bt.port iff(!bus.if.reset)
endgroup
• This way you can turn off cover for ports during reset
assuming reset is active high.
• you can also use start and stop functions to turn on and off
cover.
• Here is an example of that
1/28/2013 Krispan Inc. Confidential 18
Conditional Coverage
initial begin
BusTransaction bt;
portdata pd;
pd = new(); // Instantiate group
bt = new();
#1 pd.stop(); //stop coverage
bus.if.reset = 1; //start reset
#100 bus.ifi.reset = 0; //end reset
pd.start(); //start coverage
repeat (32) begin // Run a few cycles
assert(bt.randomize); // Create a transaction
ifc.cb.port <= bt.port; // and transmit
ifc.cb.data <= bt.data; // onto interface
pd.sample(); // Gather coverage
@ifc.cb; // Wait a cycle
end
end
1/28/2013 Krispan Inc. Confidential 19
Covergroup range
• You can use the $ to specify the upper limit if it is used to
specify the right side of the range to specify the upper limit
• You can use the $ to specify the lower limit if it is used on the
leftside of the range to specify the lower limit
covergroup portdata
coverpoint bt.port {
bins portzero = {[$:5]}; // 1 bin for port 0:5
bins portone = {[6,7]}; // 1 bin for ports 6 and 7
bins porttwo = {[8:$]}; // 1 bin for ports 8:15
}
endgroup // portdata
1/28/2013 Krispan Inc. Confidential 20
Creating bins for enumerated
types
• For enumerated data types SystemVerilog creates a bin for
each value of the enumerated type
typedef enum { idle, decode, data_transfer} fsmstate;
fsmstatecstate, nstate;
covergroup cg_fsm;
coverpoint cstate;
endgroup
• In this case it will create a bin each for idle, decode and
data_transfer.
• If you want to group multiple values into a single bin then
you have to define your bins just as we did before
1/28/2013 Krispan Inc. Confidential 21
Transition Coverage
• Individual State transitions can be specified for a cover point.
• For eg you can check if port went from 0 to 1 2 or 3
covergroup portdata
coverpoint bt.port {
bins p1 = (0 => 1), (0 => 2), (0 => 3); } // Measure coverage
endgroup
• Wildcard states and transitions:
– Wildcard keyword is used to specify state transitions. X,Z or ? are treated as a wildcard
for 0 or 1. Here is a way to create a coverpoint with bins for even and odd values
bit [2:0] port;
covergroup cp;
coverpoint port {
wildcard bins even = {3’b??0};
wildcard bins odd = {3’b??1};
}
endgroup
1/28/2013 Krispan Inc. Confidential 22
Coverage group with event trigger
• In this case the coverage is started only when a trigger event
happens. For eg you can start the coverage when the
transaction ready signal is triggered from the testbench
• e.g.
event transaction_ready
covergroup cp @(transaction_ready);
coverpoint ifc.cb.port; //measure coverage for port
endgroup
• In this case we start measuring coverage on the coverpoint
only after the event is triggerred.
1/28/2013 Krispan Inc. Confidential 23
Cover group in a class
• Cover group can be defined in a module program or class.
• In any case they have to be instantiated explicitly to start
measuring coverage.
• For a class you don’t need to create a separate name when
you instance it. You can use the original cover group name
• Cover group is triggered whenever there are new values to
the variables or expressions
• The trigger can be done by a sampling function or by using
some kind of events to trigger the cover group as we had seen
under coverage group with event trigger.
1/28/2013 Krispan Inc. Confidential 24
Functional coverage in a class
class BusTransactor; class BusTransaction
BusTransaction bt; rand bit [31:0] data; //random variables
mailbox tr_in; rand bit [3:0] port; //16 possible ports
covergroup portdata; ……………
coverpoint bt.port; ……………
endgroup endclass
function new(mailbox tr_in);
portdata = new(); // Instantiate covergroup
this.tr_in = tr_in;
endfunction
task main;
forever begin
bt = tr_in.get; // Get next transaction
ifc.cb.port <= bt.port; // Send into DUT
ifc.cb.data <= bt.data;
portdata.sample(); // Gather coverage
end
endtask
endclass
1/28/2013 Krispan Inc. Confidential 25
Ad

More Related Content

Similar to System verilog Coverage including types.pdf (20)

24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf
FrangoCamila
 
whiteboxtestingppt download here information on software.pptx
whiteboxtestingppt download here information on software.pptxwhiteboxtestingppt download here information on software.pptx
whiteboxtestingppt download here information on software.pptx
aaminashaikh053
 
Stephan berg track f
Stephan berg   track fStephan berg   track f
Stephan berg track f
Alona Gradman
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
asifusman1998
 
DesignForTestMethodologyCaseStudy
DesignForTestMethodologyCaseStudyDesignForTestMethodologyCaseStudy
DesignForTestMethodologyCaseStudy
Justin Hernandez
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
Horky Chen
 
Unit 2 Unit level testing.ppt
Unit 2 Unit level testing.pptUnit 2 Unit level testing.ppt
Unit 2 Unit level testing.ppt
PerfectMe2
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Pragmatic Code Coverage
Pragmatic Code CoveragePragmatic Code Coverage
Pragmatic Code Coverage
Alexandre (Shura) Iline
 
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
CA Technologies
 
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
CA Technologies
 
How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
ShudipPal
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
ShudipPal
 
Tool Development 09 - Localization & Testing
Tool Development 09 - Localization & TestingTool Development 09 - Localization & Testing
Tool Development 09 - Localization & Testing
Nick Pruehs
 
Whitebox Testing,Types,Different techniques
Whitebox Testing,Types,Different techniquesWhitebox Testing,Types,Different techniques
Whitebox Testing,Types,Different techniques
vasukir11
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019
ciberkleid
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
Zsolt Fabok
 
Measurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNetMeasurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNet
Vasyl Senko
 
synchronization in operating system structure
synchronization in operating system structuresynchronization in operating system structure
synchronization in operating system structure
gaurav77712
 
24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf24-02-18 Rejender pratap.pdf
24-02-18 Rejender pratap.pdf
FrangoCamila
 
whiteboxtestingppt download here information on software.pptx
whiteboxtestingppt download here information on software.pptxwhiteboxtestingppt download here information on software.pptx
whiteboxtestingppt download here information on software.pptx
aaminashaikh053
 
Stephan berg track f
Stephan berg   track fStephan berg   track f
Stephan berg track f
Alona Gradman
 
DesignForTestMethodologyCaseStudy
DesignForTestMethodologyCaseStudyDesignForTestMethodologyCaseStudy
DesignForTestMethodologyCaseStudy
Justin Hernandez
 
代码大全(内训)
代码大全(内训)代码大全(内训)
代码大全(内训)
Horky Chen
 
Unit 2 Unit level testing.ppt
Unit 2 Unit level testing.pptUnit 2 Unit level testing.ppt
Unit 2 Unit level testing.ppt
PerfectMe2
 
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
CA Technologies
 
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
Case Study: How CA Went From 40 Days to Three Days Building Crystal-Clear Tes...
CA Technologies
 
How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
Sameh El-Ashry
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
ShudipPal
 
Software Engineering (Testing techniques)
Software Engineering (Testing techniques)Software Engineering (Testing techniques)
Software Engineering (Testing techniques)
ShudipPal
 
Tool Development 09 - Localization & Testing
Tool Development 09 - Localization & TestingTool Development 09 - Localization & Testing
Tool Development 09 - Localization & Testing
Nick Pruehs
 
Whitebox Testing,Types,Different techniques
Whitebox Testing,Types,Different techniquesWhitebox Testing,Types,Different techniques
Whitebox Testing,Types,Different techniques
vasukir11
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019
ciberkleid
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
Zsolt Fabok
 
Measurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNetMeasurement .Net Performance with BenchmarkDotNet
Measurement .Net Performance with BenchmarkDotNet
Vasyl Senko
 
synchronization in operating system structure
synchronization in operating system structuresynchronization in operating system structure
synchronization in operating system structure
gaurav77712
 

Recently uploaded (20)

MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
The Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLabThe Gaussian Process Modeling Module in UQLab
The Gaussian Process Modeling Module in UQLab
Journal of Soft Computing in Civil Engineering
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Avnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights FlyerAvnet Silica's PCIM 2025 Highlights Flyer
Avnet Silica's PCIM 2025 Highlights Flyer
WillDavies22
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
Ad

System verilog Coverage including types.pdf

  • 2. Coverage types • Coverage is a generic term used to measure the progress of verifying a design. Two types of Coverage Code and Functional – Code coverage: • Here you are measuring how many lines of code have been executed(line coverage). • Which paths through the code and expressions have been executed(path coverage) • Which states and transitions have been executed(FSM) • Single bit variable transitions from 0 or 1 (toggle coverage) • Most Simulators include a code coverage tool. • Code Coverage checks how accurately your tests exercised the implementation of the design specifiacation and not the verification plan. • 100% code coverage does not mean your design is completely verified 1/28/2013 Krispan Inc. Confidential 2
  • 3. Code Coverage • The code coverage tool will not catch mistakes you make – Suppose your design implementation is missing a feature from the design specification. Code Coverage will not catch it. – Suppose you forget to implement the reset logic in your flop. Code coverage will not catch it. It will report that every line in the code is exercised. module dff ( output logic q, input logic clk, d, reset_low); always @(posedge clk or negedge reset_low) begin q <= d; end endmodule • The reset logic was not implemented. Code Coverage tool will not catch it. 1/28/2013 Krispan Inc. Confidential 3
  • 4. TestBench with Functional Coverage 1/28/2013 Krispan Inc. Confidential 4 test Generator Driver DUT Assertions Scoreboard checker monitor Test Environment Functional Coverage
  • 5. Functional Coverage • Functional Coverage tells you how much of the design is exercised. • If the design is exercised completely for all possible scenarios then the coverage is 100%. • Create a test plan with the list of tests that are needed from the design specification. • Look at the coverage results, then decide on what actions one needs take in order to achieve 100% coverage • First action is to run the existing tests with more seeds to see if you can achieve 100% coverage. • Next step is to write more constraints and see if that fulfils the cause. • Write Directed tests only if absolutely necessary 1/28/2013 Krispan Inc. Confidential 5
  • 6. Coverage Convergence • For e.g. if we are looking at coverage metrics for processors – Did we cover all instructions – Did we cover all addressing modes – Did we cover all valid combinations of instructions and addressing modes. • Functional coverage identifies tested and untested areas of your design and makes sure you test for all – Corner cases – All states in a state machine and transitions are verified • Use a combination of seeds, constraints and directed tests if needed to increase your coverage to 100%. 1/28/2013 Krispan Inc. Confidential 6
  • 7. Functional Coverage 1/28/2013 Krispan Inc. Confidential 7 Design Specification Verification Plan design tests Coverage database pass Coverage Analysis Debug
  • 8. Functional Coverage • You can see from the previous diagram you test for pass/fail of a test. – Pass gives you the coverage analysis – Fail has no significance – Functional Coverage data is discarded if the test failed due to design bug. – The Coverage data gives you the verification metrics and gives you a measure of how many items in the verification plan is complete which is based on the design specifications – If the design does not match the specifications then the coverage values have no meaning. – Analyze coverage with multiple runs with different seeds, more constraints, and directed tests if needed to achieve the coverage goal. 1/28/2013 Krispan Inc. Confidential 8
  • 9. covergroup • As we have seen before functional coverage starts with writing of the verification plan from design specification • Then in SystemVerilog we write an executable version using covergroup and cover points • covergroup construct is a keyword that encapsulates the specification of a coverage model. It may include a clocking event that samples values of variables and expressions which are called cover points. • Cover groups are defined using the keyword covergroup and endgroup. • A covergroup instance can be created using the new operator. 1/28/2013 Krispan Inc. Confidential 9
  • 10. covergroup • Coverage model definiton – Encapsulated in the covergroup construct defined by the user – Clocking events for sampling variables or expressions which are cover points . This is done using the keyword coverpoint – Cross coverage between coverage points using keyword cross – Optional coverage options • SystemVerilog functional coverage enables – Variable and expression coverage as well as cross coverage – Automatic and/or user-defined coverage bins – Filtering conditions (illegal values, values to ignore, etc.) – Automatic coverage sample triggering by events and sequences • – Dynamic query of coverage information via built-in methods 1/28/2013 Krispan Inc. Confidential 10
  • 11. covergroup • Syntax is covergroup buslogic; …….. …….. endgroup buslogic bl; bl = new; • An instance of buslogic covergroup bl is created by assigning bl to new 1/28/2013 Krispan Inc. Confidential 11
  • 12. covergroup example program test1(busifc.TB ifc) class BusTransaction; //properties variables (data portion) rand bit [31:0] data; //random variables rand bit [3:0] port; //16 possible ports endclass covergroup portdata coverpoint bt.port; // Measure coverage endgroup initial begin BusTransaction bt; portdata pd; pd = new(); // Instantiate group bt = new(); repeat (32) begin // Run a few cycles assert(bt.randomize); // Create a transaction ifc.cb.port <= bt.port; // and transmit ifc.cb.data <= bt.data; // onto interface pd.sample(); // Gather coverage @ifc.cb; // Wait a cycle end end endprogram 1/28/2013 Krispan Inc. Confidential 12
  • 13. covergroup example • In this example a random transaction is created and driven to the interface. • Testbench samples the value of the port field using the portdata covergroup. • 16 possible values, 32random transactions. Did your testbench have enough coverage • vcs will generate a coverage report which gives you a summary of your coverage. • If coverage does not satisfy your requirements then you can rerun with a new seed value, add more constraints etc. 1/28/2013 Krispan Inc. Confidential 13
  • 14. Sample of vcs® output • Coverpoint Coverage report • CoverageGroup: portdata • Coverpoint: bt.port • Summary • Coverage: 50 • Goal: 100 • Number of Expected auto-bins: 16 • Number of User Defined Bins: 0 • Number of Automatically Generated Bins: 7 • Number of User Defined Transitions: 0 • Automatically Generated Bins • Bin # hits at least • ================================ • auto[1] 7 1 • auto[2] 7 1 • auto[3] 1 1 • auto[4] 5 1 • auto[5] 4 1 • auto[6] 2 1 • auto[7] 6 1 • ================================ 1/28/2013 Krispan Inc. Confidential 14
  • 15. Sample of vcs® output • This is just how the vcs output would look like. It is not a real output. • You can see testbench generated the values for ports 1,2,3,4,5,6,7 but nothing was generated for 0,8,9,10,11,12,13,14,15. • The at least option specifies how many hits are needed before a bin is covered. • The easiest way to improve coverage is to try to generate more random transactions (more simulation cycles) or to try new seed values. 1/28/2013 Krispan Inc. Confidential 15
  • 16. Coverage bins • Bins can be created implicitly or explicitly • When you specifiy coverpoints if you do not specify any bins then implicit bins are created. • In the example vcs file we were trying the coverage on each port and since there are 16 ports it will automatically create 16 bins • The number of bins to be created can be controlled by using the auto_bin_max parameter. covergroup portdata coverpoint bt.port; { option.auto_bin_max = 8; } endgroup • In this case total bins created will be 8 half of 16 and 1 bin for 2 ports 1/28/2013 Krispan Inc. Confidential 16
  • 17. Coverage Bins • Explicit bin creation is the preferred way. Not all cover points are of interest to the user so he can use explicit bins if he knows exactly what he wants to cover. You can also name the bins covergroup portdata coverpoint bt.port { bins portzero = {0}; // 1 bin for port0 bins portone = {[1:5], 7}; // 1 bin for ports 1:5, and 7 bins porttwo = {6, [8:15]}; // 1 bin for ports 6, 8:15 } endgroup // portdata • In this case we created 3 bins as shown above. 1/28/2013 Krispan Inc. Confidential 17
  • 18. Conditional Coverage • You can add the iff keyword to add a condition to the coverpoint covergroup portdata coverpoint bt.port iff(!bus.if.reset) endgroup • This way you can turn off cover for ports during reset assuming reset is active high. • you can also use start and stop functions to turn on and off cover. • Here is an example of that 1/28/2013 Krispan Inc. Confidential 18
  • 19. Conditional Coverage initial begin BusTransaction bt; portdata pd; pd = new(); // Instantiate group bt = new(); #1 pd.stop(); //stop coverage bus.if.reset = 1; //start reset #100 bus.ifi.reset = 0; //end reset pd.start(); //start coverage repeat (32) begin // Run a few cycles assert(bt.randomize); // Create a transaction ifc.cb.port <= bt.port; // and transmit ifc.cb.data <= bt.data; // onto interface pd.sample(); // Gather coverage @ifc.cb; // Wait a cycle end end 1/28/2013 Krispan Inc. Confidential 19
  • 20. Covergroup range • You can use the $ to specify the upper limit if it is used to specify the right side of the range to specify the upper limit • You can use the $ to specify the lower limit if it is used on the leftside of the range to specify the lower limit covergroup portdata coverpoint bt.port { bins portzero = {[$:5]}; // 1 bin for port 0:5 bins portone = {[6,7]}; // 1 bin for ports 6 and 7 bins porttwo = {[8:$]}; // 1 bin for ports 8:15 } endgroup // portdata 1/28/2013 Krispan Inc. Confidential 20
  • 21. Creating bins for enumerated types • For enumerated data types SystemVerilog creates a bin for each value of the enumerated type typedef enum { idle, decode, data_transfer} fsmstate; fsmstatecstate, nstate; covergroup cg_fsm; coverpoint cstate; endgroup • In this case it will create a bin each for idle, decode and data_transfer. • If you want to group multiple values into a single bin then you have to define your bins just as we did before 1/28/2013 Krispan Inc. Confidential 21
  • 22. Transition Coverage • Individual State transitions can be specified for a cover point. • For eg you can check if port went from 0 to 1 2 or 3 covergroup portdata coverpoint bt.port { bins p1 = (0 => 1), (0 => 2), (0 => 3); } // Measure coverage endgroup • Wildcard states and transitions: – Wildcard keyword is used to specify state transitions. X,Z or ? are treated as a wildcard for 0 or 1. Here is a way to create a coverpoint with bins for even and odd values bit [2:0] port; covergroup cp; coverpoint port { wildcard bins even = {3’b??0}; wildcard bins odd = {3’b??1}; } endgroup 1/28/2013 Krispan Inc. Confidential 22
  • 23. Coverage group with event trigger • In this case the coverage is started only when a trigger event happens. For eg you can start the coverage when the transaction ready signal is triggered from the testbench • e.g. event transaction_ready covergroup cp @(transaction_ready); coverpoint ifc.cb.port; //measure coverage for port endgroup • In this case we start measuring coverage on the coverpoint only after the event is triggerred. 1/28/2013 Krispan Inc. Confidential 23
  • 24. Cover group in a class • Cover group can be defined in a module program or class. • In any case they have to be instantiated explicitly to start measuring coverage. • For a class you don’t need to create a separate name when you instance it. You can use the original cover group name • Cover group is triggered whenever there are new values to the variables or expressions • The trigger can be done by a sampling function or by using some kind of events to trigger the cover group as we had seen under coverage group with event trigger. 1/28/2013 Krispan Inc. Confidential 24
  • 25. Functional coverage in a class class BusTransactor; class BusTransaction BusTransaction bt; rand bit [31:0] data; //random variables mailbox tr_in; rand bit [3:0] port; //16 possible ports covergroup portdata; …………… coverpoint bt.port; …………… endgroup endclass function new(mailbox tr_in); portdata = new(); // Instantiate covergroup this.tr_in = tr_in; endfunction task main; forever begin bt = tr_in.get; // Get next transaction ifc.cb.port <= bt.port; // Send into DUT ifc.cb.data <= bt.data; portdata.sample(); // Gather coverage end endtask endclass 1/28/2013 Krispan Inc. Confidential 25