# Size() vs $size for constraining Unpacked Arrays

**URL:** <https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605>\
**Category:** SystemVerilog\
**Tags:** arraysize, sizearray, SystemVerilog, unpacked-array\
**Created:** [April 12, 2026, 6:49pm UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605 "2026-04-12T18:49:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TC\_2017](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/53a042/32.png) [@TC\_2017](https://verificationacademy.com/forums/u/TC_2017)\
**Post date:** [April 12, 2026, 6:49pm UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605/1 "2026-04-12T18:49:02Z")

</div>

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](https://www.edaplayground.com/x/JZQd))

[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

---

<div class="post-metadata">

**Author:** ![Tobias187](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@Tobias187](https://verificationacademy.com/forums/u/Tobias187)\
**Post date:** [April 13, 2026, 11:52am UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605/2 "2026-04-13T11:52:42Z")

</div>

`.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.

---

<div class="post-metadata">

**Author:** ![TC\_2017](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/53a042/32.png) [@TC\_2017](https://verificationacademy.com/forums/u/TC_2017)\
**Post date:** [April 13, 2026, 2:45pm UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605/3 "2026-04-13T14:45:02Z")

</div>

Hi @Tobias187 , 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 could be the reason behind 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

---

<div class="post-metadata">

**Author:** ![Tobias187](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@Tobias187](https://verificationacademy.com/forums/u/Tobias187)\
**Post date:** [April 14, 2026, 5:30am UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605/4 "2026-04-14T05:30:30Z")

</div>

Yeah. Refer IEEE Std 1800-2017 on section 20.7 “It is an error to use these functions directly on a dynamically sized type identifier”.

---

<div class="post-metadata">

**Author:** ![TC\_2017](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/53a042/32.png) [@TC\_2017](https://verificationacademy.com/forums/u/TC_2017)\
**Post date:** [April 14, 2026, 9:09am UTC](https://verificationacademy.com/forums/t/size-vs-size-for-constraining-unpacked-arrays/51605/5 "2026-04-14T09:09:13Z")

</div>

LRM-2013 Section 7.5.1 has an example

```verilog
integer addr[];

addr = new[100];

```

Section 7.5.2 further mentions

> The size dynamic array method is equivalent to $size( addr,1) array query function (see 20.7)

Where `addr` is a dynamic type identifier

**Hence I believe $size is legal for dynamic arrays**

Section 20.7 mentions

> When used on a dynamic array or queue dimension, these functions return information about the current state of the array.

**So this does confirm that $size is valid for queues and dynamic arrays.**

It further mentions

> It is an error to use these functions directly on a dynamically sized type identifier

The keyword here is **directly** ( However I am not clear on what it means here )

Furthermore LRM mentions that $size is legal for associative array dimensions with index type as integer
