Hello,
I am trying to run the basic DPI example included in questasim 10.5c. The example is in QuestaSIM Tutorial and is called “Using the SystemVerilog DPI”.
In the documentation, the following commands to run the simulation are provided:
vlib work
vlog test.sv -dpiheader dpi_types.h
vopt +acc test -o opt_test
vsim -c test -dpiexportobj exports
gcc -I %QUESTA_HOME%\include -shared -g -o foreign.dll foreign.c exports.obj -lmtipli -L %QUESTA_HOME%\win32
vsim -i opt_test test -sv_lib foreign -do "add wave light; view source"
When I try to run this commands I see:
$ ./run.bat
C:\(...)\dpi_basic>vlib work
** Warning: (vlib-34) Library already exists at "work".
C:\(...)\dpi_basic>vlog test.sv -dpiheader dpi_types.h
QuestaSim-64 vlog 10.5c Compiler 2016.07 Jul 21 2016
Start time: 11:38:35 on Mar 11,2019
vlog test.sv -dpiheader dpi_types.h
-- Compiling module test
Top level modules:
test
End time: 11:38:36 on Mar 11,2019, Elapsed time: 0:00:01
Errors: 0, Warnings: 0
C:\(...)\dpi_basic>vopt +acc test -o opt_test
QuestaSim-64 vopt 10.5c Compiler 2016.07 Jul 21 2016
Start time: 11:38:36 on Mar 11,2019
vopt "+acc" test -o opt_test
Top level modules:
test
Analyzing design...
-- Loading module test
Incremental compilation check found no design-units have changed.
Optimized design name is opt_test
End time: 11:38:36 on Mar 11,2019, Elapsed time: 0:00:00
Errors: 0, Warnings: 0
C:\(...)\dpi_basic>vsim -c test -dpiexportobj exports
Reading C:/questasim64_10.5c/tcl/vsim/pref.tcl
# 10.5c
# vsim -c test -dpiexportobj exports
# Start time: 11:38:37 on Mar 11,2019
# Loading C:/(...)\win64_gcc-8.1.0\export_tramp.dll
# Refreshing C:/(...)/dpi_basic/work.test
# Loading sv_std.std
# Loading work.test
# Compiling C:/(...)\win64_gcc-8.1.0\exportwrapper.c
# Successfully generated DPI export object 'exports.obj'.
# End time: 11:38:41 on Mar 11,2019, Elapsed time: 0:00:04
# Errors: 0, Warnings: 0
C:\(...)\dpi_basic>gcc -I /c/questasim64_10.5c/include -shared -g -o foreign.dll foreign.c exports.obj -lmtipli -L /c/questasim64_10.5c/win64
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmtipli
collect2.exe: error: ld returned 1 exit status
C:\(...)\dpi_basic>vsim -i opt_test test -sv_lib foreign -do "add wave light; view source"
Reading C:/questasim64_10.5c/tcl/vsim/pref.tcl
quit
As it can be seen in the log, GCC complains about the “-lmtipli” argument. I have looked around the documentation and in google and all the information I can find about that argument is:
The -lmtipli option is used to specify a compiled library that is to be included when trying to resolve all the functions used in the C/C++ code being compiled. The -L option specifies a directory to search for libraries specified in the -l option.
I have been unable of finding more detail information on that argument… What is it trying to do exactly? I have looked at the GCC man page but I have not been able to match it to the options listed there…
If I remove that option and try again I see:
C:\(...)\dpi_basic>gcc -I /c/questasim64_10.5c/include -shared -g -o foreign.dll foreign.c exports.obj -lm -L /c/questasim64_10.5c/win64
exports.obj: In function `sv_RedLight':
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:46: undefined reference to `__imp_svGetScope'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:46: undefined reference to `mti_svFindTFHandleDetailsWithSig'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:52: undefined reference to `vl_trace_dpi_call'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:60: undefined reference to `mti_svExecuteTaskOrFunction'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:62: undefined reference to `mti_svCleanContext'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:64: undefined reference to `mti_set_numof_step_scdpi_stop'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:66: undefined reference to `vl_trace_dpi_call'
exports.obj: In function `sv_WaitForRed':
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:90: undefined reference to `__imp_svGetScope'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:90: undefined reference to `mti_svFindTFHandleDetailsWithSig'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:92: undefined reference to `__imp_svIsDisabledState'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:96: undefined reference to `vl_trace_dpi_call'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:104: undefined reference to `mti_svExecuteTaskOrFunction'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:106: undefined reference to `mti_svCleanContext'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:108: undefined reference to `mti_set_numof_step_scdpi_stop'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:110: undefined reference to `vl_trace_dpi_call'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:112: undefined reference to `vl_trace_dpi_call'
exports.obj: In function `sv_YellowLight':
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:136: undefined reference to `__imp_svGetScope'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:136: undefined reference to `mti_svFindTFHandleDetailsWithSig'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:142: undefined reference to `vl_trace_dpi_call'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:150: undefined reference to `mti_svExecuteTaskOrFunction'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:152: undefined reference to `mti_svCleanContext'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:154: undefined reference to `mti_set_numof_step_scdpi_stop'
C:/Users/(...)/win64_gcc-8.1.0/exportwrapper.c:156: undefined reference to `vl_trace_dpi_call'
collect2.exe: error: ld returned 1 exit status
Can anybody shine any light into this? It is an example included in the tutorial, so I would expect to be easy to get it going.