Why is System Verilog HVL (Hardware Verification Language) to be adopted?
Abstract
Assertion is a very powerful feature of System Verilog HVL (Hardware Verification Language). Nowadays it is widely adopted and used in most of the design verification projects.
This article explains the concurrent assertions syntaxes, simple examples of their usage and details of passing and failing scenarios along with waveform snippets for the ease of understanding.
This article is helpful to anyone who is new to system verification and who wishes to learn System Verification (SV) assertions quickly with simple examples. It is also useful to an experienced person who would like to have a quick refresh before he/she starts implementing it after some break.
Introduction
Irrespective of the verification methodology used in a project, System Verilog assertions help speed up the verification process. Identifying the right set of checkers in verification plan and implementing them using effective SV assertions helps to quickly catch the design bugs and ultimately helps in high-quality design.
Some of the key advantages of SV assertions are as mentioned below:
Multiple lines of checker code can be represented in a few lines effectively using SVA code.
SVA can be ignored by synthesis.
Assertion takes lesser time to debug as they pin point the exact time of failure. Assertions can be turned on/off during simulations. They can have severity levels; failures can be non-fatal or fatal errors.
Multi-Clock assertions are useful in writing checkers around Clock Domain Crossing (CDC) logic
Assertions can be also used for formal verification.
Let us look at different types of examples of SV assertions.
1. Simple ## delay assertion:
Property hash_delay_p checks for,
a) Signal โaโ is asserted high on each clock cycle
b) If โaโ is high in a cycle after two clock cycles, signal โbโ has to be asserted high.
Snippet:
Assertion passes when signal โaโ is high and after two clock cycles signal โbโ is high.
There are two cases for which assertion fails,
when signal โaโ is not asserted high in any cycle.
when signal โaโ asserts high and after two clock signal โbโ is not asserted high.
2. Overlapped Implication:
Property overlapped_implication_p checks,
If the left hand side condition (โaโ==1) of the implication โ|->โ (called โantecedentโ) is true, check the right hand side (called โconsequentโ) condition (โbโ == 1) in the same cycle.
Snippet:
In the above snippet, Assertion passes when signal โaโ is high and in the same clock cycles, signal โbโ is high. Assertion remains in โInactiveโ state when signal โaโ is not asserted high.
Assertion fails only when signal โaโ is asserted high and in the same clock cycle signal โbโ is not asserted high.
3. Non-Overlapped Implication:
Property Non_overlapped_implication_p checks,
If the left hand side condition (โaโ==1) of the implication โ|->โ (called โantecedentโ) is true, check the right hand side (called โconsequentโ) condition (โbโ == 1) in the next cycle.
Snippet:
In above snippet, Assertion passes when signal โaโ is high and in the next clock cycles, signal โbโ is high. Assertion remains in โInactiveโ state when signal โaโ is not asserted high.
Assertion fails only when signal โaโ is asserted high and in the next clock cycle, signal โbโ is not asserted high.
4. Assertion with delay ranges:
Property overlapped_implication_with_range_p checks,
when signal โaโ is asserted high, within given latency ranges it checks assertion of signal โbโ.
Snippet:
In the above snippet, assertion finishes when signal โaโ is asserted high and within 5 to 7 (MIN_DELAY:MAX_DELAY) clock cycles, signal โbโ asserts high.
Assertion fails when signal โaโ is asserted high and within 5 to 7 clock cycles, signal โbโ does not assert high.
5. $rose:
Property rose_p checks when signal โaโ asserts high, in the same cycle it also detects the positive edge on signal โbโ.
Snippet:
In the above snippet, assertion passes when signal โaโ is asserted high and in the same clock cycle, positive edge on signal โbโ is detected.
Assertion fails when signal โaโ is asserted high, but in the same clock cycle, positive edge on signal โbโ is not detected.
6. $fell:
Property fell_p checks when signal โaโ asserts high, in the same cycle, it also detects negative edge on signal โbโ.
Snippet:
In the above snippet, assertion passes when signal โaโ is asserted high and in the same clock cycle, negative edge on signal โbโ is detected.
Assertion fails when signal โaโ is asserted high and in the same clock cycle, negative edge on signal โbโ is not detected.
7. $stable:
Property stable_p checks when signal โaโ asserts high, it checks for no change in signal โbโ. It means, signal โbโ should stay as it was in the previous cycle.
Snippet:
In the above snippet, assertion passes when signal โaโ is asserted high and in the same clock cycle, signal โbโ remains to the same value as in the previous clock cycle.
Assertion fails when signal โaโ is asserted high and in the same clock cycle signal โbโ is also changed from to 0 to 1 (not stable).
Similarly, the assertion would fail if signal โaโ is asserted high and in the same clock cycle, signal โbโ is also changed from to 1 to 0 (not stable).
8. $past:
Syntax: $past (signal_name) $past (signal_name, number of clock cycles)
Property past_p checks when signal โaโ asserts high, it checks signal โbโ was high before 2 clock cycles.
If the second argument is not specified, then by default, $past checks for the signal value in the immediate previous cycle.
Snippet:
In the above snippet, assertion passes when signal โaโ is asserted high and signal โbโ was asserted high before two clock cycles.
Assertion fails when signal โaโ is asserted high and before two clock cycles, signal โbโ was not asserted high.
9. Disable Iff :
Property disable_iff_p, remains disabled if signal โresetโ is asserted high. If reset is not asserted high, then it checks if signal โaโ is asserted high, then in the same cycle, signal โbโ should also be asserted high.
Snippet:
In the above snippet, assertion remains disabled as long as reset is asserted high.
When reset is not asserted and when signal โaโ is asserted high, assertion passes OR fails according to the value of signal โbโ in the same cycle.
10. Consecutive repetition operator:
Syntax:
Signal_name [*n]
It specifies that a signal or a sequence will match continuously for the number of clocks specified.
Property consecutive_repeatation_p checks when the positive edge is detected on signal โaโ, check from next clock onwards, signal โbโ is asserted high continuously for 6 clock cycles, followed by a high value on signal โcโ in the next cycle.
Snippet-1:
In the above snippet, at timestamp 254ns, assertion triggers when positive edge of signal โaโ is detected, starting next clock cycle, signal โbโ is continually high for 6 clock cycles and in the following clock cycle, signal โcโ is asserted high so assertion finishes with pass status at 282ns.
Assertion fails at the time stamp 330ns as signal โbโ is asserted low in the cycle following the positive edge on signal โaโ.
Snippet-2:
In the above snippet, assertion fails when positive edge of signal โaโ is detected, followed by signal โbโ asserted high continuously for 6 clock cycles and in the next clock cycle, signal โcโ is not asserted high.
11. Go to repetition operator:
Syntax:
Signal_name1 [->n] ##1 signal_name2
It specifies that an expression matches the number of times specified, not necessarily in the consecutive clock cycles. The matches can be intermittent.
The key requirement of a โgo toโ repeat is that the last match of the expression (which is checked for repetition) should happen in the clock cycle before the end of the entire sequence match.
Property goto_repeatation_p checks, when positive edge on signal โaโ is detected, checks for signal โbโ to be high continuously or intermittently for 3 clock cycles and in the following cycle (after 3rd match of โbโ high), signal โc โ is asserted high.
Snippet- 1: Passing case:
In the above snippet, at time stamp 234ns, assertion becomes active when the positive edge of signal โaโ is detected. It waits for signal โbโ to be high for 3 clock cycles (not necessarily consecutive cycles, in the snippet, it is 3 cycles before 270ns), followed by signal โcโ asserted high in the immediate next cycle at 270ns, where assertion passes.
Note that if consecutive repetition operator had been used here, then the assertion would have failed at timestamp 234ns due to signal โbโ asserted low, as it requires a consecutive match of signal โbโ to be high upon posedge of signal โaโ.
Snippet โ 2: Failing case:
In the above snippet, at the time stamp 6614ns, assertion triggers upon a positive edge of signal โaโ, starting same cycle signal โbโ continually or intermediately high for 3 clock cycles, followed by signal โcโ, which is not asserted high at 6626ns and hence, assertion fails.
Consider a sequence example which would also pass:
!a a !b !b b !b !b b !b !b !b b c
In this sequence, out of three repetitions of signal โbโ to be high, 2 repetitions of signal โbโ can be the intermediate, but the 3rd repetition of signal โbโ must be followed by signal โcโ (b c) for assertion to pass.
In short, with go to repetition operator, sequence โb cโ must be followed for the last repetition of signal โbโ.
It fails if we have!b c (signal โbโ is not followed by signal โcโ) for the last repetition.
Snippet โ 3 Failing case:
In the above snippet, when the positive edge of signal โaโ is detected, signal โbโ is continually (or can be intermediate) high for 3 clocks, but as signal โcโ is not asserted high, following the last occurence of โbโ, the assertion fails.
12. Non Consecutive repetition operator
This is very similar to โgo toโ repetition except that it does not require the last match on the signal repetition to happen in the clock cycle before the end the entire sequence match.
Syntax:
Signal_name1 [=n] ##1 signal_name2
Property non_consecutive_repeatation_p check, when the positive edge of signal โaโ is detected, check for signal โbโ to be high continuously or intermittently for 3 clock cycles, followed by signal โc โ to be high in any cycle after that while signal โbโ remains low.
Snippet โ 1: Passing case:
In the above snippet, the assertion triggers when the positive edge of signal โaโ is detected. It waits for signal โbโ to be high for 3 clock cycles, followed by signal โcโ asserted high in the next cycle. This behavior is exactly the same as โGo to repetitionโ.
Snippet โ 2: Failing case:
In the above snippet, the assertion triggers when the positive edge of signal โaโ is detected. It waits for signal โbโ to be high for 3 clock cycles, followed by signal โcโ not asserted high and hence, the assertion fails. This behavior is the same as โGo to repetitionโ.
Difference Between โGo to repetitionโ and โnon-consecutive repetitionโ:
Snippet:
Go to repetition:
In the above snippet, at the time stamp 6614ns, assertion becomes active as positive edge of signal โaโ is detected. From the time stamp 6614ns onwards, signal โbโ is asserted high for 3 clock cycles, but in the following cycle, as signal โcโ is not asserted high, goto_repetition_chk fails.
This is because out of 3 repetitions of signal โbโ, the last repetition of signal โbโ must be followed by signal โcโ.
Nonconsecutive repetition:
In the above snippet, Nonconsecutive repetition passes at the time stamp 6634ns as after 3rd repetition of signal โbโ, signal โcโ is asserted high and after 2 clock cycle, signal โbโ is asserted low (!b c).
Similarly, below sequence would also pass for Nonconsecutive repetition.
!a a !b !b b !b !b b !b !b !b b !b !b !b c
This is because after the (last) 3rd occurrence of โbโ, occurrence of โcโ happens without additional occurrences of โbโ.
The below sequence would fail.
!a a !b !b b !b !b b !b !b !b b !b b !b c
This is because the last occurrence of โbโ is followed by another occurrence of โbโ before the occurrence of โcโ.
13. If else inside property:
Property if_else_p checks,
When signal โdโ changes to 1, on next cycle, if signal โbโ is true, then signal โcโ should be high continuously or intermittently for 2 clock cycles, followed by high on signal โdโ in the next cycle.
When signal โdโ changes to 1, on next cycle, if signal โbโ is low, then signal โaโ should be high continuously or intermittently for 2 clock cycles, followed by high on signal โcโ in the next cycle.
Snippet-1:
In the above snippet, assertion triggers when the positive edge of signal โdโ is detected, in the next clock cycle, signal โbโ is high, so assertion waits for signal โcโ to be asserted high continuously or intermittently for 2 clock cycles, followed by high on signal โdโ in the next cycle. Assertion passes at the time stamp 286ns.
Snippet โ 2:
In the above snippet, assertion triggers when positive edge of signal โdโ is detected, in the next clock cycle, signal โbโ is low, so assertion waits for signal โaโ to be asserted high continuously or intermittently for 2 clock cycles, followed by high on signal โcโ in the next cycle. Assertion passes at the time stamp 1150ns.
Snippet โ 3:
In the above snippet, the assertion triggers when positive edge of signal โdโ is detected. In the next clock cycle, signal โbโ is low, so it waits for signal โaโ to be asserted high continuously or intermittently for 2 clock cycles. It expects signal โcโ to be high in the following cycle, but as it is not asserted high, the assertion fails at the time stamp 1322ns.
14. Local variable inside property:
Property lcl_variable_p checks data on i_data to be reflected on o_data after two clock cycles.
Local variables can be used inside the property.
Snippet- 1:
In the above snippet, the assertion passes on every clock cycle as data on i_data is reflected to o_data signal after 2 clock cycles.
15. $onehot property:
Property one_hot_p checks the number of ones must be one in โbus_valโ for each cycle.
Snippet:
In the above snippet, at the time stamp 18ns, where โbus_valโ has the number of ones = 1, assertion passes.
Assertion fails in each cycle where the number of ones is not equal to 1.
Similarly, $onehot(~bus_val) can be used to detect โWALK0โ (5โb11110, 5โb10111, 5โb1111 etc) pattern on signal โbus_valโ.
16. Throughout:
To check whether a certain condition holds true during the evaluation of the entire sequence, โthroughoutโ operator is used.
Property throughout_p checks,
When the positive edge of signal โaโ is detected, check signal โbโ has to be high continuously until signal โcโ goes low.
!c[->1] checks for the occurrence of c[*] ##1 !c, so assertion would stop when the signal โcโ goes low.
Snippet โ 1:
In the above snippet, at time stamp 8182ns, assertion triggers as signal โaโ changes to 1. From the next clock cycle onwards, it checks for signal โbโ to be high till the time stamp 8202ns where signal โcโ goes low.
Note that once the assertion triggers, signal โbโ is continuously asserted high, including the last cycle where signal โcโ goes low and hence, assertion passes at the time stamp 8202ns.
Snippet โ 2:
In the above snippet, assertion triggers when the positive edge of signal โaโ is detected, signal โbโ goes low before signal โc โ goes low and hence, the assertion fails at the time stamp 7922ns.
Snippet โ 3:
Once throughout assertion triggers, it fails if checking condition is not true in the very first checking cycle.
In the above snippet assertion triggers, once signal โaโ changes to โ1โ, in the next clock cycle signal โbโ is not asserted high and hence, the assertion fails even if signal โcโ is not asserted high.
Snippet โ 4:
In the above snippet, the assertion triggers once signal โaโ changes to โ1โ.In the next clock cycle, signal โbโ is asserted high and hence assertion passes even if signal โcโ is not asserted high. This is because the first cycle checking condition is the last cycle of checking.
Snippet โ 5 throughout assertion failure in last cycle:
In the above snippet, assertion triggers when positive edge of signal โaโ is detected, from the next clock cycle onwards, it checks for signal โbโ to be high till the time stamp 7842ns, which is the second last cycle. In the following clock cycle, both signal โbโ and signal โcโ goes low and throughout the assertion fails even if signal โcโ is not high. This is because the assertion expects signal โbโ to be high in the last cycle where signal โcโ goes low. Here, the assertion would have passed if signal โbโ remained asserted for one more cycle.
To conclude, the โthroughoutโ assertion fails if checking condition is not true in any cycle, including the last cycle (which is the end of checking boundary). Here itโs including the cycle where signal โcโ goes low.
17. Until & Until_with:
Until construct is similar to throughout construct. Until construct further have overlap and non-overlap flavor.
Until construct is non overlapping form.
Until_with is overlapping form.
Non-overlapping form evaluates to true if property_expr1 evaluates to true at every clock tick until one clock tick before property_expr2 evaluates to true.
Overlapping form evaluates to true if property_expr1 evaluates to true at every clock tick until property_expr2 evaluates to true.
Syntax: property_expr1 until property_expr2 property_expr1 until_with property_expr2
Property until_with checks for:
When the positive edge of signal โaโ is detected, assertion checks for signal โbโ to be high continuously until signal โcโ goes low.
Property until checks,
When the positive edge of signal โaโ is detected, assertion checks for signal โbโ to be high continuously until one cycle before signal โcโ goes low.
Snippet-1:
In the above snippet, at the time stamp 6290ns, assertion triggers due to signal โaโ changes to 1. From the next clock cycle onwards, it checks for signal โbโ to be high till the time stamp 8310ns, where signal โcโ goes low.
Snippet-2:
In the above snippet, the assertion triggers when the positive edge of signal โaโ is detected, signal โbโ goes low before signal โc โ goes low and, the assertion fails at the time stamp 2026ns.
Difference between throughout/until/until_with:
Until_with assertion works same as throughout assertion.
In the above snippet, assertion triggers when positive edge of signal โaโ is detected. From the next clock cycle onwards, it checks for signal โbโ to be high till the time stamp 7842ns, which is the second last cycle. In following clock cycle, both signal โbโ and signal โcโ goes low and throughout assertion fails even if signal โcโ is not high. This is because the assertion expects signal โbโ to be high in the last cycle where signal โcโ goes low. Here throughout and until_with assertions would have passed if signal โbโ remained asserted for one more cycle.
Until assertion passes when throughout and until_with assertion fails because until assertion is non overlapping form and it checks condition till one cycle before signal โcโ goes low.
18. Within:
Syntax:
sequence1 within sequence 2;
This means that seq1 happens within the start and completion of seq2. The starting matching point of seq2 must happen before the starting matching point of seq1. The ending matching point of seq1 must happen before the ending matching point of seq2.
Property within_p checks for
sequence 1 happens within the start and completion of sequence 2.
Snippet Pass Case:
Sequence 1: c [->2] ##1 d, it checks for the intermediate assertion of signal โcโ for the two clock cycles, in the following clock cycle signal โdโ to be asserted high.
Sequence 2: $fell(b) ##[5:10] $rose(b), it checks negedge to posedge of signal โbโ within latency of 5 to 10 clock cycles.
In the above snippet, the assertion triggers when the negative edge of signal โaโ is detected, and remains active due to signal โbโ changes to โ0โ. Sequence -1 gets completed at the time stamp 5090ns and sequence -2 gets completed at the time stamp 5122ns.
Assertion is finished at the time stamp 5122ns due to sequence 1 happened within the start and completion of sequence 2.
Snippet Fail case:
In the above snippet, assertion triggers when negative edge of signal โaโ is detected and remains active due to signal โbโ changes to โ0โ, assertion failed at the time stamp 4974ns as sequence 1 is not completed (signal โdโ is not asserted high) within the start and completion of sequence 2.
Summary
By using appropriate SVA syntaxes explained in this paper, Design Verification engineers can easily implement any complex checker in any SV-based design verification project. This is irrespective of the design protocol, complexity, and verification methodology adopted for the project. Such assertions really add value to catch the design bugs early in time without waiting for 100% development of other DV components.
Courtesy to:ย Design&Reuse.comย
Would you like to know more about system Verilog, get in touch:ย https://www.einfochips.com/contact-us/














