Could sv function return a Multidimensional Arrays

In reply to designer007:

SV function cannot return bare multidimensional array. You should typedef the array, then you can make use of it to return the array.
Please refer the below example for returning multidimensional array.


module top;
  typedef bit[7:0]data1;
  typedef data1 data2[4][6];
  
  function data2 func();
    bit[7:0]array[4][6];
    array[1][2]=5;    //randomly assigning some value
    $display("array is %p",array);
    return array;
  endfunction
  
  initial begin
    $display("data2 is %p",func());
  end
endmodule

Result:-

array is '{'{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h5, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}} 
data2 is '{'{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h5, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}, '{'h0, 'h0, 'h0, 'h0, 'h0, 'h0}}