SystemVerilog Assertion
Part 2: Sequence  An Introduction
Prev: Sequence and Clock 
Next: Sequence Match Operators
Sequence Repetition Operators
A sequence repetition operator indicates that the sequence occurs a
number of times. The number of times the sequence repeats is always
a nonnegative number (i.e. zero or positive number) and can be
specified either as a fixed number or a range. If it is a range, then
the maximum limit of the range can also be specified as '$', which
indicates a finite but unbounded maximum.
There are three types of repetition operators.
 Consecutive Repetition Operator [* ]
 Goto Repetition Operator [> ]
 Nonconsecutive Repetition Operator [= ]
The last two of these operators actually work on boolean expressions
rather than on sequences. Next sections describe these repetition
operators.
Consecutive Repetition Operator [* ]
The consecutive repetition operator applied to a sequence indicates
that the sequence repeates itself a specified number of times with
one clock cycle of delay between two repetitions. For example,
s1 ##2 s2 [*4] ##5 s3
is same as
s1 ##2 (s2 ##1 s2 ##1 s2 ##1 s2) ##5 s3
or, simply,
s1 ##2 s2 ##1 s2 ##1 s2 ##1 s2 ##5 s3
Note that the repetition operation ([*4]) is on s2, but not on the
delay ##2 that preceeds it.
Empty Sequence [*0]
A repetition of 0 times indicates that the resultant sequence is empty.
So if s1 is a sequence, s1 [*0] does not match any event(s)
regardless of what s1 is.
An empty sequence can be used in a sequence operation with the following
rules. Here e is an empty sequence and s is not.
 Neither (e ##0 s) nor (s ##0 e) matches any sequence.
 (e ##n s) is equivalent to (##(n1) s), if n > 0
 (s ##n e) is equivalent to (s ##(n1) `true), if n > 0
Repetition with a Range
A range specified for a repetition simply menas that the match may be for
any of the combinations of the repetition. Thus, a range of s1 given as
s1 [*2:3]
is equivalent to
s1 ##1 s1 // two times of s1
or s1 ##1 s1 ##1 s1 // or three times of s1
A range repetition is applicable to a chain of sequences (or events) as well.
(s1 ##5 s2) [*2:3]
is equivalent to
(s1 ##5 s2) ##1 (s1 ##5 s2) // two times of (s1 #5 s2)
or (s1 ##5 s2) ##1 (s1 ##5 s2) ##1 (s1 ##5 s2) // or three times of (s1 #5 s2)
Lastly, an upper bound of '$' in a range indicates the sequence repeats
at least the number of times specified by the lower bound. So,
s1[*2:$] means s1 occurs at least 2 times. As another
example, s0 ##3 s1[*2:$] ##2 s2 indicates that s0 occurs
first followed by at least 2 occurances of s1 after 3 clock
cycles and then s2 occurs 2 clock cycles after the last s1
finishes.
Goto Repetition Operator [> ]
The Goto is a 'nonconsecutive exact repetition' operator for boolean
expression, meaning it checks if a boolean expression has been true
for specified number of times but not necessarily on consecutive
clock cycles. The sequence starts with the first occurance of the
boolean expression and ends with the last one (i.e. there is no gap
before the first one and after the last one). The following are few
cases of using the Goto operator.
 b [>3]: The boolean expression b has been true thrice,
but not necessarily on successive clocks.
 b [>3:5]: Here, b has been true 3, 4 or 5 times, once
again not necessarily on consecutive clocks.
 a ##2 b [>3] ##4 c: The boolean expression b has been
true thrice, but not necessarily on successive clocks. The first occurance
of b happens after two clocks cycles of a. The last one occurs
four clock cycles before c.
Nonconsecutive Repetition Operator [= ]
The nonconsecutive exact repetition operator is also for boolean expression
and is very similar to the goto repetition operator. When the goto repetition
operation ends with the last true value of the operand, the nonconsecutive
repetition operation may extend beyond such last true value. An example will
clarify this.
 b [=3]: The boolean expression b has been true thrice,
but not necessarily on successive clocks and there may be additional clock
cycles after the last true b before the sequence completes.
 b [=3:5]: Here, b has been true 3, 4 or 5 times, once
again not necessarily on consecutive clocks, and with possible additional
clocks afterwords when b is not true.
 a ##2 b [=3] ##4 c: The boolean expression b has been
true thrice, but not necessarily on successive clocks. The first occurance
of b happens after two clocks cycles of a. The last one occurs at
least four clock cycles before c.
Can You?
The new intern Smart Assert can not write simple assertions. He wrote:
((!b[*0:$] ##1 b) [*3:5])
While the assertion works correctly, can you help him write it in a
simplified form?
We wrap up our Part 2 of this series on SystemVerilog Assertion with this.
In Part 3, we will look into other types of sequence operation and how they
make building sequences easier for you.
Prev: Sequence and Clock 
Next: Sequence Match Operators
