Module 9: SystemVerilog for Design & Verification · 9.3 Assertions — SVA

Writing Properties and Sequences

The previous article introduced inline concurrent assertions. As verification environments expand, inline checks become difficult to maintain across multiple interfaces. SystemVerilog provides named sequence and property blocks to create modular assertion libraries.

Declaring Named Sequences

A sequence encapsulates a multi-cycle temporal pattern:

sequence req_then_ack;
    req ##[1:4] ack;   // Acknowledgment must assert between 1 and 4 cycles after request
endsequence

The bracket notation ##[1:4] specifies a bounded cycle range. The acknowledgment signal may assert on cycle 1, 2, 3, or 4. This range operator accommodates variable handshake latencies without over-constraining the timing specification.

req followed by ack anywhere in a window of cycles
Figure 1: A range delay: ack may land anywhere in the window

Binding Sequences to Properties

A property combines sequences with clocking events, reset conditions, and logical implications:

property req_gets_ack;
    @(posedge clk) req |-> req_then_ack;
endproperty

assert property (req_gets_ack)
else $error("Request was not acknowledged within the required 1 to 4 cycle window");

Separating sequence patterns from property rules promotes code reuse. Engineers can reference the same sequence across different assertion and coverage directives.

Constructing an Assertion Module

Group related protocol checks into a dedicated verification module:

module handshake_assertions (
    input logic clk, rst_n,
    input logic req, ack
);
    sequence req_then_ack;
        req ##[1:4] ack;
    endsequence

    sequence ack_then_req_falls;
        ack ##1 !req;
    endsequence

    property p_req_gets_ack;
        @(posedge clk) disable iff (!rst_n)
        req |-> req_then_ack;
    endproperty

    property p_req_falls_after_ack;
        @(posedge clk) disable iff (!rst_n)
        ack |-> ack_then_req_falls;
    endproperty

    property p_req_held_until_ack;
        @(posedge clk) disable iff (!rst_n)
        $rose(req) |-> req until ack;     // req must remain high until ack asserts
    endproperty

    assert property (p_req_gets_ack)
    else $error("Handshake error: req not acknowledged within 1 to 4 cycles");

    assert property (p_req_falls_after_ack)
    else $error("Handshake error: req remained high after ack asserted");

    assert property (p_req_held_until_ack)
    else $error("Handshake error: req dropped before ack asserted");

endmodule

The disable iff (!rst_n) clause disables assertion checks during active reset. This prevents false error reports when signals initialize into transient states. The until keyword ensures that req stays asserted until ack transitions high.

Assertions as Executable Documentation

Formal assertions serve as executable hardware documentation. Standard paper specifications often become outdated as implementations evolve. In contrast, formal properties remain synchronized with design behavior because simulators evaluate them on every cycle. Designers bind assertion checkers to interfaces to validate protocol compliance automatically.

Summary Checklist for Module 9

Before proceeding to Module 10, review these core SystemVerilog concepts:

  1. logic unifies wire and reg declarations, while wire remains required for multi-driver nets.
  2. always_comb detects unassigned branches and executes automatically at simulation time zero.
  3. unique case enforces single-match branch evaluation with automated compiler warnings.
  4. struct packed organizes related signals into contiguous hardware bit vectors.
  5. modport enforces directional port access on shared interfaces at compile time.
  6. Object-oriented classes model dynamic testbench stimulus and scoreboards.
  7. rand generates uniform random values, while randc generates non-repeating cyclic sequences.
  8. Unsatisfiable constraints cause randomize() to return zero.
  9. Modular testbenches separate responsibilities into drivers, monitors, and scoreboards.
  10. Immediate assertions execute procedurally; concurrent assertions evaluate temporal logic across clock cycles.
  11. The |-> operator evaluates overlapping implications, whereas |=> evaluates non-overlapping implications.
  12. The disable iff clause suppresses false assertion errors during system reset.
  13. Formal assertions provide executable documentation that simulators enforce continuously.

Module 9 established modern SystemVerilog design and verification foundations. Module 10 applies these skills across five comprehensive digital hardware implementation projects.

← Concurrent Assertions and Temporal Logic