求助questasim跑sv DPI tutorial时遇到的错误
错误信息如下:
{
# vsim -dpiexportobj exports -c opt_test
# Loading sv_std.std
# Loading work.test(fast)
# Compiling D:\questa_test\dpi_test\work\_dpi\win32_cl-12.0.8168\exportwrapper.c
# ** Fatal: (vsim-3827) Could not compile generated DPI-C exportwrapper C code: cmd = 'D:\Program Files\Microsoft VisualStudio\VC98\bin\cl.exe/c /O2 /I. /I"D:\questasim_6.4\include"/Fo"exports.obj""D:\questa_test\dpi_test\work\_dpi\win32_cl-12.0.8168\exportwrapper.c"'
# (vsim-50) A call to system(D:\Program Files\Microsoft VisualStudio\VC98\bin\cl.exe/c /O2 /I. /I"D:\questasim_6.4\include"/Fo"exports.obj""D:\questa_test\dpi_test\work\_dpi\win32_cl-12.0.8168\exportwrapper.c" returned error code '2'.
# The logfile contains the following messages:
# Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
# Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
#
# exportwrapper.c
# D:\questasim_6.4\include\stddef.h(6) : fatal error C1021: invalid preprocessor command 'include_next'
#
# No such file or directory. (errno = ENOENT)
#
#Time: 0 nsIteration: 0Instance: /test File: test.sv
# FATAL ERROR while loading design
}
哪位高手帮忙指点迷津啊……
哪个例子啊
是不是编译器路径问题
To: whxqq
就是红绿灯的那个例子,就两个文件,一个是foreign.c和test.sv文件
代码内容如下:
//foreign.c
#include "dpi_types.h"
int c_CarWaiting()
{
printf("There's a car waiting on the other side. \n");
printf("Initiate change sequence ...\n");
sv_YellowLight();
sv_WaitForRed();
sv_RedLight();
return 0;
}
//test.sv
module test ();
typedef enum {RED, GREEN, YELLOW} traffic_signal;
traffic_signal light;
function void sv_GreenLight ();
begin
light = GREEN;
end
endfunction
function void sv_YellowLight ();
begin
light = YELLOW;
end
endfunction
function void sv_RedLight ();
begin
light = RED;
end
endfunction
task sv_WaitForRed ();
begin
#10;
end
endtask
export "DPI-C" function sv_YellowLight;
export "DPI-C" function sv_RedLight;
export "DPI-C" task sv_WaitForRed;
import "DPI-C" context task c_CarWaiting ();
initial
begin
#10 sv_GreenLight;
#10 c_CarWaiting;
#10 sv_GreenLight;
end
endmodule
其实代码内容很简单,关键在运行批处理文件时其中的一条命令出错,全部的批处理命令如下:
//windows.bat
vlib work//1
vlog test.sv -dpiheader dpi_types.h//2
vopt +acc test -o opt_test//3
vsim -c opt_test -dpiexportobj exports//4
gcc -I %MTI_HOME%\include -shared -g -o foreign.dll foreign.c exports.obj -lmtipli -L %MTI_HOME%\win32//5
vsim -i opt_test -sv_lib foreign -do "add wave light; view source"//6
在运行第四条命令爆出帖子里描述的错误,我也怀疑是不是我的visaul studio 2003那边调用出了错,因为报错的路径指向那里,但是我怎么知道什么错误呢?怎么解决,求了解这方面的大侠帮忙分析一下,万分感激!
问题解决了,原因是环境变量设置有问题,囧
我今天遇到了和你同样的问题,不知道是不是太晚了,你不会看本帖了。
你说的环境变量设置错误,是指什么?是visaul studio 2003吗?
我想问,modelsim是怎么调用visaul studio 2003编译c代码的?需要什么设置吗?
-dpiheader 和 -dpiexportobj选项是什么意思?我没有查到,谢谢!期待你的答复 4# lee_267
建议小编把环境设置的修改贴出来共享一下。
-dpiheader 和-dpiexportobj的区别是,前者指示vlog命令生成.h文件,后者是提示vsim命令生成.obj文件,我的理解是这样的。
环境变量的设置是指,gcc-mingw32编译器的环境变量,要放在visual studio编译器环境变量的后面,具体原因我现在也忘了为什么要这么做,有知道的可以补充哈。就这些。
thank you teach me about it.
In my understanding,gcc-mingw32 will tell visaul studio 2003 to generate 32-bit version .so.
9# dpivpipli
the gcc and vs are two different compiler , how can gcc tell vs to generate 32-bit version ,btw , all thesesoftware work under Windows platform , which uses DLL file to link the DPI interface function, not .so file . is that right? thank you .
我也有这个问题。
正在看dpi的实例,学习下
好复杂啊
我是来赚分的
great doc
good job !