Verification foundations

Coverage & Metrics

Coverage measures verification progress and helps identify which design behaviors have been exercised and which still need tests.

What is Coverage?

Coverage answers the question: "What percentage of my design has been exercised by my tests?"

It's measured automatically during simulation and provides objective metrics for verification progress. Coverage helps identify what's been tested and what hasn't.

Code Coverage (Structural Coverage)

Measures which parts of the HDL code have been executed:

1. Statement/Line Coverage
  • Measures if each line of code was executed at least once
  • Most basic form of coverage
  • Example: If-statement lines executed?
2. Branch Coverage
  • Measures if all branches (if/else paths) taken
  • More comprehensive than line coverage
  • Example: Both the if AND else paths executed?
3. Toggle Coverage
  • Measures if each bit has toggled (0→1, 1→0)
  • Catches stuck-at faults
  • Important for detecting hardware failures
4. Finite State Machine (FSM) Coverage
  • Measures if all states and transitions visited
  • Critical for protocol-based designs

Functional Coverage (User-Defined)

Measures if high-level design features and behaviors have been tested. This is defined by the verification engineer.

Examples of Functional Coverage Points:
  • Did we test writing to a FIFO when full?
  • Did we test reading from FIFO when empty?
  • Did we test all possible burst lengths?
  • Did we test with all address ranges?
  • Did we test with all possible data patterns?
Benefits:
  • Directly maps to design requirements
  • More meaningful than code coverage
  • Drives test generation
  • Easy to understand for non-engineers

Typical Coverage Targets

Coverage Type Typical Target Reasoning
Line Coverage 90-95% Some unreachable code (error handling)
Branch Coverage 85-90% Harder to reach all branches
Toggle Coverage 95%+ Critical for hardware reliability
Functional Coverage 100% All features must be verified

Coverage-Driven Verification (CDV) Flow

  1. Run Tests: Execute test suite with coverage collection enabled
  2. Measure Coverage: Analyze code and functional coverage results
  3. Identify Gaps: Find areas with low or zero coverage
  4. Generate Tests: Create new tests to cover missing areas
  5. Repeat: Continue until coverage targets met

This iterative process ensures comprehensive verification without wasting effort on redundant tests.

Coverage Best Practices

  • Define functional coverage upfront: As part of test plan
  • Set realistic targets: 95% is often achievable, 100% may not be
  • Distinguish code vs. functional: Both are important
  • Review coverage gaps: Understand why areas have low coverage
  • Automate coverage collection: Run with every test
  • Track coverage trends: Monitor progress over time
  • Use coverage to guide testing: Not as a replacement for quality
Common Coverage Pitfalls
  • Coverage ≠ Correctness: 100% coverage doesn't guarantee correct design
  • Dead code: Some code may be unreachable or obsolete
  • Over-testing: Don't spend weeks to go from 95% to 100%
  • Ignoring functional coverage: Code coverage alone isn't enough