sami154
Newbie
Hello Everyone,
I am learning System Verilog DPI. I am trying to export a function written in System Verilog and trying to call it from C. However, I am facing the problem on how to export the function and how to call it from C. Below is the code I wrote in System Verilog. Can you please give me a sample code in "C" that call the below function, passes the arguments and get the result? A sample code can help me to understand my mistakes and understand the process clearly. Thank you in advance for your help.
I am learning System Verilog DPI. I am trying to export a function written in System Verilog and trying to call it from C. However, I am facing the problem on how to export the function and how to call it from C. Below is the code I wrote in System Verilog. Can you please give me a sample code in "C" that call the below function, passes the arguments and get the result? A sample code can help me to understand my mistakes and understand the process clearly. Thank you in advance for your help.
Code:
//System Verilog DPI
module tb_add;
export "DPI-C" function addFromSV;
function logic [7:0] addFromSV (input logic [7:0] in1, input logic [7:0] in2);
logic [7:0] out1;
out1 = in1 + in2;
return out1;
endfunction
endmodule
Last edited by a moderator: