SystemVerilog Assertions (SVA) interview questions
Implication, sequences, repetition operators, sampled-value functions, disable iff and the classic SVA traps.
📚 Learn it first: Chapter 3: SystemVerilog Assertions Essentials
Q1What is the difference between immediate and concurrent assertions?
Basic
- Immediate assertions (
assert (expr);) run like anifstatement inside procedural code, at the moment the statement executes. They check a single point in time and can glitch on intermediate values (deferred formsassert #0/assert finalavoid that). - Concurrent assertions (
assert property (...)) are clocked, sample values in the preponed region, and can describe behaviour across many cycles with sequences.
Formal tools work almost entirely with concurrent assertions.
Q2What is the difference between |-> and |=>?
Basic
|-> and |=>?|-> is overlapping implication: the consequent starts in the same cycle the antecedent ends. |=> is non-overlapping: the consequent starts one cycle later. So a |=> b is exactly a |-> ##1 b.
assert property (@(posedge clk) req |-> ack); // ack in the same cycle as req
assert property (@(posedge clk) req |=> ack); // ack in the next cycleQ3Explain $rose, $fell, $stable and $past.
Basic
$rose, $fell, $stable and $past.All of them compare sampled values at clock ticks:
$rose(x): the LSB of x was 0 at the previous tick and is 1 now.$fell(x): it was 1 and is now 0.$stable(x): x has the same value as at the previous tick.$past(x, n): the value of x n ticks ago (default 1).
// data must not change while valid is waiting for ready
assert property (@(posedge clk) valid && !ready |=> $stable(data));Trap: in the first cycle after reset there is no real "previous" value, so $past returns the initial value — guard such checks with reset or a "past valid" flag.
Q4What does disable iff do? Is it synchronous?
Basic
disable iff do? Is it synchronous?disable iff (cond) abandons any evaluation of the property in progress while cond is true, and the attempt counts as neither pass nor fail. It is typically used for reset.
It is asynchronous and uses current (not sampled) values, so an attempt is cancelled as soon as reset asserts, even between clock edges.
default disable iff (!rst_n);
assert property (@(posedge clk) req |=> gnt);Q5What does a ##[1:3] b mean? And ##[1:$]?
Basic
a ##[1:3] b mean? And ##[1:$]?a ##[1:3] b matches when b is true 1, 2 or 3 cycles after a. As a property it holds if any of those three cycles has b.
##[1:$] means "one or more cycles later, unbounded". Be careful: in an assertion, a |-> ##[1:$] b is a weak property and can never fail in formal (any finite trace could still be extended to see b). For a real "eventually" check use s_eventually or strong(##[1:$] b).
Q6Explain the repetition operators [*n], [->n] and [=n].
Intermediate
[*n], [->n] and [=n].- Consecutive
b[*3]: b true for 3 cycles in a row. - Goto
b[->3]: b true 3 times, not necessarily consecutive; the match ends exactly on the 3rd occurrence. - Non-consecutive
b[=3]: b true 3 times; the match may continue after the 3rd occurrence while b stays false.
// after start, the 4th beat must come with last
assert property (@(posedge clk) start |=> (beat[->4]) |-> last);The difference between goto and non-consecutive only shows when something follows: b[->2] ##1 c needs c right after the 2nd b; b[=2] ##1 c allows a gap.
Q7In which region are values sampled for concurrent assertions, and why does it matter?
Intermediate
Concurrent assertions use values sampled in the preponed region — i.e. the values just before the clock edge, the same values the flops see. This avoids races with the RTL that updates on the same edge.
Consequence: if a flop q updates on the clock edge, an assertion at that edge sees the old value of q. That is why "q follows d" is written d |=> q, not d |-> q.
Q8What do throughout, within and intersect do?
Intermediate
throughout, within and intersect do?c throughout s: condition c must hold in every cycle while sequence s is matching.s1 within s2: s1 must match somewhere inside the time span of s2.s1 intersect s2: both match, starting and ending in the same cycles (same length).
// while a burst is in progress, the address must stay stable
assert property (@(posedge clk)
burst_start |=> $stable(addr) throughout (beat[->LEN]));Q9What is the difference between strong and weak sequences in SVA?
Advanced
A weak sequence property passes if the trace ends before the sequence has a chance to fail. A strong one requires the sequence to actually complete. In assert property, sequences are weak by default (since SVA 2009).
In formal, traces are infinite, so a weak unbounded wait (##[1:$] b) can never be refuted. Use strong(...), s_eventually or s_until to state real liveness, and add fairness assumptions on the environment.
Q10How do you check that a grant vector is one-hot or all zero?
Basic
assert property (@(posedge clk) $onehot0(gnt)); // at most one bit set
assert property (@(posedge clk) busy |-> $onehot(gnt)); // exactly one while busy$onehot0 allows zero or one bit set; $onehot requires exactly one. $countones(x) is the general form.
Q11What are local variables in SVA and when do you need them?
Advanced
A local variable is declared inside a sequence or property and captures a value at one point of a match, to be compared later. You need it whenever a later check depends on data seen earlier, and several transactions can overlap.
property p_data_echo;
logic [7:0] d;
@(posedge clk) (in_valid, d = in_data) |-> ##[1:4] (out_valid && out_data == d);
endproperty
assert property (p_data_echo);In formal, local variables can be expensive. A common alternative is auxiliary code: a small tracker that records one symbolic transaction (see the FPV topic).
Q12What is the difference between a sequence and a property?
Basic
A sequence describes a pattern over time that can match (e.g. req ##1 gnt). A property is something that is true or false about a trace and can use sequences together with implication, not, until, s_eventually and so on.
You assert, assume or cover properties. Sequences are building blocks (and can also be covered directly).
Q13How would you check the values of registers right after reset?
Intermediate
// while reset is held, outputs are in their reset state
assert property (@(posedge clk) !rst_n |=> (state == IDLE) && !valid_o);
// note: no "disable iff (!rst_n)" here - it would disable the very check we wantThe trap is the default disable iff (!rst_n): it switches off assertions during reset, so a reset-value check must override or avoid it (declare it without the default, or use disable iff (1'b0)).
Q14Why do we write cover properties, if assertions already prove correctness?
Intermediate
Covers answer a different question: "Can the interesting thing even happen in my environment?"
- They catch over-constraint: if a cover for "FIFO becomes full" is unreachable, your assumptions are too strong and the proofs are hollow.
- They show example traces for design exploration before a testbench exists.
- Their depths tell you how deep a bounded proof must be to be meaningful.
Discussion
No comments yet.