The size of the packed dimension, the unpacked dimension, or both dimensions can remain unspecified,such cases are referred to as open arrays (or unsized arrays). Open arrays allow the use of generic code to handle different sizes. Formal arguments in SystemVerilog can be specified as open arrays solely in import declarations, exported. SystemVerilog functions cannot have formal arguments specified as open arrays.
OpenArrays are good for generic programming, since C language doesn't have concept of parameterizable arguments. Standared query and library functions are provided to determine array information to acess array elements.
A packed array is represented as an array of one or more elements (of type svBitVecVal for 2-state values and svLogicVecVal for 4-state values), each element representing a group of 32 bits.
initial begin $display("\n Passing fxd_arr_1 to C \n");
pass_array( fxd_arr_1 );
$display("\n Passing fxd_arr_2 to C \n");
pass_array( fxd_arr_2 );
end
void pass_array(const svOpenArrayHandle dyn_arr ) {
printf("Array Pointer is %x \n", svGetArrayPtr(dyn_arr) );
printf(" Lower index %d \n", svLow(dyn_arr,1));
printf(" Higher index %d \n", svHigh(dyn_arr, 1) );
printf(" Left index %d \n", svLeft(dyn_arr,1), svRight(dyn_arr, 1) );
printf(" Right index %d \n", svRight(dyn_arr, 1) );
printf(" Length of array %d \n", svLength(dyn_arr,1) );
printf(" Incremental %d \n",svIncrement(dyn_arr,1));
printf("Dimentions of Array %d \n", svDimensions(dyn_arr ));
printf("Size of Array in bytes %d \n", svSizeOfArray(dyn_arr) );
}
RESULTS:
Passing fxd_arr_1 to C
Array Pointer is 80fdc58 Lower index 3 Higher index 8 Left index 8 Right index 3 Length of array 6 Incremental 1 Dimentions of Array 1 Size of Array in bytes 24
Passing fxd_arr_2 to C
Array Pointer is 80fdc70 Lower index 1 Higher index 13 Left index 1 Right index 13 Length of array 13 Incremental -1 Dimentions of Array 1 Size of Array in bytes 52