SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
280
Code and Functional Coverages
Session delivered by:
Padmanaban K .
Session-07
281281
Session Objectives
• To learn about code coverage
• To have an idea about functional coverages
• To learn the types of code coverages
• To learn the types of Functional Coverages
282282
Session Topics
• Code Coverage
• Types of Code coverage
• Functional Coverage
• Types of Functional Coverage
• Merits and demerits of code and functional coverages
283283
Introduction to Code Coverage
• Code coverage is used to measure the efficiency of
verification implementation.
• It provides a quantitative measurement of the testing space.
• It describes the degree to which the source code of a DUT
has been tested. It is also referred as structural coverage.
284284
Introduction to Code Coverage
Code coverage answers the questions like
Have all the branches in " Case ", "if" have been entered?
Have all the conditions in "if", "case" statement is
simulated?
Have all the variables have been toggled?
Have all the statements of the RTL code have been
exercised?
Have all the states in the FSM has been entered and all the
legal transitions exercised?
Have all the paths within a block have been exercised?
285285
Performance Measure
• By applying code coverage analysis techniques to hardware
description languages, verification efficiency was improved
by enabling a verification engineer to isolate areas of un-
tested HDL code.
• The verification engineer examine a coverage report, seeks
out the low values and understands why that particular code
hasn't been tested fully and writes more tests or directs
randomness to cover the untested areas where there may be a
possibility of bug hiding.
• It does not require any additional coding to get code
coverage, tool dose everything.
286286
Performance Measure
• In unit level verification, a module by module is verified in
its own test environment to prove that the logic, control, and
data paths are functionally correct.
• The goal of module level verification is to ensure that the
component/unit being tested conforms to its specifications
and is ready to be integrated with other subcomponents of the
product.
• Code coverage becomes a criterion for finishing unit level
testing as it needs to verify every feature of component/unit.
In sub-system level /system level, the goal is to ensure that
the interfaces among the units are correct and the units work
together to execute the functionality correctly.
• In sub system level /system level testing, code coverage may
not be use full as the verification is not targeted at all the
features of the unit.
287287
TYPES OF CODE COVERAGE
• Statement coverage /line coverage
Block/segment coverage
Conditional coverage
Branch coverage
Toggle coverage
Path coverage
FSM coverage
288288
Code Coverage Example
• 2 module dut();
3 reg a,b,c,d,e,f;
4
5 initial
6 begin
7 #5 a = 0;
8 #5 a = 1;
9 end
10
11 always @(posedge a)
12 begin
13 c = b && a;
14 if(c && f)
15 b = e;
16 else
17 e = b;
18
19 case(c)
20 1:f = 1;
21 0:f = 0;
22 default : f = 0;
23 endcase
24
25 end
26 endmodule
289289
STATEMENT COVERAGE
• Statement coverage, also known as line coverage is the
easiest understandable type of coverage. This is required to
be 100% for every project.
• From N lines of code and according to the applied stimulus
how many statements (lines) are covered in the simulation is
measured by statement coverage.
• If a DUT is 10 lines long and 8 lines of them were exercised
in a test run, then the DUT has line coverage of 80%. Line
coverage includes continuous assignment statements,
Individual procedural statements, Procedural statement
blocks, Procedural statement block types, Conditional
statement and Branches for conditional statements.
290290
STATEMENT COVERAGE
• It considers only the executable statements and statements
which are not executable like module, endmodule, comments,
timescale etc are not covered.
There are total 12 statements at lines 5,7,8,11,13,14,15,17,19,20,21,22
Covered 9 statements. They are at lines
5,7,8,11,13,14,17,19,22
Uncovered 3 statements. They are at line
15,20,21
Coverage percentage: 75.00 (9/12)
291291
BLOCK COVERAGE
• The nature of the statement and block coverage looks
somewhat same.
• The difference is that block coverage considers branched
blocks of if/else, case branches, wait, while, for etc.
• Analysis of block coverage reveals the dead code in RTL.
There are total 9 blocks at lines
5,7,8,11,15,17,20,21,22
Covered 6 blocks. They are at lines
5,7,8,11,17,22
Uncovered 3 blocks. They are at line
15,20,21
Coverage percentage: 66.67 (6/9)
292292
CONDITIONAL COVERAGE
• Conditional coverage also called as expression coverage, will
reveals how the variables or sub-expressions in conditional
statements are evaluated. Expressions with logical operators
are only considered.
• The downside is that the conditional coverage measure
doesn't take into consideration how the Boolean value was
gotten from the conditions.
• Conditional coverage is the ratio of no. of cases checked to
the total no. of cases present. Suppose one expression having
Boolean expression like AND or OR, so entries which is
given to that expression to the total possibilities is called
expression coverage.
293293
CONDITIONAL COVERAGE
• Conditional coverage report of the previous example:
At LINE 13
Combinations of STATEMENT c = (b && a)
B = 0 and a = 0 is Covered
B = 0 and a = 1 is Covered
B = 1 and a = 0 is Not Covered
b = 1 and a = 1 is Not Covered
At LINE 14 combinations of STATEMENT if ((c && f))
C = 0 and f = 0 is Covered
C = 0 and f = 1 is Not Covered
C = 1 and f = 0 is Not Covered
C = 1 and f = 1 is Not Covered
Total possible combinations: 8
Total combinations executed: 3
294294
BRANCH COVERAGE
• Branch coverage which is also called as Decision coverage
report s the true or false of the conditions like if-else, case
and the ternary operator (? :) statements.
• For an "if" statement, decision coverage will report whether
the "if" statement is evaluated in both true and false cases,
even if "else" statement doesn't exist.
Branch coverage report of the example:
At line 15 branch b = e; not covered
At line 17 branch e = b; covered
At line 20 branch 1: f = 1; not covered
At line 21 branch 0: f = 0; covered
At line 22 branch default: f = 0; not covered
Coverage percentage: 40.00 (2/5)
295295
PATH COVERAGE
296296
PATH COVERAGE
• Path coverage represents yet another interesting measure.
Due to conditional statements like if-else, case in the design
different path is created which diverts the flow of stimulus to
the specific path.
• Path coverage is considered to be more complete than branch
coverage because it can detect the errors related to the
sequence of operations.
• As mentioned in the above figure path will be decided
according to the if-else statement According to the applied
stimulus the condition which is satisfied only under those
expressions will execute, the path will be diverted according
to that.
• Path coverage is possible in always and function blocks .
Path created by more than one block is not covered.
297297
PATH COVERAGE
• Path coverage report of the example:
Path 1 : 15,20 Not Covered
Path 2 : 15,21 Not Covered
Path 3: 15,22 Not Covered
Path 4: 17,20 Not Covered
Path 5 : 17,21 Covered
Path 6 : 17,22 Not Covered
Total possible paths : 6
Total covered path : 1
Path coverage Percentage : 16.67 (1/6)
298298
TOGGLE COVERAGE
• It makes assures that how many times variables and nets
toggled? Toggle coverage could be as simple as the ratio of
nodes toggled to the total number of nodes.
X or Z --> 1 or H
X or Z --> 0 or L
1 or H --> X or Z
0 or L --> X or Z
299299
TOGGLE COVERAGE
• Above example shows the signal changes from one level to
another. All types of transitions mentioned above are not
interested. Only 1->0 and 0->1 are important.
• Toggle coverage will show which signal did not change the
state. Toggle coverage will not consider zero-delay
glitches. This is very useful in gate level simulation.
Toggle coverage report of the example:
Name Toggled 1->0 0->1
a No No Yes
b No No No
c No No No
d No No No
e No No No
f No No No
300300
FSM COVERAGE
• It is the most complex type of code coverage, because it
works on the behavior of the design.
• Using Finite state machine coverage, all bugs related to finite
state machine design can be found. In this coverage we look
for how many times states are visited, transited and how
many sequence are covered in a Finite state machine.
• It will count the no. of transition from one state to another
and it will compare it with other total no. of transition. Total
no. of transition is nothing but all possible no. of transition
which is present in the finite state machine. Possible
transition = no. of states * no. of inputs.
301301
Example
• module fsm (clk, reset, in);
input clk, reset, in;
reg [1:0] state;
parameter s1 = 2'b00; parameter s2 = 2'b01;
parameter s3 = 2'b10; parameter s4 = 2'b11;
always @(posedge clk or posedge reset)
begin
if (reset) state <= s1;
else case (state)
s1:if (in == 1'b1) state <= s2;
else state <= s3;
s2: state <= s4;
s3: state <= s4;
s4: state <= s1;
endcase
end
endmodule
302302
TestBench
• module testbench();
reg clk,reset,in;
fsm dut(clk,reset,in);
initial
forever #5 clk = ~clk;
initial
begin
clk =0;in = 0;
#2 reset = 0;#2 reset = 1;
#21 reset = 0;#9 in = 0;
#9 in = 1;#10 $finish;
end
endmodule
303303
FSM coverage report
• FSM coverage report for the above example:
// state coverage results
s1 | Covered
s2 | Not Covered
s3 | Covered
s4 | Covered
// state transition coverage results
s1->s2 | Not Covered
s1->s3 | Covered
s2->s1 | Not Covered
s2->s4 | Not Covered
s3->s1 | Not Covered
s3->s4 | Covered
s4->s1 | Covered
304304
MAKE YOUR GOAL 100 PERCENT CODE COVERAGE
NOTHING LESS
• Never set your goal to anything less than 100% code
coverage. Anything less than 100% is a slippery slope. If you
set your goal to 98% , may be the most important feature like
reset of the system may be in the untested part of 2%.
• If the verification engineer sets the code coverage goal to
95% to facilitate the 5% the unused untestable legacy code,
there are chances that the unused legacy code gets executed
and the 5% holes may be in the important code.
• 100% code coverage provides advantages not only in
reducing the bug count but also in making it easier to make
significant changes to existing code base to remove uncover
able areas like the unused legacy blocks in RTL code.
305305
Dont Be Fooled By The Code Coverage
Report
• Highly covered code isn't necessarily free of defects,
although it's certainly less likely to contain them. By
definition, code coverage is limited to the design code. It
doesn't know anything about what design supposed to do.
• Even if a feature is not implemented in design, code coverage
can report 100% coverage.
• It is also impossible to determine whether we tested all
possible values of a feature using code coverage
• Code coverage is unable to tell much about how well you
have covered your logic -- only whether you've executed
each line/block etc at least once.
306306
Dont Be Fooled By The Code Coverage
Report
• Code coverage does not provide information about your test
bench randomization quality and it does not report what
caused the line execution/state transition etc.
• Analysis of code coverage require knowledge of design to
find which features are not verified which is time consuming
and out of scope of verification engineer.
• If the analysis is done at higher level of abstraction, it would
be easier for the test writer to identify the missed serious
which is not possible by code coverage.
• So if the code coverage is less than 100%, it means there is
more work to do, if it is 100%, it doesn't mean that the
verification is complete.
307307
When To Stop Testing?
• It's getting harder to figure out when to stop testing as the
complexity of the protocol is increasing.
• In directed test environment, for each point mentioned in test
plan, there will be a separate test case file.
• So if there are 100 points in test plan, then the engineer has to
write 100 test case files.
• After writing and executing the 100 test case files, we can say
that "all the points in test plan are verified" and we can stop
testing.
308308
FUNCTIONAL COVERAGE
• In constraint random verification all the features are
generated randomly. Verification engineer need a mechanism
to know the information about the verified features of DUT.
• SystemVerilog provides a mechanism to know the untested
feature using functional coverage.
• Functional Coverage is "instrumentation" that is manually
added to the TestBench.
• This is a better approach than counting testcases.
• Functional coverage is better than code coverage where the
code coverage reports what was exercised rather than what
was tested
309309
Functional Coverage Answers
• Have all the packets length between 64 to 1518 are used?
Did the DUT got exercised with alternate packets with
good and bad crc?
Did the monitor observe that the result comes with 4 clock
cycles after read operation?
Did the fifos are filled completely?
Did the fifo takes care of empty and full?
310310
Functional Coverage Advantages
• Functional coverage helps to determine how much of your
specification was covered.
• Functional coverage qualifies the test benches.
Considered as stopping criteria for unit level verification.
• Gives feedback about the untested features.
• Gives the information about the redundant tests which
consume valuable cycle.
• Guides to reach the goals earlier based on grading.

Más contenido relacionado

La actualidad más candente

Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
klinetik
 
Session 9 advance_verification_features
Session 9 advance_verification_featuresSession 9 advance_verification_features
Session 9 advance_verification_features
Nirav Desai
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academy
Raghavendra Kamath
 

La actualidad más candente (20)

Verilog Tasks and functions
Verilog Tasks and functionsVerilog Tasks and functions
Verilog Tasks and functions
 
Verilog Tasks & Functions
Verilog Tasks & FunctionsVerilog Tasks & Functions
Verilog Tasks & Functions
 
UVM TUTORIAL;
UVM TUTORIAL;UVM TUTORIAL;
UVM TUTORIAL;
 
System verilog assertions
System verilog assertionsSystem verilog assertions
System verilog assertions
 
SOC Verification using SystemVerilog
SOC Verification using SystemVerilog SOC Verification using SystemVerilog
SOC Verification using SystemVerilog
 
Jtag presentation
Jtag presentationJtag presentation
Jtag presentation
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Ral by pushpa
Ral by pushpa Ral by pushpa
Ral by pushpa
 
CPU Verification
CPU VerificationCPU Verification
CPU Verification
 
axi protocol
axi protocolaxi protocol
axi protocol
 
VLSI testing and analysis
VLSI testing and analysisVLSI testing and analysis
VLSI testing and analysis
 
How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?How to create SystemVerilog verification environment?
How to create SystemVerilog verification environment?
 
Test Bench Development
Test Bench DevelopmentTest Bench Development
Test Bench Development
 
Verilog
VerilogVerilog
Verilog
 
Session 9 advance_verification_features
Session 9 advance_verification_featuresSession 9 advance_verification_features
Session 9 advance_verification_features
 
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
 
Verilog hdl
Verilog hdlVerilog hdl
Verilog hdl
 
Uvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academyUvm cookbook-systemverilog-guidelines-verification-academy
Uvm cookbook-systemverilog-guidelines-verification-academy
 
JTAG Interface (Intro)
JTAG Interface (Intro)JTAG Interface (Intro)
JTAG Interface (Intro)
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 

Destacado

Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)
DVClub
 
