Home > OS >  Systemverilog: is there a limit in size for a dynamic array?
Systemverilog: is there a limit in size for a dynamic array?

Time:10-26

When doing new[SIZE] to a dynamic array, is there a limit for the SIZE we can use in Systemverilog?

CodePudding user response:

The limit is very big.

IEEE Std 1800-2017, section 7.5.1 New[ ] states

[ expression ]:
The desired size of the dynamic array. The type of this operand is longint. 
It shall be an error if the value of this operand is negative. 

longint is 64-bit signed.

CodePudding user response:

The LRM section 7.4.2 Unpacked arrays says

Implementations may limit the maximum size of an array, but they shall allow at least 16 777 216 (224) elements.

But you might be limited more by time than space if you tried to access that many elements. An associative array might be a better choice for a large array if you only plan to access a small percentage of the address space.

  • Related