Passing a Multidimensional array from c to system verilog using DPI

Hi ,

I have a two dimensional array A[64][64] . i need to pass the value using system verilog DPI .
Can any one help me with an example.

Thanks
Senkadir

SystemVerilog file:

module top;
   typedef int MDA_t[64][64];

   import "DPI-C" function void MDAfromC(output MDA_t arg);

   initial begin
      MDA_t val;
      MDAfromC(val);
      foreach(val[i,j]) $display(i,,j,,val[i][j]);
   end
endmodule

C file:

#import "mda.h"
void MDAfromC(
	      int* arg
	      )
{
  int i,j,count=0;
  int Carray[5][5];
  for(i=0;i<5;i++)
    for(j=0;j<5;j++)
      Carray[i][j] = count++;
  memcpy(arg,Carray,sizeof(Carray));
}

Compile with:

vlib work
vlog mda.sv -dpiheader mda.h mda.c
vsim -c top -do “run -all;quit”

You can do this without memcpy(); I’m just rusty on my multidimensional pointer skills.