Lesson 5: How Do SystemVerilog Assertions Check a Design?
A concurrent assertion states a rule about signals over clock cycles, and the simulator checks it on every clock for the whole run. Instead of writing code that compares outputs at the right moment, you write the rule once: 'whenever in_valid is high, out_valid is high one clock later'. Assertions catch protocol and timing bugs at the cycle they happen, and the same properties can be proved by a formal tool.
What you'll learn
- Immediate and concurrent assertions
- Implication: |-> and |=>
- $past, $isunknown and disable iff
- Cover properties
- What a failing assertion looks like, on a real bug
Conventions and assumptions
Every lesson tests the same small design: a registered 8-bit ALU (add, sub, and, or, xor) whose 9-bit result appears one clock after in_valid; the final project moves on to the synchronous FIFO. All code was compiled and run in AMD Vivado xsim 2025.2, and the output shown is copied from those runs. The complete files are in the site's repository under scripts/verification.
Immediate vs concurrent
An immediate assertion, assert (x == 1), is a procedural check that runs once, where it is written. A concurrent assertion, assert property (...), is clocked: it samples signals at each clock edge and evaluates a sequence over time. Concurrent assertions are what verification teams mean by SVA.
The properties
The overlapping implication a |-> b checks b in the same clock as a; the non-overlapping a |=> b checks b one clock later. $past(a) is the value a had one clock earlier, which lines inputs up with a registered result. disable iff (!rst_n) switches checking off during reset.
// 1. out_valid follows in_valid exactly one clock later.
a_valid: assert property (disable iff (!rst_n) in_valid |=> out_valid)
else $error("out_valid missing one clock after in_valid");
a_no_spurious: assert property (disable iff (!rst_n) !in_valid |=> !out_valid)
else $error("out_valid without a request");
// 2. The result is right: $past() gives the inputs from the request clock.
a_add: assert property (disable iff (!rst_n) in_valid && op == 0 |=> y == $past(a) + $past(b))
else $error("add gave %0d", y);
a_sub: assert property (disable iff (!rst_n) in_valid && op == 1 |=> y == {1'b0, $past(a)} - {1'b0, $past(b)})
else $error("sub wrong");
a_logic: assert property (disable iff (!rst_n) in_valid && op inside {[2:4]} |=> y[8] == 1'b0)
else $error("logic op set bit 8");
// 3. Inputs must be known whenever a request is made (a check on the testbench).
a_known: assert property (disable iff (!rst_n) in_valid |-> !$isunknown({op, a, b}));
// Cover: did the test ever see an add that carried out?
c_carry: cover property (disable iff (!rst_n) in_valid && op == 0 ##1 y[8]);
A note on tools: Vivado xsim 2025.2 rejected a default disable iff declaration ('not supported yet for simulation') and $past inside a cast, so each property carries its own disable iff, and the subtraction is widened with concatenation instead. Other simulators accept both forms; the IEEE standard allows them.
What the runs showed
| Design | Result |
|---|---|
| Correct ALU, 300 random clocks | No assertion failures; 45 results with bit 8 set, so the carry cover was hit |
| ALU with the borrow bit dropped (+define+BUG) | a_sub failed 25 times, first at 385 ns; only 20 results set bit 8 |
The bug drops the borrow, so it only shows when a < b. The assertion reported the exact clock and line of each failure, with no scoreboard code at all. The difference in the bit 8 count (45 against 20) is exactly the 25 failing subtractions.
Exercises
- E1. Write a property that y never changes while out_valid is low.
- E2. Why does a_valid use |=> and not |->?
- E3. Write a cover property for two back-to-back requests.
Solutions
- E1. assert property (disable iff (!rst_n) !out_valid |=> $stable(y) || out_valid); after a clock with no result, y holds unless a new result arrives.
- E2. out_valid rises one clock after in_valid, because the ALU is registered; |-> would demand it in the same clock and fail every time.
- E3. cover property (disable iff (!rst_n) in_valid ##1 in_valid);
Common mistakes
- Using |-> where the design responds a clock later.
- Forgetting disable iff, so every check fails during reset.
- Asserting on the testbench's own copy of a value instead of the DUT's signals.
- Writing assertions that are always vacuously true because the trigger never happens. Add a cover property for the trigger.
- Assuming every simulator supports every SVA feature. Check the tool's documentation.
Check your understanding
- Q1. What does $past(a) return? Answer: the value of a at the previous clock edge of the property's clock.
- Q2. What is the difference between assert property and cover property? Answer: assert fails when the property is false; cover records when the property happens, to prove the case was exercised.
- Q3. Why did the buggy ALU only fail on some subtractions? Answer: dropping the borrow changes the result only when a < b.
The course
Last verified
Run in Vivado xsim 2025.2 on 16 November 2026, with and without +define+BUG; outputs copied from those runs. Language rules checked against IEEE 1800-2023.