SVA Sequences II – Repetition Operators

There are three different kinds of repetition operators available in SVA viz., consecutive, non-consecutive and goto. For all three operators the number of iterations can be either specified by an exact count or by a finite range. If the number of repetitions is specified by an exact count [*n], then ‘n’ has to be a non-negative integer constant expression.

Sequence repetition syntax

sequence_expr ::= 
...
| expression_or_dist [ boolean_abbrev ]
| sequence_instance [ sequence_abbrev ]
| ( sequence_expr {, sequence_match_item} ) [ sequence_abbrev ]
...
boolean_abbrev ::=
consecutive_repetition
| non_consecutive_repetition
| goto_repetition
sequence_abbrev ::= consecutive_repetition
consecutive_repetition ::=
[* const_or_range_expression ]
| [*]
| [+]
non_consecutive_repetition ::= [= const_or_range_expression ]
goto_repetition ::= [-> const_or_range_expression ]
const_or_range_expression ::=
constant_expression
| cycle_delay_const_range_expression
cycle_delay_const_range_expression ::=
constant_expression : constant_expression
| constant_expression : $

Consecutive repetition operator [*const_or_range_expression]

Consecutive repetition specifies finitely, many iterative matches of the operand sequence with a delay of one clock tick from the end of one match to the beginning of the next. The overall repetition sequence matches at the end of the last iterative match of the operand.

sequence seq1;
  sig1[*4];   // equivalent to: sig1 ##1 sig1 ##1 sig1 ##1 sig1
endsequence: seq1

A consecutive repetition specifies that the operand sequence shall match a specified number of times. In the above example, consecutive repetition operator [*4] specifies that the operand sequence must match 4 times in succession.

consecutive repetition operation with finite range:
(x ##3 y)[*1:3]
This means 
 (x ##3 y)  or 
 ((x ##3 y) ##1 (x ##3 y)) or 
 ((x ##3 y) ##1 (x ##3 y) ##1 (x ##3 y))

empty sequence

If 0 is used as repetition number, the sequence will be empty. An empty sequence is one that matches over zero clock ticks and does not match over any positive number of clock ticks.

x ##2 y[*0:1]  is equivalent to 
x or (x ##1 y)

Non-consecutive repetition operator [=const_or_range_expression]

Non-consecutive repetition specifies finitely, many iterative matches of the operand Boolean expression. There is a delay of one or more clock ticks from one match of the operand to the next successive match and no match of the operand strictly in between.

The overall repetition sequence matches at or after the last iterative match of the operand, but before any later match of the operand.

sequence seq1
  x ##2 y [=3:10] ##1 z
endseuquence

If x is true in the first clock tick and z in the last clock tick, then there are at least 3 and at most 10 non-consecutive clock ticks in between x and z.

Goto repetition operator [->const_or_range_expression]

Goto repetition specifies finitely, many iterative matches of the operand Boolean expression. There is a delay of one or more clock ticks from one match of the operand to the next successive match and no match of the operand strictly in between.

The overall repetition sequence matches at the last iterative match of the operand. The goto repetition takes a Boolean expression rather than a sequence as operand.

Consecutive repetition operator

$rose(rdy) ##1 rd_en[*4]##1intr_en

seq_rep1

Non-consecutive repetition operator

$rose(rdy) ##1 rd_en[=4]##1intr_en

seq_rep2

Goto repetition operator

$rose(rdy) ##1 rd_en[->4]##1intr_en

seq_rep3

Legend
seq_rep4

The non-consecutive repetition is like the goto repetition except that a match does not have to end at the last iterative match of the operand Boolean expression.

Note: [*] is an equivalent representation of [*0:$] and [+] is an equivalent representation of [*1:$].

The consecutive repetition operator can be applied to general sequence expressions, but the goto repetition and non-consecutive repetition operators can be applied only to Boolean expressions.

Other operator types are discussed in the next article in the series.

5 comments on “SVA Sequences II – Repetition Operators

  1. ab

    sequence seq1
    x ##2 y [=3:10] ##1 z
    endseuquence

    If x is true in the first clock tick and z in the last clock tick, then there are at least 3 and at most 10 non-consecutive clock ticks in between x and z.


    I think above statement is not correct, it should be

    If x is true in the first clock tick and z in the last clock tick, then there are at least 5 and at most 12 non-consecutive clock ticks in between x and z.

    Reply
  2. Mounika

    Thank you very much for the informative article. I have a doubt.Why go-to and non-consecutive repetition operators can’t be used with general sequential expressions?

    Reply
    1. Sini Balakrishnan Post author

      Hi Mounika

      As per System Verilog Language Reference Manual (LRM), goto and non-consecutive repetition operators work on only with Boolean expression and and not with sequential expression.
      Do you see any requirement for using these with sequential expression ?

      Supporting these two operators with sequential expression leads to lots of complexity issues in the EDA tool. This could be the reason for excluding these with sequential expression.
      Thanks
      Sini

      Reply

Leave a Reply to Sini Balakrishnan Cancel reply

Your email address will not be published. Required fields are marked *