Hi, I found this Assertion code in slove complex assertion from verification academy.
code:
package sva_delay_repeat_pkg;
sequence dynamic_repeat(q_s, count);
int v=count;
(1, v=count) ##0 first_match((q_s, v=v-1’b1) [*1:] ##0 v<=0);
endsequence
sequence dynamic_delay(count);
int v;
(1, v=count) ##0 first_match((1, v=v-1'b1) [*0:] ##1 v<=0);
endsequence
endpackage
In the above code i did’nt understand how the (1,v=count) is working, can you please explain.
In reply to Amruthabmanigar:
Syntax 16-14—Variable assignment syntax of the LRM says:
sequence_expr ::= // from A.2.10
...
| ( sequence_expr {, sequence_match_item} ) [ sequence_abbrev ]
...
sequence_match_item ::=
operator_assignment
| inc_or_dec_expression
...
Variable ‘v’ in your code is a local variable which is dynamic in nature.
If one wants to initialize a local variable the LRM syntax above tells us that it needs to be associated with a sequence_expr. The local variable initialization is done only when the sequence matches.
In your code ‘1’ is the sequence_expression which means it will always match. As a result on each attempt of sequence dynamic_repeat , local variable ‘v’ is initialized with value of ‘count’ to the parameterized sequence.
In reply to MICRO_91:
Thank you the reply, it is helpful.