Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help on exporting system Verilog function to C using DPI

Status
Not open for further replies.

sami154

Newbie
Newbie level 4
Joined
Dec 10, 2015
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
44
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.

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:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top