Assertions Updated NewLec2-UNIT4
Assertions Updated NewLec2-UNIT4
Page 1 of 2 Copyright 2010., Kacper Technologies Pvt Ltd. All Rights Reserved
WHAT IS ASSERTION?
EXAMPLES:
• Immediate Assertions
• Concurrent Assertions
Immediate Assertions:
• These are event driven and procedural in nature
• Mainly used in simulation block
• Based on clock cycles
• Evaluated in Observed region
Immediate Assertions
An assertion is basically a statement that something must be true,
similar to if statement. Expression is non temporal.
If an expression is not true and it does not have an associated else part,
verification tools automatically register that as an error.
Concurrent Assertions
Immediate assertion describes a logic behaviour at an instant of time, where a
concurrent assertion detects a behaviour over time to be specified.
The variables used in a concurrent assertion are sampled in the Preponed region of
a time slot and the assertions are evaluated during the Observe region. Both these
regions occur immediately before a clock edge.
Sequence Expressions
Define formal arguments in a sequence definition and re-use the same sequence
for other signals in design that have similar behavior.
• For example,
Concurrent Assertions cont...
Sequence Expressions (Cont..)
Sequences of Boolean expressions can be described with a specified time step in-
between.
Consider the following example at pose edge of clock ‘a’ should be high, after
two clock cycles ‘b’ should be high, after four clock cycles ‘c’ should be high and
‘z’ should be high with in one to five clock cycles.
Concurrent
Concurrent Assertions
Assertions cont...
(Cont..)
Sequence
Sequence Replication operators:
with logical relationship
Consecutive Repetition Operator [* ]
• To specify that a signal or a sequence will match continuously for the
number of specified clocks.
• A hidden delay of one clock cycle is assumed between each match of the
signal.
• Syntax: signal or sequence [* n]
• "n" is the number of times the expression should match repeatedly.
a ##2 b [*5] ##6 c a ##2 b ##1 b ##1 b ##1 b ##1 b ##6 c
s1 [*4] s1##1 s1##1 s1 ## 1 s1
(s1 ##1 s2) [*3] (s1 ##1 s2) ##1 (s1 ##1 s2) ##1 (s1 ##1 s2)
a [*3] a ##1 a ##1 a
s1[*2:$] means s1 occurs at least 2 times
Concurrent Assertions cont...
Sequence Replication operators Cont..
Goto Repetition Operator [-> ]
• This operator specify that an expression will match the number of times
specified not necessarily on continuous clock cycles.
• Syntax: signal [->]
y [->4] The Boolean expression y has been true 4 times, but not
necessarily on successive clocks
x [->4:7] x has been true 4, 5, 6 or 7 times, not necessarily on
consecutive clocks
x ##3 y [->3] ##6 z The Boolean expression y has been true thrice, not
necessarily on consecutive clocks, 1st occurrence of y
happens after 3 clocks cycles of x. The last one occurs 6
clock cycles before z.
Concurrent Assertions cont...
Sequence Match Operators
The "and" construct
• The binary operator "and" can be used to combine two sequences logically.
The final property succeeds when both the sequences succeed.
• The result of and operation is a match, if
• Both sequences must start at the same time.
• Sequences may end at different times.
• The end time of the match i.e. when the match is recognized is the end
time of the longer sequence.
A t1 t7
A,B Match at t7
B t1 t5
CLK
Concurrent Assertions cont...
Sequence Match Operators (Cont..)
The OR operator
• The binary operator "or" can be used to combine two sequences logically.
• The final property succeeds when any one of the sequence succeeds.
• The sequence B matches (or, it ends) at time t7. The sequence A matches
at time t5. So the sequence A or B has a match at times t5 and t7.
B t1 t7
CLK
Concurrent Assertions cont...
Property:
Number of sequences can be combined logically or sequentially to
create more complex sequences. SVA provides a key word to
represent these complex sequential behaviors called "property."
The basic syntax of a property is as follows.
Concurrent Assertions cont...
Assert Property:
The property is the one that is verified during a simulation. It has
to be asserted to take effect during a simulation.
SVA provides a key word called "assert" to check the property.
Assert statements produce results that are visible externally.
The basic syntax of an assert is as follows.
Concurrent Assertions cont...
Assert property (cont..)
An assert either succeeds, fails or remain incomplete.
A property can also be forbidden from happening. We expect the property
to be false always. If the property is true, the assertion fails.
Overlapping:
• If enable is high at posedge of clock write should be high at same
positive edge of clock and read must be high 2 clock cycles later.
Implication operators (Cont..)
Non-Overlapping :
Property prp1 has a signal in the antecedent position. If signal "a" and signal "b" are
detected to be high, then two clock cycle later, signal "c" should be high. Sequence seqb
checks that, After 1 clock cycles from the current positive edge of the clock, signal "d”
should be low.
The final property checks that, if sequence seqa succeeds, then a check for sequence
seqb is performed.
Clock definitions in SVA
A clock can be specified in a sequence, in a property or even in an assert statement.
Clock in Assert
Assertion System Functions
SystemVerilog provides a number of system functions, which can be used in
assertions.
$rose, $fell and $stable indicate whether or not the value of an expression has
changed between two adjacent clock ticks.
For example,
• Asserts that if in changes from 0 to 1 between one rising clock and the next,
detect must be 1 on the following clock.
The system functions $onehot and $onehot0 are used for checking one-hot
encoded signals. $onehot(expr) returns true if exactly one bit of expr is high;
$onehot0(expr) returns true if at most one bit of expr is high.
Summary