I know that I can pass unknown size of packed array to function and change the array by inout.
For example:
The function is:
function void foo_arr_bit (inout bit [31:0] mem, input int size, string mem_name);
for (int i=0; i< size(); i++)
mem[i] = my_randomize_int(mem[i], mem_name);
endfunction: foo_arr_bit
Call the function:
foo_arr_bit (data_bit, 8, "data_bit");
But can I pass unknown size of unpacked array of packed array to a function?
I tried the following:
function void foo_arr_bit (int seed, inout bit [31:0] q [$], input string mem_name, int arr_size, const ref int vec_bit_siz);
for (int i=0; i< size(); i++)
mem[i] = my_randomize_int(mem[i], mem_name);
endfunction: foo_arr_bit
Call the function:
foo_arr_bit (seed, arr_vec_bit, "arr_vec_bit", t_data_bit, 9, arr_vec_b_size);
Where:
bit [9:0] arr_vec_bit [$];
int arr_vec_b_size = 10;
And got the following error:
** Error (suppressible): (vlog-7034) …\sv\trx.sv(31): Array assignment to type ‘bit[31:0] []’ from type ‘bit[9:0] []’: Ar
. ‘q’ of ‘my_randomize_array_vec_bit’: Element widths (32, 10) don’t match
Where line 32 is the function call.