Not, and Property and/or
Negate a property with not and its strength swap, join properties with and and or, and group them by precedence.
You Will Be Able To
- Write "this must never happen" rules with
not, and say why negating Booleans is different. - Say how
notturns a weak property into a strong one, and what that means at the end of a test. - Read the verdict of property
andandor, and write runnable forms for Verilator 5.052. - Group a property by the precedence of its operators.
- Lesson
- A3.3
- Time
- 25 min
- Runs on
- Verilator
- Check
- 5 questions
A rule says "no error in the three edges after a request". Someone writes req |-> ##[1:3] !err. It passes on every trace that has one quiet edge in the window.
Negated Booleans
req |-> ##[1:3] !err
Some edge in the window has err low.
Negated property
req |-> not (##[1:3] err)
No edge in the window has err high.
Negating a property is not the same as negating its Booleans. This lesson works through not, and and or on whole properties.
Negating a Property
not p holds exactly when p does not. Put a sequence inside, and you get "this pattern never happens here".
Each window holds one error. The negated property fails on it; the negated Booleans pass at the first quiet edge.
| Rule | Standard | Verilator 5.052 (measured) |
|---|---|---|
start |-> not (##[1:3] err) | fails 2 of 12 attempts | fails twice |
not (start |-> ##[1:3] err) | fails all 12: it passes only where the implication fails | fails twice, as if the not were inside |
Trace: the 12 edges of program 1 in practice problem A3.3.1. Outside the implication, not inverts the rule; a negated vacuous success is a vacuous failure (16.14.8). 5.052 gets it silently wrong.
The Strength Swap
A sequence used as a property is weak: if the test ends before it can match, it is not counted as false. not turns weak into strong, and strong into weak (IEEE 1800-2023 16.12.3).
So req |-> not (##[1:$] err) is strong. A request near the end of a test, with no error yet, is still open. The standard counts that open attempt as false when the test ends.
- Edge 5 · t=45
err rises at 45: the pattern happened, so the attempt from 5 fails.
- Edge 10 · t=95
The attempt from 75 has seen no error, but nothing rules one out. The negation is strong, so the open attempt is false when the test ends.
Read the lanes as text
- attempt @5, from edge 1 (t=5): fails at edge 5 (t=45).
- attempt @75, from edge 8 (t=75): is still running at the end of the run: strong, so it fails.
Sampled values, edge 1 to 10: req 1 0 0 0 0 0 0 1 0 0; err 0 0 0 0 1 0 0 0 0 0.
Standard behaviour, derived in docs/sva-standard-traces/A3.md (sva-073). Write not strong(##[1:$] err) for a weak rule that passes a clean end.
Verilator 5.052 runs this property. It reports the failure at 45 and says nothing about the open attempt when the run ends (measured). The standard fixes that attempt as false; how a tool reports it is left to the tool.
Property And
p and q holds when both properties hold. It fails as soon as either one fails, and passes when the later of the two passes (16.12.5).
- Edge 4 · t=35
b is 0 at 35: the left side fails, so the and fails.
- Edge 6 · t=55
d is 0 at 55: the right side fails.
- Edge 8 · t=75
Both sides fail at 75. That is one failed attempt, reported once.
Read the lanes as text
- attempt @5, from edge 1 (t=5): passes at edge 2 (t=15).
- attempt @25, from edge 3 (t=25): fails at edge 4 (t=35).
- attempt @45, from edge 5 (t=45): fails at edge 6 (t=55).
- attempt @65, from edge 7 (t=65): fails at edge 8 (t=75).
Sampled values, edge 1 to 10: a 1 0 1 0 1 0 1 0 0 0; b 0 1 0 0 0 1 0 0 0 0; c 1 0 1 0 1 0 1 0 0 0; d 0 1 0 1 0 0 0 0 0 0.
Standard behaviour, derived in docs/sva-standard-traces/A3.md (sva-074).
Verilator 5.052 reports the attempt from 65 twice, once per failing side (measured: 4 failures where the standard has 3). The runnable form states both sides in one consequent.
Property Or
p or q holds when at least one property holds (16.12.4). It passes as soon as one side passes, and fails only when both have failed.
- Edge 4 · t=35
b fails but d holds at 35: the or passes.
- Edge 6 · t=55
b holds at 55: pass, although d fails.
- Edge 8 · t=75
Both sides fail at 75: the only failure.
Read the lanes as text
- attempt @5, from edge 1 (t=5): passes at edge 2 (t=15).
- attempt @25, from edge 3 (t=25): passes at edge 4 (t=35).
- attempt @45, from edge 5 (t=45): passes at edge 6 (t=55).
- attempt @65, from edge 7 (t=65): fails at edge 8 (t=75).
Sampled values, edge 1 to 10: a 1 0 1 0 1 0 1 0 0 0; b 0 1 0 0 0 1 0 0 0 0; c 1 0 1 0 1 0 1 0 0 0; d 0 1 0 1 0 0 0 0 0 0.
Standard behaviour, derived in docs/sva-standard-traces/A3.md (sva-075).
Verilator 5.052 misses this failure: it reports none (measured). Here both sides start on the same edge and check one Boolean at the same delay. Then one antecedent with both conditions is an exact equivalent; for other shapes it is not.
Precedence of Property Operators
Without parentheses, a property is grouped by IEEE 1800-2023 Table 16-3. Higher rows bind tighter.
- Property
- Structure
- not first
notbinds to the operand right after it:not b. - and, then or
andgroups beforeor, socjoinsnot bfirst, thendjoins byor. - until, then the implication
untiltakes the whole left side. The implication binds loosest, so all of it is the consequent ofa.
Read the diagram as text
- not b: tightest of these
- (not b) and c: and next
- ((not b) and c) or d: then or
- (...) until e: then until
- a |-> (...): implication last
- not b → (not b) and c: and
- (not b) and c → ((not b) and c) or d: or
- ((not b) and c) or d → (...) until e: until
- (...) until e → a |-> (...): |->
Read from the tightest operator outwards. When in doubt, add the parentheses yourself.
| Binds | Operators | Associativity |
|---|---|---|
| tightest | [*] [=] [->] | - |
## | left | |
throughout | right | |
within | left | |
intersect | left | |
not, nexttime, s_nexttime | - | |
and | left | |
or | left | |
iff | right | |
until family, implies | right | |
|-> |=> #-# #=# | right | |
| loosest | always, eventually families, if, case, accept_on family | - |
So a |-> b until c is a |-> (b until c), and not a and b is (not a) and b.
Try It
Three rules on one read channel. no_err uses not over a bounded window and catches the error at 55.
both is the runnable form of an and: the beat must come and carry no error flag. It fails at 55 and at 85. either is the form of an or: a beat or a retry answers each time.
Rewrite no_err as req |-> ##[1:3] !err and predict its count.
no_err=1 both=2 either=0Check Yourself
Common Mistakes
Wrong Write "no err in the window" as ##[1:3] !err.
That passes as soon as one edge in the window is quiet.
Fix Negate the property: not (##[1:3] err).
req |-> ##[1:3] !errreq |-> not (##[1:3] err)Wrong Negate an open-ended sequence and expect a clean end of test to pass.
not makes the weak sequence strong, so an open attempt is false at the end.
Fix Write not strong(##[1:$] err), or bound the window.
Wrong Count two failures when both sides of an and fail.
One attempt has one verdict.
Fix Count attempts, not sides. On Verilator 5.052 use the one-consequent form.
Wrong Read a |-> b until c as (a |-> b) until c.
until binds tighter than |->.
Fix Add parentheses whenever the grouping matters to a reader.
Remember
not pholds whenpdoes not; negating a property is not negating its Booleans.notswaps weak and strong:not (##[1:$] e)is false at the end of a test,not strong(...)is not.andfails when either side fails;orfails only when both fail. Each attempt has one verdict.- Verilator 5.052 double-reports
and, missesorfailures and stays silent on an open strong attempt. - Precedence:
notoverandoveroroveriffoveruntilover|->.