HomeSVDay 15

Coverage Closure

Metrics, regression, automation—achieve and maintain 100% functional coverage.

Why Closure Matters

Coverage isn't a one-time measurement—it's a continuous process. As RTL changes, coverage can regress. You need automated tracking and closure gates.

Regression Monitoring

// Continuous coverage collection class CoverageTracker; real coverage_history[$]; string dates[$]; function void record(real cov, string date); coverage_history.push_back(cov); dates.push_back(date); if (cov < 80.0) begin $warning("Coverage REGRESSION: %0.1f%%", cov); end endfunction function void report(); real avg = 0; foreach(coverage_history[i]) avg += coverage_history[i]; avg /= coverage_history.size(); $display("Avg coverage: %0.1f%%", avg); endfunction endclass

Closure Criteria

Typical Sign-Off Criteria:
• Code coverage: 100% (statements, branches)
• Functional coverage: ≥90%
• No regression from previous build
• All critical scenarios hit
• Directed tests for known gaps

Automation & CI Integration

// run_tests.sh - automated nightly regression #!/bin/bash COVERAGE_THRESHOLD=85 # Compile & run tests vcs -full64 -sverilog tb.sv testbench.sv ./simv -dir work +coverage=functional # Extract coverage coverage_result=$(grep "Overall coverage:" cov.log | awk '{print $3}') coverage_pct=${coverage_result%\%} # Pass/Fail if (( $(echo "$coverage_pct >= $COVERAGE_THRESHOLD" | bc -l) )); then echo "✓ Coverage PASSED: $coverage_pct%" exit 0 else echo "✗ Coverage FAILED: $coverage_pct% < $COVERAGE_THRESHOLD%" exit 1 fi

Key Takeaways

Tomorrow (Day 16): Constrained-random + coverage — automated test generation.