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.
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:
logicunifieswireandregdeclarations, whilewireremains required for multi-driver nets.always_combdetects unassigned branches and executes automatically at simulation time zero.unique caseenforces single-match branch evaluation with automated compiler warnings.struct packedorganizes related signals into contiguous hardware bit vectors.modportenforces directional port access on shared interfaces at compile time.- Object-oriented classes model dynamic testbench stimulus and scoreboards.
randgenerates uniform random values, whilerandcgenerates non-repeating cyclic sequences.- Unsatisfiable constraints cause
randomize()to return zero. - Modular testbenches separate responsibilities into drivers, monitors, and scoreboards.
- Immediate assertions execute procedurally; concurrent assertions evaluate temporal logic across clock cycles.
- The
|->operator evaluates overlapping implications, whereas|=>evaluates non-overlapping implications. - The
disable iffclause suppresses false assertion errors during system reset. - 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.