Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16886 Discussions

Linking fftw3 lib into SystemVerilog Simulation with DPI-C

AlexBeasley
New Contributor I
1,897 Views

Hi there, 

 

I am trying to run a simulation that makes use of the DPI-C interface so I can compare the FPGA output with the same function being performed in C. 

 

For this I need to compile in the FFTW3 libraries for my C code.

Below are some examples of the code and compilation set up 

 

C Code includes

 

 

#include "./fftw3.h"
#include "svdpi.h"
#include "svdpi_src.h"

 

 

SV code imports 

 

import "DPI-C" task fft2d();

 

 

Compilation and vsim set up 

 

 

vlog -dpiheader dpi_header.h C:/Data/fpga/DPI_C/fourier_fftw.c

# compile toucan testbench
vlog -reportprogress 300 -work work +acc C:/Data/fpga/Testbenches/Toucan_tb.sv

# #
# # Set the top-level simulation or testbench module/entity name, which is
# # used by the elab command to elaborate the top level.
# #
set TOP_LEVEL_NAME Toucan_tb
# #
# # Set any elaboration options you require.
set USER_DEFINED_ELAB_OPTIONS {-c -ldflags "-llibfftw3-3" -ldflags  "-llibfftw3f-3" -ldflags "-llibfftw3l-3" -64}
# #
# # Call command to elaborate your design and testbench.
elab
# #

 

 

However, every time I try to run the simulation I get the following fatal error: 

 

# ** Fatal: (vsim-3828) Could not link 'vsim_auto_compile.dll': cmd = 'C:/intelFPGA_pro/21.3/questa_fse\gcc-7.4.0-mingw64vc15\bin\gcc.exe -shared -o "C:/Users/ALEXBE~1/AppData/Local/Temp\AlexBeasley@ALEXVIVIDQLAPTO_dpi_34940\win64_gcc-7.4.0\vsim_auto_compile.dll" C:/Data/fpga/Sim/Toucan/libraries/work\_dpi\auto_compile@\win64_gcc-7.4.0\fourier_fftw.o   -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3 -Wl,-Bsymbolic  -L"C:/intelFPGA_pro/21.3/questa_fse/win64" -lmtipli'
# (vsim-50) A call to system(C:/intelFPGA_pro/21.3/questa_fse\gcc-7.4.0-mingw64vc15\bin\gcc.exe -shared -o "C:/Users/ALEXBE~1/AppData/Local/Temp\AlexBeasley@ALEXVIVIDQLAPTO_dpi_34940\win64_gcc-7.4.0\vsim_auto_compile.dll" C:/Data/fpga/Sim/Toucan/libraries/work\_dpi\auto_compile@\win64_gcc-7.4.0\fourier_fftw.o   -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3 -Wl,-Bsymbolic  -L"C:/intelFPGA_pro/21.3/questa_fse/win64" -lmtipli) returned error code '1'.
# No such file or directory. (errno = ENOENT)
# 
# 
# FATAL ERROR while loading design
# Error loading design
# Error: Error loading design
#        Pausing macro execution
# MACRO ./compile_toucan.do PAUSED at line 99

 

 

I cannot work out where I am going wrong or what file is being referred to by the "No such file or directory. (errno = ENOENT)" line. 

 

The fftw3 files were downloaded directly from the FFTW website as a set of pre-compiled dlls for windows. The lib files were then generated using the lib.exe function within Visual Studio.

 

Any ideas?

Thanks

0 Kudos
1 Solution
AlexBeasley
New Contributor I
1,847 Views

Hi there, 

 

I worked it out; because the .lib files were in a directory that was not being searched automatically I had to add -L<lib_directory> into the  -ldflags command. i.e.: 

 

vsim -c -ldflags "-L./ -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3" -64 work.fftw3_tb

This now works. 

 

Cheers 

Alex  

View solution in original post

0 Kudos
6 Replies
ShengN_Intel
Employee
1,879 Views

Hi,


You need to pass your library to 64 bit. For example like this:

vsim -c -ldflags "-l<library>" -64


Best regards,

Sheng

p/s: If any answer from community or Intel support are helpful, please feel free to mark as solution and give Kudos.


0 Kudos
AlexBeasley
New Contributor I
1,871 Views

Hi there, 

 

Thanks for getting back to me. 

I have tried passing in the -64 flag with the -ldflags command using the following commands:  

vlog -dpiheader myheader.h fourier_fftw.c fftw3_tb.sv

vsim -c -ldflags "-llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3" -64 work.fftw3_tb

 

But I still get the following error in the output: 

# vsim -c -ldflags "-llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3" -64 work.fftw3_tb 
# Start time: 09:00:33 on Jul 20,2022
# ** Note: (vsim-3812) Design is being optimized...
# Loading sv_std.std
# Loading work.fftw3_tb(fast)
# ** Fatal: (vsim-3828) Could not link 'vsim_auto_compile.dll': cmd = 'C:/intelFPGA_pro/21.3/questa_fse\gcc-7.4.0-mingw64vc15\bin\gcc.exe -shared -o "C:/Users/ALEXBE~1/AppData/Local/Temp\AlexBeasley@ALEXVIVIDQLAPTO_dpi_23316\win64_gcc-7.4.0\vsim_auto_compile.dll" c:/Data/fpga/sim/fftw3_example/work\_dpi\auto_compile@\win64_gcc-7.4.0\fourier_fftw.o   -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3 -Wl,-Bsymbolic  -L"C:/intelFPGA_pro/21.3/questa_fse/win64" -lmtipli'
# (vsim-50) A call to system(C:/intelFPGA_pro/21.3/questa_fse\gcc-7.4.0-mingw64vc15\bin\gcc.exe -shared -o "C:/Users/ALEXBE~1/AppData/Local/Temp\AlexBeasley@ALEXVIVIDQLAPTO_dpi_23316\win64_gcc-7.4.0\vsim_auto_compile.dll" c:/Data/fpga/sim/fftw3_example/work\_dpi\auto_compile@\win64_gcc-7.4.0\fourier_fftw.o   -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3 -Wl,-Bsymbolic  -L"C:/intelFPGA_pro/21.3/questa_fse/win64" -lmtipli) returned error code '1'.
# No such file or directory. (errno = ENOENT)
# 
# 
# FATAL ERROR while loading design
# Error loading design
# Error: Error loading design
#        Pausing macro execution

 

I don't know if it is looking for the libfftw3 libraries in a certain location? Currently they are in the working directory of QuestaSim. 

I have attached the example I am using to try and get this working. There is a "compile.do" file which has my commands in to compile the source files and run the simulation. 

 

Any ideas? 

Alex 

 

 

0 Kudos
ShengN_Intel
Employee
1,864 Views

I think not need to flag those libraries. Questa can run the simulation without flagging those libraries.


0 Kudos
ShengN_Intel
Employee
1,852 Views

Any further update or concern? Do you able to run the simulation?


0 Kudos
AlexBeasley
New Contributor I
1,848 Views

Hi there, 

 

I worked it out; because the .lib files were in a directory that was not being searched automatically I had to add -L<lib_directory> into the  -ldflags command. i.e.: 

 

vsim -c -ldflags "-L./ -llibfftw3-3 -llibfftw3f-3 -llibfftw3l-3" -64 work.fftw3_tb

This now works. 

 

Cheers 

Alex  

0 Kudos
ShengN_Intel
Employee
1,826 Views

Thanks for the sharing.

Btw, I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread. Thank you.


0 Kudos
Reply