Hi,
Can we use an expression in consecutive repetition operator.
Originally the syntax is signal_name[*number];
but instead of number can i give an expression(gives the same number). I executed the below code but it shown error. If it is possible then give me a small sample code for understanding.
[*(len_array[start_id].pop_front)] is it valid or not?
module assertions;
int count[int];
bit [7:0] len_array[int][$];
If you look at the SV LRM Section 16.9.2 Repetition in sequences you’ll find that
— Consecutive repetition ( *[const_or_range_expression] ): Consecutive repetition specifies finitely many iterative matches of the operand sequence…
So your expression is not a constant or a range expression, based on this I’d say it is not allowed, but have you tried it out?
In reply to rgarcia07:
int var;
signal_name[*var] is illegal
Do this instead
int var=5;
// a[*var] replacement
properly p;
int v;
(b, v=var)|->
first_match((a, v=v-1'b1)[*0:$] ##1 v==0) ##1 c; // or ##0 c depends on requirements
endproperty
In reply to Siva91221:
If you look at the SV LRM Section 16.9.2 Repetition in sequences you’ll find that
— Consecutive repetition ( *[const_or_range_expression] ): Consecutive repetition specifies finitely many iterative matches of the operand sequence…
So your expression is not a constant or a range expression, based on this I’d say it is not allowed, but have you tried it out?
HTH,
-R
Hi,
I tried the above mentioned code but it shows that expressions are not allowed in consecutive repetition operator.
So, that’s why i’m asking how can we approach that scenario?