Linking fftw3 lib into SystemVerilog Simulation with DPI-C
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
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_tbThis now works.
Cheers
Alex