Verification

Formal Verification: Proving Correctness Without Simulation

16 min read Verification

Formal Verification: Mathematical Proof for Hardware Correctness

Formal verification uses mathematical techniques to prove that a design meets its specification for all possible inputs, not just tested scenarios. Unlike simulation which can only test a subset of states, formal methods provide exhaustive coverage, making them essential for safety-critical and security-sensitive designs.

Why Formal Verification?

  • Exhaustive: Covers all possible input combinations
  • Early Bug Detection: Finds corner cases simulation misses
  • Proofs: Mathematical guarantee of correctness
  • No Testbench: Properties replace stimulus generation
  • Counterexamples: Provides waveforms for failures

Formal Verification Techniques

1. Model Checking

Automatically verify temporal properties against design:

  • Explores all reachable states exhaustively
  • Checks properties expressed in temporal logic
  • Returns counterexample if property fails
  • Bounded (BMC) or unbounded verification

2. Equivalence Checking

Prove two designs are functionally identical:

  • LEC (Logic Equivalence Checking): RTL vs netlist
  • SEC (Sequential Equivalence Checking): Designs with different FSMs
  • Used after synthesis, optimization, ECO

3. Theorem Proving

Interactive proof with human guidance:

  • For complex algorithms and protocols
  • Higher capacity than model checking
  • Requires expertise in proof techniques

Technique Comparison

Aspect Model Checking Equivalence Checking Theorem Proving
Automation Automatic Automatic Manual guidance
Capacity Medium High Very High
Use Case Property verification Sign-off Protocols
Completeness Bounded/Unbounded Complete Complete

Writing Effective Assertions

SystemVerilog Assertions (SVA)

Standard language for formal properties:

Basic SVA Syntax

// Immediate assertion (combinational)
assert (data_valid |-> data != 0)
  else $error("Valid data cannot be zero");

// Concurrent assertion (temporal)
property req_ack;
  @(posedge clk)
  req |-> ##[1:5] ack;  // ack within 1-5 cycles
endproperty

assert property (req_ack)
  else $error("Acknowledge not received in time");
      

Common Assertion Patterns

Essential Assertion Patterns

// 1. Request-Acknowledge
property p_req_ack;
  @(posedge clk) disable iff (!rst_n)
  req |-> ##[1:10] ack;
endproperty

// 2. Mutual Exclusion
property p_mutex;
  @(posedge clk)
  !(grant_a && grant_b);  // Never both high
endproperty

// 3. FIFO Never Overflow
property p_no_overflow;
  @(posedge clk)
  (fifo_full && write_en) |-> read_en;
endproperty

// 4. Data Stability
property p_data_stable;
  @(posedge clk)
  (valid && !ready) |=> $stable(data);
endproperty

// 5. One-Hot State Machine
property p_onehot_state;
  @(posedge clk) disable iff (!rst_n)
  $onehot(state);
endproperty

// 6. Eventually (Liveness)
property p_eventually_done;
  @(posedge clk)
  start |-> s_eventually done;
endproperty
      

Cover Properties

Prove that scenarios are reachable:

// Ensure back-to-back transactions possible
cover property (@(posedge clk)
  (valid && ready) ##1 (valid && ready)
);

// Ensure FIFO can reach full state
cover property (@(posedge clk)
  fifo_count == DEPTH
);
      

Formal Verification Methodology

1. Define Verification Goals

  • Identify critical functionality to verify
  • Determine completeness requirements
  • Prioritize based on risk

2. Write Properties

  • Safety: Bad things never happen
  • Liveness: Good things eventually happen
  • Functional: Correct behavior for operations

3. Create Environment Constraints

Constrain inputs to valid scenarios:

// Assume valid input constraints
assume property (@(posedge clk)
  data_valid |-> data_size inside {1, 2, 4, 8}
);

assume property (@(posedge clk)
  !($isunknown(control_signals))  // No X values
);
      

4. Run Formal Analysis

Formal Verification Flow:
┌──────────────────┐
│  Design (RTL)    │
└────────┬─────────┘
         │
         ▼
┌──────────────────┐     ┌──────────────────┐
│  Assertions      │────►│  Formal Tool     │
│  Assumptions     │     │  (JasperGold,    │
│  Cover Points    │     │   VC Formal,     │
└──────────────────┘     │   Questa Formal) │
                         └────────┬─────────┘
                                  │
         ┌────────────────────────┼────────────────────────┐
         │                        │                        │
         ▼                        ▼                        ▼
┌──────────────┐        ┌──────────────┐        ┌──────────────┐
│    PROVEN    │        │   FALSIFIED  │        │  INCONCLUSIVE│
│ (All states) │        │(Counterexample)       │   (Timeout)  │
└──────────────┘        └──────────────┘        └──────────────┘

5. Debug Failures

  • Analyze counterexample waveform
  • Determine if design bug or assertion error
  • Fix and re-run

Handling Complexity

Abstraction Techniques

Manage state space explosion:

  • Cut Points: Abstract complex logic as free variables
  • Black Boxing: Replace verified blocks with assumptions
  • Assume-Guarantee: Decompose into smaller problems
  • Case Splitting: Verify modes separately

Bounded Model Checking (BMC)

Verify properties up to a cycle bound:

  • Finds bugs quickly in early cycles
  • Does not prove absence of bugs beyond bound
  • Useful for initial debugging

Induction

Prove properties for any depth:

  • Base Case: Property holds from reset
  • Inductive Step: If property holds at cycle N, holds at N+1
  • May require helper assertions (invariants)

Formal Verification Applications

Control Logic

  • State machine verification
  • Arbitration logic
  • Handshaking protocols

Interface Compliance

  • AXI/AHB/APB protocol checks
  • FIFO full/empty conditions
  • Ready/valid handshakes

Security Properties

  • Information flow (no data leakage)
  • Access control verification
  • Privilege escalation checks

Safety-Critical (ISO 26262)

  • Fault tolerance verification
  • Watchdog functionality
  • Safe state transitions

Formal Verification Tools

Commercial Tools

  • Cadence JasperGold: Industry leader for FPV
  • Synopsys VC Formal: Integrated with VCS
  • Siemens Questa Formal: Comprehensive ABV

Open Source

  • SymbiYosys: Open-source formal framework
  • Yosys: Synthesis + formal flow
  • ABC: Academic verification tool

Conclusion

Formal verification provides mathematical guarantees of design correctness that simulation cannot achieve. By expressing specifications as assertions and using model checking or equivalence checking, engineers can find corner-case bugs and prove critical properties with complete confidence.

Vcores employs formal verification extensively in our IP development, with assertion libraries and formal testbenches included with our cores. We also offer formal verification services to help customers achieve sign-off confidence for their designs.

Tags: formal verification property checking model checking SVA assertion-based verification

Need IP Cores for Your Design?

Vcores offers silicon-proven IP cores for ASIC and FPGA designs. Get high-quality, verified IP with comprehensive documentation and support.

Explore Products Contact Us