Qualcomm SnapDragon 400-based Android Wear
Qualcomm SnapDragon 400-based Android WearQualcomm SnapDragon 400-based Android Wear
Qualcomm SnapDragon 400-based Android Wear
JJ Wu
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
Sunil Thorat
 
Qualcomm SnapDragon 800 Mobile Device
Qualcomm SnapDragon 800 Mobile DeviceQualcomm SnapDragon 800 Mobile Device
Qualcomm SnapDragon 800 Mobile Device
JJ Wu
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
DVClub
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
Varun Mahajan
 
2010 bristol q1_hybrid-formal-coverage
2010 bristol q1_hybrid-formal-coverage2010 bristol q1_hybrid-formal-coverage
2010 bristol q1_hybrid-formal-coverage
Obsidian Software
 
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Tammy Clark
 

Destacado (20)

Code coverage
Code coverageCode coverage
Code coverage
 
Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)Finding Bugs Faster with Assertion Based Verification (ABV)
Finding Bugs Faster with Assertion Based Verification (ABV)
 
Pragmatic Code Coverage
Pragmatic Code CoveragePragmatic Code Coverage
Pragmatic Code Coverage
 
Code coverage analysis in testing
Code coverage analysis in testingCode coverage analysis in testing
Code coverage analysis in testing
 
