Is there a way in SystemVerilog to create a dynamic array that allocates its memory contiguously? I'm trying to read in data from a file into a dynamic array. The problem appears to be that the dynamic array is not in contiguous memory locations, so the file is not read properly into the array.
When I declare the variable reading the file as a non-dynamic array it works fine, so I assume the problem is contiguous memory. Here's the code:
This works fine, but does not use a dynamic array:
// Reads frame from a binary file
task t_Read_File(input string i_File_Name);
int n_Temp[10][10];
int n_File_ID;
n_File_ID = $fopen(i_File_Name, "rb");
$fread(n_Temp, n_File_ID);
$fclose(n_File_ID);
r_Frame = n_Temp;
endtask : t_Read_File
This uses a dynamic array (r_Frame) but does not work
// Reads frame from a binary file
task t_Read_File(input string i_File_Name);
int n_File_ID;
n_File_ID = $fopen(i_File_Name, "rb");
$fread(r_Frame, n_File_ID);
$fclose(n_File_ID);
endtask : t_Read_File
FYI, r_Frame is declared previously as a local variable to my class as follows:
int r_Frame[][];