UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor julien-niu
Visitor
182 Views
Registered: ‎07-08-2019

Encounter an error when trying to call c function sin()

I try to use a c function sin() in testbench written in systemVerilog. However, when I start the simulation, it throws an error like this: "Vivado Simulator kernel has encounted an exception from DPI C function: cos(). Please correct."

Here is the relevant code:

package math_pkg;
  // import functions directly from C library
  //import dpi task      C Name = SV function name
  import "DPI-C" pure function real cos(input real rTheta);
  import "DPI-C" pure function real sin(input real y);
  import "DPI-C" pure function real atan2(input real y, input real x);
endpackage : math_pkg

 wr = math_pkg::cos(theta); 
 wi = math_pkg::sin(theta);

Does anyone know what else I need to setup in order to successfully use a built-in c library?

0 Kudos
1 Reply
Moderator
Moderator
161 Views
Registered: ‎04-24-2013

Re: Encounter an error when trying to call c function sin()

Hi @julien-niu ,

Have a look at Appendix D of User Guide 900, it has information on using DPI and compiling C Code.

https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_1/ug900-vivado-logic-simulation.pdf#G13.393986

At this time it only works via scripting and not via the GUI

You can generate scripts to modify by using the export_simulation tcl command.

Best Regards
Aidan

------------------------------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if this answered your question
Give Kudos to a post which you think is helpful and may help other users
------------------------------------------------------------------------------------------------------------------
0 Kudos