Assertions are executable spec comments — they watch your design 24/7 during simulation and scream the moment an invariant breaks. RTL owners don't need full formal verification fluency; a handful of immediate and concurrent SVA patterns cover 80% of real blocks.
An assertion states a property that must always hold (or hold after a trigger). assert(condition) is the immediate form. assert property (@(posedge clk) ...) is the concurrent form — it monitors signals across clock cycles.
Start with immediate asserts in your RTL. Add concurrent properties for protocol timing you can't express in one line.
| Type | Syntax | When to use | Synth? |
|---|---|---|---|
| Immediate | assert (expr) else $error(...) | One-cycle invariants inside always | Often yes |
| Concurrent | assert property (p) else $error(...) | Multi-cycle protocol rules | Depends on tool |
| Assume | assume property (p) | Constrain inputs (formal/sim) | Sim / formal |
| Cover | cover property (p) | Did this scenario ever happen? | Sim only |
Drop these inside your always blocks or at the end of a combinational block. They catch logic bugs during simulation and can sometimes synthesize into hardware checkers.
// Inside an always @(posedge clk) block:
always @(posedge clk) begin
if (en && !full)
wr_ptr <= wr_ptr + 1;
// One-hot FSM check (sim + some synth flows)
assert ($onehot(state))
else $error("FSM state not one-hot: %b", state);
// Mutually exclusive controls
assert (!(wr_en && rd_en && empty))
else $error("Read and write when empty");
end
// Combinational range check
always @(*) begin
assert (addr < DEPTH)
else $error("Address out of range: %0d", addr);
end
Don't assert on signals that are X during reset unless you guard with if (rst_n). Unconditional asserts during reset cause false failures and teach you to ignore assertion noise.
Concurrent assertions use properties — temporal expressions evaluated every clock edge. Three operators cover most RTL owner needs:
|-> (overlapping implication): if antecedent is true now, consequent must hold.##N (delay): wait N clock cycles.$rose(sig) / $fell(sig): detect edges.// Valid-ready handshake: transfer only when both high
property p_xfer;
@(posedge clk) disable iff (!rst_n)
(s_valid && s_ready) |-> ##1 (data_captured);
endproperty
assert property (p_xfer) else $error("Transfer handshake violated");
// After reset release, FSM must reach IDLE within 3 cycles
property p_reset_to_idle;
@(posedge clk) $rose(rst_n) |-> ##[1:3] (state == IDLE);
endproperty
assert property (p_reset_to_idle)
else $error("FSM did not return to IDLE after reset");
// m_valid must stay high until m_ready
property p_valid_hold;
@(posedge clk) disable iff (!rst_n)
(m_valid && !m_ready) |=> m_valid; // |=> non-overlapping next cycle
endproperty
assert property (p_valid_hold)
else $error("m_valid dropped before handshake");
p_xfer checks data captured at cycle 3
p_valid_hold checks m_valid stays 1 after cycle 3
| Operator | Meaning | Example |
|---|---|---|
|-> | If A now, then B (same cycle start) | a |-> b |
|=> | If A now, then B next cycle | a |=> b |
##1 | Delay exactly 1 cycle | a |-> ##1 b |
##[1:5] | Delay 1 to 5 cycles | a |-> ##[1:5] b |
$rose(x) | x went 0→1 this cycle | $rose(req) |
$fell(x) | x went 1→0 this cycle | $fell(ack) |
disable iff | Skip check when condition true | disable iff (!rst_n) |
Simple immediate asserts, one-hot checks, range checks. Some flows map these to hardware error flags.
Complex ##[m:n] ranges, cover property, sequences with repetition. Keep in ifdef SIM or bind file.
Put sim-only assertions in a separate *_assert.sv bound to DUT — keeps RTL clean for synthesis.
// assertions bind file — not synthesized
`ifdef SIM
bind sync_fifo fifo_assertions #(
.DEPTH(DEPTH)
) u_assert (
.clk (clk),
.rst_n (rst_n),
.wr_en (wr_en),
.rd_en (rd_en),
.full (full),
.empty (empty),
.count (count)
);
module fifo_assertions #(parameter DEPTH=16) (
input clk, rst_n, wr_en, rd_en, full, empty,
input [$clog2(DEPTH+1)-1:0] count
);
assert property (@(posedge clk) disable iff (!rst_n)
full |-> !wr_en)
else $error("Write when full!");
assert property (@(posedge clk) disable iff (!rst_n)
empty |-> !rd_en)
else $error("Read when empty!");
endmodule
`endif
FSMs are the #1 place RTL owners add assertions. Encode legal transitions directly from your state diagram:
// States: IDLE=0, BUSY=1, DONE=2
localparam IDLE=0, BUSY=1, DONE=2;
// Only legal transitions (from state diagram)
property p_idle_to_busy;
@(posedge clk) disable iff (!rst_n)
(state == IDLE && start) |-> ##1 (state == BUSY);
endproperty
property p_busy_to_done;
@(posedge clk) disable iff (!rst_n)
(state == BUSY && done_flag) |-> ##1 (state == DONE);
endproperty
property p_done_to_idle;
@(posedge clk) disable iff (!rst_n)
(state == DONE && ack) |-> ##1 (state == IDLE);
endproperty
assert property (p_idle_to_busy) else $error("Illegal: IDLE->? (not BUSY)");
assert property (p_busy_to_done) else $error("Illegal: BUSY->? (not DONE)");
assert property (p_done_to_idle) else $error("Illegal: DONE->? (not IDLE)");
// Cover: did we ever reach DONE? (functional coverage tie-in)
cover property (@(posedge clk) (state == DONE));
Rule of thumb: if you wrote it in the spec as "must never" or "shall always", it belongs in an assertion. If you wrote it as "output equals X when Y", it belongs in the testbench checker.
disable iff (!rst_n) or equivalent`ifdef SIM or placed in bind files$error message with signal values|->, ##N, $rose cover most RTL-owner protocol needs.