Code coverage
Code coverageCode coverage
Code coverage
 
Code Coverage
Code CoverageCode Coverage
Code Coverage
 
Doulos coverage-tips-tricks
Doulos coverage-tips-tricksDoulos coverage-tips-tricks
Doulos coverage-tips-tricks
 
Qualcomm SnapDragon 400-based Android Wear
Qualcomm SnapDragon 400-based Android WearQualcomm SnapDragon 400-based Android Wear
Qualcomm SnapDragon 400-based Android Wear
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Qualcomm SnapDragon 800 Mobile Device
Qualcomm SnapDragon 800 Mobile DeviceQualcomm SnapDragon 800 Mobile Device
Qualcomm SnapDragon 800 Mobile Device
 
Code coverage & tools
Code coverage & toolsCode coverage & tools
Code coverage & tools
 
Challenges in Using UVM at SoC Level
Challenges in Using UVM at SoC LevelChallenges in Using UVM at SoC Level
Challenges in Using UVM at SoC Level
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
The ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM ArchitectureThe ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM Architecture
 
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
IoT 개발자를 위한 Embedded C에서 Test Coverage를 추출해보자
 
2010 bristol q1_hybrid-formal-coverage
2010 bristol q1_hybrid-formal-coverage2010 bristol q1_hybrid-formal-coverage
2010 bristol q1_hybrid-formal-coverage
 
