Session 15 FSM Verification and Code Coverage
Session 15 FSM Verification and Code Coverage
371
FSM VERIFICATION
372
FSM VERIFICATION
373
FSM VERIFICATION
D=1
Problem: Dead states ST_6 IDLE
Once entered, can not transition to any other
state. D=0
374
FSM VERIFICATION
375
FSM VERIFICATION
A=1
376
FSM VERIFICATION
377
FSM VERIFICATION
Problem: Wrong operation after reset Ensure that the FSM correctly initializes to a
After reset occurs, states are not transit to initial state. known state upon reset !!!
This issue occurs at modules that have multiple reset,
e.g. Power-ON (POR) reset and System reset.
ST_6 IDLE
Example: This FSM is inside module that has POR reset
and system reset. This FSM is reset by POR reset only.
When system reset occur at ST_4, D (initizlize by system
reset) is reset to 0 so state is stucked at ST_4 and can
not go back to IDLE state. ST_5 ST_3 ST_0
378
COVERAGE RECAP
Identify Verification Scope Coverage: helps DV engineers identify areas they haven't yet tested. Here are
and Method
some examples:
Design Requirement ▪ Some lines of code that haven't been tested
Analysis ▪ An else-if condition that hasn't been tested
Create Verification
▪ A logical combination of values that hasn't been tested
Specification and Plan ▪ Some states of a state machine that haven't been tested
….
Build Test Environment and
Test Case (Scenario)
Coverage also helps RTL design engineers identify unreasonable lines of code and
conditions that never occur. As a result, RTL engineers can optimize their designs
Run Simulation and Debug to make them better.
Check and Improve Completing coverage is a MUST to demonstrate that the verification work is
Coverage completed.
Verification Review
Coverage will help to detect the above issues !!!
379
CODE COVERAGE
Code coverage is a metric used to measure how much the design source in RTL or gates
are tested. Code coverage measures how often a suite or tests exercises certain aspects
of the source.
Some common code coverage types are: statement, branch, expression, condition,
toggle.
Statement coverage: sometimes called “line coverage” is the most basic form of code
coverage. The EDA tools will count of how many times a given statement is executed
during simulation.
381
COMMON CODE COVERAGE TYPES
Branch coverage
Branch coverage: relates to branching constructs such as “if” and “case” statements. It
measurestrue branch and false branch execution.
382
COMMON CODE COVERAGE TYPES
Expression coverage
FEC (Focused Expression Coverage): is a method that measures coverage for each input
of an expression. If all inputs are fully covered, the expression has reached 100%
coverage.
Example of expression:
383
COMMON CODE COVERAGE TYPES
Expression coverage
In FEC, an input is said to be fully covered when the following conditions apply:
▪ All other inputs are in a state that allow the covered input to control the output of
the expression.
▪ The output can be seen in both 0 and 1 states while the target input is controlling it.
Example:
.
384
COMMON CODE COVERAGE TYPES
Expression coverage
The tool will break the big expression into smaller basic expressions and evaluate one by one.
385
COMMON CODE COVERAGE TYPES
Condition coverage
Condition coverage: Similar to expression coverage but it analyzes the decision made in
“if” and ternary statements (condition ? true_value : false value).
386
COMMON CODE COVERAGE TYPES
Toggle coverage
Toggle coverage: to measure how many times each bit of a signal has changed (or toggled) during
simulation.
Data types which are target of toggle coverage calculation: wire, reg, bit, enum, real, shortreal and integer.
387
PRACTICE
1. Create 15_ss15 in your home directory
2. Copy share/teacher/15_ss15/cov_practice into your directory. The design contains only 1 expression as
the previous examples: y = a & (b | c);
3. Start writing test case in home directory, write first vector (a,b,c) = (1,1,0).
4. % make help to see the new options
5. % make all_cov to build and run simulation in coverage mode. Simulation should be PASSED and
test.ucdb is generated.
6. % make gen_cov to generate coverage report. The report is in coverage folder.
7. Read and analyze the summary and detail report
8. Improve the coverage by adding testcase one by one and see the differences in the coverage report
(repeat step 3 until coverage of dut is 100%).
9. % make gen_html to generate coverage report in html format. Open the index.html in covhtmlreport
folder report to see the coverage.
10. Apply this method for one another design to see other coverage metrics.
388
Homework
Homework1: Apply code coverage method for counter below:
389