Hi,
I am trying to understand how to pass an fix-size array from C side to SV side, why it only works on VCS, not NC?
Is a tool issue or bug in the code?
SV code:
module tb;
int buffer[2];
import "DPI-C" function void slave_write(input int addr, input int data, int buffer[2]);
export "DPI-C" function write;
function void write_test(int addr, int data, output int buffer[2]);
//Call C function
$display("before-buffer[2]:%p",buffer);
slave_write(addr, data, buffer);
$display("after-buffer[2]:%p",buffer);
endfunction
function void write(input int buff[2]);
//export the array from C to SV
buffer = buff;
$display("output buffer[2]:%p",buffer);
endfunction
initial begin
write_test(8'h30, 8'hff, buffer);
$display("%p\n",buffer);
end
endmodule
C code:
extern void write(int *buffer); // Imported from SystemVerilog
void slave_write(int I1, int I2, int *buff) {
buff[0] = I1;
buff[1] = I2;
write(buff);
printf("after write call\n");
}