Introducing LCS to Digital Design Verification
Introducing LCS to Digital Design VerificationIntroducing LCS to Digital Design Verification
Introducing LCS to Digital Design Verification
 
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...Gs Us Roadmap For A World Class Information Security Management System– Isoie...
Gs Us Roadmap For A World Class Information Security Management System– Isoie...
 
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide LearningTma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
Tma World Viewpoint: Building Global Alignment Through Enterprise Wide Learning
 
BT Global Services - Our approach to Innovation
BT Global Services - Our approach to InnovationBT Global Services - Our approach to Innovation
BT Global Services - Our approach to Innovation
 

Similar a Session 7 code_functional_coverage

White boxvsblackbox
White boxvsblackboxWhite boxvsblackbox
White boxvsblackbox
sanerjjd
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective
Engineering Software Lab
 
Software Testing Foundations Part 5 - White Box Testing
Software Testing Foundations Part 5 - White Box TestingSoftware Testing Foundations Part 5 - White Box Testing
Software Testing Foundations Part 5 - White Box Testing
Nikita Knysh
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
Fincy V.J
 
Efficient Reliability Demonstration Tests - by Guangbin Yang
Efficient Reliability Demonstration Tests - by Guangbin YangEfficient Reliability Demonstration Tests - by Guangbin Yang
Efficient Reliability Demonstration Tests - by Guangbin Yang
ASQ Reliability Division
 

