# Passing array size as argument for another array inside the task/function

**URL:** <https://verificationacademy.com/forums/t/passing-array-size-as-argument-for-another-array-inside-the-task-function/41855>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, parameter, systemverilog-Arrays-packedarrays-unpackedarrays, systemverilog-Arrays\
**Created:** [June 20, 2023, 4:23pm UTC](https://verificationacademy.com/forums/t/passing-array-size-as-argument-for-another-array-inside-the-task-function/41855 "2023-06-20T16:23:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [June 20, 2023, 4:36pm UTC](https://verificationacademy.com/forums/t/passing-array-size-as-argument-for-another-array-inside-the-task-function/41855/2 "2023-06-20T16:36:16Z")

</div>

_In reply to [gabi0307](https://verificationacademy.com/forums/t/passing-array-size-as-argument-for-another-array-inside-the-task-function/41855):_

Section 7.4.2 in the LRM states that dimensions for an unpacked array are required to be constant expressions. Using a variable violates this requirement.

You can use a dynamic array instead:

```verilog

parameter SIZE_1 = 27;
task task1(input int SIZE, input logic my_array1, input logic my_array2);
   automatic logic my_array3[] = new[SIZE-1];
   //rest of the code
endtask
 
task1(SIZE_1, array1, array2);

```

---

_[View the full topic](https://verificationacademy.com/forums/t/passing-array-size-as-argument-for-another-array-inside-the-task-function/41855)._
