Size() vs $size for constraining Unpacked Arrays

Hi All,

While trying to constraint an unpacked array random property of different type ( fixed / dynamic / queue ) I observe that 2 out of 3 tools don’t allow method size() for fixed type array (edalink)

[Q1] Is size() method legal for fixed unpacked arrays ?

[Q2] Inorder to constraint size of queue / dynamic array, is system function $size legal ?

As per LRM 7.5.2 ::

The size dynamic array method is equivalent to the $size(addr,1) array query system function

For dynamic arrays / queue, is it legal to constraint the size using $size instead of size method ?

Thanks in Advance

.size() method is not legal for fixed unpacked arrays. Fixed arrays have compile-time constant size, but this appears to be a tool-specific extension and not strictly defined by the LRM.

And even though LRM states that dynamic array .size() is equivalent to $size(array,1), in practice $size() is not reliably supported inside constraints as far as I have tried on many tools. I mean constraint solvers treat .size() as a property of the random array and can solve symbolically for the array length. $size() is considered a runtime query function which expects the array to already exist, so many tools do not allow it inside constraints. using $size() only the array elements can be randomized, not the array size.

For dynamic arrays and queues, it is recommended to use .size() for constraining the array length. $size() can still be used for dynamic types outside constraints (for example display/debug), including for fixed arrays.

Hi @Thobiyas , I am not clear on the first 2 lines of your comment.

As per my understanding .size() would be considered illegal for fixed unpacked arrays only if the LRM explicitly mentions it.

In my brief search I couldn’t find any such line ( I may have possibly missed if any such quote does exist in LRM )

Absence of such a quote would probably mean that each tool has it’s own implementation ( which is what we currently observe in above edalink )

Similarly although LRM mentions using size to constraint the size of dynamic array / queue ( Section 18.4 of LRM-2023 ), it doesn’t explicitly mention $size as illegal to constraint size of dynamic array / queue