Similar a Session 7 code_functional_coverage (20)

680report final
680report final680report final
680report final
 
siemens-eda_technical-paper_the-missing-link-the-testbench-to-dut-connection.pdf
siemens-eda_technical-paper_the-missing-link-the-testbench-to-dut-connection.pdfsiemens-eda_technical-paper_the-missing-link-the-testbench-to-dut-connection.pdf
siemens-eda_technical-paper_the-missing-link-the-testbench-to-dut-connection.pdf
 
White boxvsblackbox
White boxvsblackboxWhite boxvsblackbox
White boxvsblackbox
 
Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)
 
white box testing.ppt
white box testing.pptwhite box testing.ppt
white box testing.ppt
 
Code coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspectiveCode coverage in theory and in practice form the do178 b perspective
Code coverage in theory and in practice form the do178 b perspective
 
Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective   Code Coverage in Theory and in practice form the DO178B perspective
Code Coverage in Theory and in practice form the DO178B perspective
 
A Verilog HDL Test Bench Primer
A Verilog HDL Test Bench PrimerA Verilog HDL Test Bench Primer
A Verilog HDL Test Bench Primer
 
Test pattern Generation for 4:1 MUX
Test pattern Generation for 4:1 MUXTest pattern Generation for 4:1 MUX
Test pattern Generation for 4:1 MUX
 
Software Testing Foundations Part 5 - White Box Testing
Software Testing Foundations Part 5 - White Box TestingSoftware Testing Foundations Part 5 - White Box Testing
Software Testing Foundations Part 5 - White Box Testing
 
Test cases for effective testing - part 2
Test cases for effective testing - part 2Test cases for effective testing - part 2
Test cases for effective testing - part 2
 
Fault Modeling for Verilog Register Transfer Level
Fault Modeling for Verilog Register Transfer LevelFault Modeling for Verilog Register Transfer Level
Fault Modeling for Verilog Register Transfer Level
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
 
11 whiteboxtesting
11 whiteboxtesting11 whiteboxtesting
11 whiteboxtesting
 
New software testing-techniques
New software testing-techniquesNew software testing-techniques
New software testing-techniques
 
Arduino introduction
Arduino introductionArduino introduction
Arduino introduction
 
Tools and techniques of code coverage testing
Tools and techniques of code coverage testingTools and techniques of code coverage testing
Tools and techniques of code coverage testing
 
ScioTalks | Coverage Based Testing
ScioTalks | Coverage Based TestingScioTalks | Coverage Based Testing
ScioTalks | Coverage Based Testing
 
Duplicate_Quora_Question_Detection
Duplicate_Quora_Question_DetectionDuplicate_Quora_Question_Detection
Duplicate_Quora_Question_Detection
 
Efficient Reliability Demonstration Tests - by Guangbin Yang
Efficient Reliability Demonstration Tests - by Guangbin YangEfficient Reliability Demonstration Tests - by Guangbin Yang
Efficient Reliability Demonstration Tests - by Guangbin Yang
 

Más de Nirav Desai

“Optimized AES Algorithm Core Using FeedBack Architecture”
“Optimized AES Algorithm Core Using FeedBack Architecture” “Optimized AES Algorithm Core Using FeedBack Architecture”
“Optimized AES Algorithm Core Using FeedBack Architecture”
Nirav Desai
 
List of vlsi companies in bangalore
List of vlsi companies in bangaloreList of vlsi companies in bangalore
List of vlsi companies in bangalore
Nirav Desai
 
Xilinx design flow -By BhargavTarpara
Xilinx design flow -By BhargavTarparaXilinx design flow -By BhargavTarpara
Xilinx design flow -By BhargavTarpara
Nirav Desai
 

