Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Course
  • Reading Paths
  • Concept Map
  • How to Read the Diagrams
  • Part 0: What Is a Protocol?10
  • Part 1: Timing and Clocking11
  • Part 2: Encoding and Framing12
  • Part 3: Handshakes13
  • Part 4: Flow Control17
  • Part 5: Transactions19
  • Part 6: Concurrency and Performance17
  • Part 7: Ordering13
  • Part 8: Sharing and Arbitration12
  • Part 9: Deadlock and Liveness13
  • Part 10: Reliability and Recovery20
  • Part 11: Bring-Up and Link Management10
  • Part 12: Power8
  • Part 13: Shared State and Coherence9
  • Part 14: Security and Isolation7
  • Part 15: Specifying and Verifying11
    • Writing an Interface Contract
    • Safety and Liveness
    • Protocol Assertions
    • Monitors and Transaction Reconstruction
    • Ordering-Aware Scoreboards
    • Protocol Coverage
    • Formal Methods for Protocols
    • Compliance and VIP
    • Observability and Tracing
    • A Waveform Debug Method
    • Drills: Specifying and Verifying
  • Part 16: Protocols Dissected17
  • Part 17: Capstones5
  • Part 18: Interview Preparation6
Loading lesson

‹Part 15: Specifying and Verifying
  1. Topics
  2. First Principles of Hardware Protocols
  3. Part 15: Specifying and Verifying
  4. Formal Methods for Protocols

Part 15 · Specifying and Verifying · Senior (S)

Formal Methods for Protocols

Simulation checks the input sequences you generate; formal tools check all of them. Which protocol properties formal proves better than simulation (handshake rules, credit conservation, deadlock freedom), how assumptions on the partner work, and where formal runs out.

On this page

    Note

    Level: Senior (S) · Answers: How do we know it is correct?

    Before this: Safety and Liveness, Protocol Coverage

    A credit counter passes months of random simulation. A formal tool, run on the counter alone for twenty minutes, returns a nine-cycle trace: a credit returns in the same cycle a reset is released and a packet is sent, and the count ends one too high. The sequence is legal but so specific that random stimulus would have needed astronomically many cycles to stumble on it. The tool did not get lucky. It looked at every sequence.

    What can formal tools prove about a protocol that simulation cannot, and how are they used?

    The obvious answer, and why it breaks

    The obvious answer is that more simulation, and better coverage, eventually finds everything. Simulation only checks the sequences it generates. The bugs that survive good simulation are combinations of rare events in specific cycles: a reset and a credit return and a send together, two requests colliding at a wrap-around. Coverage plans name the corners you thought of; the dangerous ones are the corners you did not.

    The idea: check every legal input sequence

    • Assertions (assert): the properties to prove, the same ones used in simulation (lesson 15.3).

    • Assumptions (assume): the rules the environment follows, typically the partner's side of the protocol. Without them, the tool finds "bugs" caused by impossible inputs.

    • Covers (cover): situations the tool must show are reachable, so you know the assumptions did not rule everything out.

    • Result: a proof that the assertion holds for every input sequence allowed by the assumptions, or a counterexample trace, usually short (fact T31).

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // snippet: formal setup for the receiving side of a credit link
    // The sender's side of the protocol is assumed; the receiver's is asserted.
    assume property (@(posedge clk) disable iff (!rst_n)
      vld |-> credits_at_sender > 0);           // the sender never sends without credit
    assert property (@(posedge clk) disable iff (!rst_n)
      occupancy <= DEPTH);                      // the buffer never overflows
    assert property (@(posedge clk) disable iff (!rst_n)
      occupancy + credits_at_sender + credits_in_flight == DEPTH);  // credits conserved
    cover property (@(posedge clk) occupancy == DEPTH);  // the buffer can really fill

    The conservation assertion states the credit loop's invariant directly: every buffer slot is either occupied, held as a credit by the sender, or a credit on its way back. Any leak or double count breaks it.

    What formal does best for protocols

    Property

    Why formal suits it

    Handshake rules (hold, stable)

    Small, local; proved quickly for every stall pattern

    Credit and counter conservation

    Invariants over all interleavings of sends, returns and resets

    FIFO and buffer overflow or underflow

    Corner cases at full and empty with simultaneous push and pop

    Deadlock and liveness

    Can prove "eventually" or produce a looping trace (Part 9)

    Arbiter fairness

    Bounded-wait properties for every request pattern

    Ordering rules

    No illegal overtaking, for every arrival order

    Where formal runs out

    • State-space size: whole subsystems are too large; formal works best on blocks and interfaces, with the rest abstracted.

    • Bounded results: a bounded proof to depth N says nothing beyond N; induction-based proofs cover all depths but may need helper invariants.

    • Over-constraining: a wrong assumption can hide real bugs; covers guard against it.

    • Data-heavy behaviour: long arithmetic pipelines and end-to-end data transformations are better checked by simulation against a model.

    How real verification does it

    Practice

    Use

    Protocol assertion IP in formal

    The same AXI protocol assertions used in simulation drive formal proofs on an interface (fact A29)

    Assume-guarantee

    Each side's rules are assumptions when verifying the other side, assertions when verifying itself

    Formal for deadlock

    Proving credit loops and arbiters free of deadlock and starvation

    What breaks

    The opening counter (illustrative) had a priority bug: on the cycle reset was released, its update logic applied both the reset value and the credit return. The formal counterexample was nine cycles long and pointed at the line. A regression of the corrected counter proved the conservation invariant unbounded in a few minutes, and the same setup was reused for every credit counter in the chip.

    Why this matters

    Senior lens. Use formal where the risk is in combinations rather than data: handshakes, counters, credit loops, FIFOs, arbiters, ordering and deadlock. Write the partner's rules as assumptions and your side's as assertions, guard against over-constraint with covers, and prefer unbounded proofs for invariants. Pair it with simulation for data paths and end-to-end behaviour.

    Interview

    Asked: "When would you use formal verification on an interface?"

    Weak answer: When simulation is too slow.

    Strong answer: When the risk is in rare combinations of events rather than data: handshake rules, credit and counter conservation, FIFO full and empty corners with simultaneous push and pop, arbiter fairness, ordering rules and deadlock freedom. Formal checks every input sequence the assumptions allow, so it finds the nine-cycle corner random simulation never hits. I'd write the partner's protocol rules as assumptions, my side's as assertions, add covers to prove the assumptions aren't over-constraining, and aim for unbounded proofs of invariants. Data-heavy end-to-end behaviour stays in simulation.

    Follow-ups: (1) What goes wrong with a bad assumption? (2) What does a bounded proof tell you?

    Check yourself Why are covers essential in a formal setup?

    An over-constraining assumption can make the design's interesting states unreachable, so every assertion passes vacuously; covers show those states are still reachable.

    Check yourself What invariant would you prove for a credit loop with buffer depth D?

    Occupancy plus credits held by the sender plus credits in flight equals D, at every cycle.

    Key takeaways

    • Formal checks every input sequence the assumptions allow, finding rare combinations simulation misses.

    • Assume the partner's rules, assert your own, and use covers to catch over-constraint.

    • Best for handshakes, counters, credit loops, FIFOs, arbiters, ordering and deadlock; simulation keeps data paths.

    Keep going

    Next: Lesson 15.8, Compliance and VIP. Testing against the specification, not against your own reading of it.

    Related topics

    • Part 15 overview: Specifying and Verifying

    Previous

    202 / 234

    Next: Compliance and VIP

    Up next

    Up nextCompliance and VIP

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Writing an Interface Contract
    • Safety and Liveness
    • Protocol Assertions