Más de Nirav Desai (6)

SATA Protocol
SATA ProtocolSATA Protocol
SATA Protocol
 
AMBA 2.0 PPT
AMBA 2.0 PPTAMBA 2.0 PPT
AMBA 2.0 PPT
 
AMBA 2.0 REPORT
AMBA 2.0 REPORTAMBA 2.0 REPORT
AMBA 2.0 REPORT
 
“Optimized AES Algorithm Core Using FeedBack Architecture”
“Optimized AES Algorithm Core Using FeedBack Architecture” “Optimized AES Algorithm Core Using FeedBack Architecture”
“Optimized AES Algorithm Core Using FeedBack Architecture”
 
List of vlsi companies in bangalore
List of vlsi companies in bangaloreList of vlsi companies in bangalore
List of vlsi companies in bangalore
 
Xilinx design flow -By BhargavTarpara
Xilinx design flow -By BhargavTarparaXilinx design flow -By BhargavTarpara
Xilinx design flow -By BhargavTarpara
 

Último

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Session 7 code_functional_coverage

  • 1. 280 Code and Functional Coverages Session delivered by: Padmanaban K . Session-07
  • 2. 281281 Session Objectives • To learn about code coverage • To have an idea about functional coverages • To learn the types of code coverages • To learn the types of Functional Coverages
  • 3. 282282 Session Topics • Code Coverage • Types of Code coverage • Functional Coverage • Types of Functional Coverage • Merits and demerits of code and functional coverages
  • 4. 283283 Introduction to Code Coverage • Code coverage is used to measure the efficiency of verification implementation. • It provides a quantitative measurement of the testing space. • It describes the degree to which the source code of a DUT has been tested. It is also referred as structural coverage.
  • 5. 284284 Introduction to Code Coverage Code coverage answers the questions like Have all the branches in " Case ", "if" have been entered? Have all the conditions in "if", "case" statement is simulated? Have all the variables have been toggled? Have all the statements of the RTL code have been exercised? Have all the states in the FSM has been entered and all the legal transitions exercised? Have all the paths within a block have been exercised?
  • 6. 285285 Performance Measure • By applying code coverage analysis techniques to hardware description languages, verification efficiency was improved by enabling a verification engineer to isolate areas of un- tested HDL code. • The verification engineer examine a coverage report, seeks out the low values and understands why that particular code hasn't been tested fully and writes more tests or directs randomness to cover the untested areas where there may be a possibility of bug hiding. • It does not require any additional coding to get code coverage, tool dose everything.
  • 7. 286286 Performance Measure • In unit level verification, a module by module is verified in its own test environment to prove that the logic, control, and data paths are functionally correct. • The goal of module level verification is to ensure that the component/unit being tested conforms to its specifications and is ready to be integrated with other subcomponents of the product. • Code coverage becomes a criterion for finishing unit level testing as it needs to verify every feature of component/unit. In sub-system level /system level, the goal is to ensure that the interfaces among the units are correct and the units work together to execute the functionality correctly. • In sub system level /system level testing, code coverage may not be use full as the verification is not targeted at all the features of the unit.
  • 8. 287287 TYPES OF CODE COVERAGE • Statement coverage /line coverage Block/segment coverage Conditional coverage Branch coverage Toggle coverage Path coverage FSM coverage
  • 9. 288288 Code Coverage Example • 2 module dut(); 3 reg a,b,c,d,e,f; 4 5 initial 6 begin 7 #5 a = 0; 8 #5 a = 1; 9 end 10 11 always @(posedge a) 12 begin 13 c = b && a; 14 if(c && f) 15 b = e; 16 else 17 e = b; 18 19 case(c) 20 1:f = 1; 21 0:f = 0; 22 default : f = 0; 23 endcase 24 25 end 26 endmodule
  • 10. 289289 STATEMENT COVERAGE • Statement coverage, also known as line coverage is the easiest understandable type of coverage. This is required to be 100% for every project. • From N lines of code and according to the applied stimulus how many statements (lines) are covered in the simulation is measured by statement coverage. • If a DUT is 10 lines long and 8 lines of them were exercised in a test run, then the DUT has line coverage of 80%. Line coverage includes continuous assignment statements, Individual procedural statements, Procedural statement blocks, Procedural statement block types, Conditional statement and Branches for conditional statements.
  • 11. 290290 STATEMENT COVERAGE • It considers only the executable statements and statements which are not executable like module, endmodule, comments, timescale etc are not covered. There are total 12 statements at lines 5,7,8,11,13,14,15,17,19,20,21,22 Covered 9 statements. They are at lines 5,7,8,11,13,14,17,19,22 Uncovered 3 statements. They are at line 15,20,21 Coverage percentage: 75.00 (9/12)
  • 12. 291291 BLOCK COVERAGE • The nature of the statement and block coverage looks somewhat same. • The difference is that block coverage considers branched blocks of if/else, case branches, wait, while, for etc. • Analysis of block coverage reveals the dead code in RTL. There are total 9 blocks at lines 5,7,8,11,15,17,20,21,22 Covered 6 blocks. They are at lines 5,7,8,11,17,22 Uncovered 3 blocks. They are at line 15,20,21 Coverage percentage: 66.67 (6/9)
  • 13. 292292 CONDITIONAL COVERAGE • Conditional coverage also called as expression coverage, will reveals how the variables or sub-expressions in conditional statements are evaluated. Expressions with logical operators are only considered. • The downside is that the conditional coverage measure doesn't take into consideration how the Boolean value was gotten from the conditions. • Conditional coverage is the ratio of no. of cases checked to the total no. of cases present. Suppose one expression having Boolean expression like AND or OR, so entries which is given to that expression to the total possibilities is called expression coverage.
  • 14. 293293 CONDITIONAL COVERAGE • Conditional coverage report of the previous example: At LINE 13 Combinations of STATEMENT c = (b && a) B = 0 and a = 0 is Covered B = 0 and a = 1 is Covered B = 1 and a = 0 is Not Covered b = 1 and a = 1 is Not Covered At LINE 14 combinations of STATEMENT if ((c && f)) C = 0 and f = 0 is Covered C = 0 and f = 1 is Not Covered C = 1 and f = 0 is Not Covered C = 1 and f = 1 is Not Covered Total possible combinations: 8 Total combinations executed: 3
  • 15. 294294 BRANCH COVERAGE • Branch coverage which is also called as Decision coverage report s the true or false of the conditions like if-else, case and the ternary operator (? :) statements. • For an "if" statement, decision coverage will report whether the "if" statement is evaluated in both true and false cases, even if "else" statement doesn't exist. Branch coverage report of the example: At line 15 branch b = e; not covered At line 17 branch e = b; covered At line 20 branch 1: f = 1; not covered At line 21 branch 0: f = 0; covered At line 22 branch default: f = 0; not covered Coverage percentage: 40.00 (2/5)
  • 17. 296296 PATH COVERAGE • Path coverage represents yet another interesting measure. Due to conditional statements like if-else, case in the design different path is created which diverts the flow of stimulus to the specific path. • Path coverage is considered to be more complete than branch coverage because it can detect the errors related to the sequence of operations. • As mentioned in the above figure path will be decided according to the if-else statement According to the applied stimulus the condition which is satisfied only under those expressions will execute, the path will be diverted according to that. • Path coverage is possible in always and function blocks . Path created by more than one block is not covered.
  • 18. 297297 PATH COVERAGE • Path coverage report of the example: Path 1 : 15,20 Not Covered Path 2 : 15,21 Not Covered Path 3: 15,22 Not Covered Path 4: 17,20 Not Covered Path 5 : 17,21 Covered Path 6 : 17,22 Not Covered Total possible paths : 6 Total covered path : 1 Path coverage Percentage : 16.67 (1/6)
  • 19. 298298 TOGGLE COVERAGE • It makes assures that how many times variables and nets toggled? Toggle coverage could be as simple as the ratio of nodes toggled to the total number of nodes. X or Z --> 1 or H X or Z --> 0 or L 1 or H --> X or Z 0 or L --> X or Z
  • 20. 299299 TOGGLE COVERAGE • Above example shows the signal changes from one level to another. All types of transitions mentioned above are not interested. Only 1->0 and 0->1 are important. • Toggle coverage will show which signal did not change the state. Toggle coverage will not consider zero-delay glitches. This is very useful in gate level simulation. Toggle coverage report of the example: Name Toggled 1->0 0->1 a No No Yes b No No No c No No No d No No No e No No No f No No No
  • 21. 300300 FSM COVERAGE • It is the most complex type of code coverage, because it works on the behavior of the design. • Using Finite state machine coverage, all bugs related to finite state machine design can be found. In this coverage we look for how many times states are visited, transited and how many sequence are covered in a Finite state machine. • It will count the no. of transition from one state to another and it will compare it with other total no. of transition. Total no. of transition is nothing but all possible no. of transition which is present in the finite state machine. Possible transition = no. of states * no. of inputs.
  • 22. 301301 Example • module fsm (clk, reset, in); input clk, reset, in; reg [1:0] state; parameter s1 = 2'b00; parameter s2 = 2'b01; parameter s3 = 2'b10; parameter s4 = 2'b11; always @(posedge clk or posedge reset) begin if (reset) state <= s1; else case (state) s1:if (in == 1'b1) state <= s2; else state <= s3; s2: state <= s4; s3: state <= s4; s4: state <= s1; endcase end endmodule
  • 23. 302302 TestBench • module testbench(); reg clk,reset,in; fsm dut(clk,reset,in); initial forever #5 clk = ~clk; initial begin clk =0;in = 0; #2 reset = 0;#2 reset = 1; #21 reset = 0;#9 in = 0; #9 in = 1;#10 $finish; end endmodule
  • 24. 303303 FSM coverage report • FSM coverage report for the above example: // state coverage results s1 | Covered s2 | Not Covered s3 | Covered s4 | Covered // state transition coverage results s1->s2 | Not Covered s1->s3 | Covered s2->s1 | Not Covered s2->s4 | Not Covered s3->s1 | Not Covered s3->s4 | Covered s4->s1 | Covered
  • 25. 304304 MAKE YOUR GOAL 100 PERCENT CODE COVERAGE NOTHING LESS • Never set your goal to anything less than 100% code coverage. Anything less than 100% is a slippery slope. If you set your goal to 98% , may be the most important feature like reset of the system may be in the untested part of 2%. • If the verification engineer sets the code coverage goal to 95% to facilitate the 5% the unused untestable legacy code, there are chances that the unused legacy code gets executed and the 5% holes may be in the important code. • 100% code coverage provides advantages not only in reducing the bug count but also in making it easier to make significant changes to existing code base to remove uncover able areas like the unused legacy blocks in RTL code.
  • 26. 305305 Dont Be Fooled By The Code Coverage Report • Highly covered code isn't necessarily free of defects, although it's certainly less likely to contain them. By definition, code coverage is limited to the design code. It doesn't know anything about what design supposed to do. • Even if a feature is not implemented in design, code coverage can report 100% coverage. • It is also impossible to determine whether we tested all possible values of a feature using code coverage • Code coverage is unable to tell much about how well you have covered your logic -- only whether you've executed each line/block etc at least once.
  • 27. 306306 Dont Be Fooled By The Code Coverage Report • Code coverage does not provide information about your test bench randomization quality and it does not report what caused the line execution/state transition etc. • Analysis of code coverage require knowledge of design to find which features are not verified which is time consuming and out of scope of verification engineer. • If the analysis is done at higher level of abstraction, it would be easier for the test writer to identify the missed serious which is not possible by code coverage. • So if the code coverage is less than 100%, it means there is more work to do, if it is 100%, it doesn't mean that the verification is complete.
  • 28. 307307 When To Stop Testing? • It's getting harder to figure out when to stop testing as the complexity of the protocol is increasing. • In directed test environment, for each point mentioned in test plan, there will be a separate test case file. • So if there are 100 points in test plan, then the engineer has to write 100 test case files. • After writing and executing the 100 test case files, we can say that "all the points in test plan are verified" and we can stop testing.
  • 29. 308308 FUNCTIONAL COVERAGE • In constraint random verification all the features are generated randomly. Verification engineer need a mechanism to know the information about the verified features of DUT. • SystemVerilog provides a mechanism to know the untested feature using functional coverage. • Functional Coverage is "instrumentation" that is manually added to the TestBench. • This is a better approach than counting testcases. • Functional coverage is better than code coverage where the code coverage reports what was exercised rather than what was tested
  • 30. 309309 Functional Coverage Answers • Have all the packets length between 64 to 1518 are used? Did the DUT got exercised with alternate packets with good and bad crc? Did the monitor observe that the result comes with 4 clock cycles after read operation? Did the fifos are filled completely? Did the fifo takes care of empty and full?
  • 31. 310310 Functional Coverage Advantages • Functional coverage helps to determine how much of your specification was covered. • Functional coverage qualifies the test benches. Considered as stopping criteria for unit level verification. • Gives feedback about the untested features. • Gives the information about the redundant tests which consume valuable cycle. • Guides to reach the goals earlier based on grading.