在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 3618|回复: 2

[求助] SV DPI 新手求助

[复制链接]
发表于 2011-3-22 08:36:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
照着书写的程序, 编译通不过  请教哪里有问题?//file: test.sv
import "DPI" function int fact(input int i);

program automatic test;
  initial begin
    for(int i=1; i<=10; i++)
      $display("%0d! = %0d", i, fact(i));
  end
endprogram



//file: test.cpp
#include "svdpi.h"

int fact(int i){
  if(i<=1) return 1;
  else  return i*fact(i-1);
}



编译命令:
vcs -sverilog test.sv test.cc -CFLAGS "-I $VCS_HOME/linux/lib"

结果:
Parsing design file 'test.sv'
Top Level Modules:
       test
No TimeScale specified
Starting vcs inline pass...
2 modules and 0 UDP read.
recompiling module test
All of 3 modules done
g++ -w  -pipe -m32 -I /tool/cbar/apps/vcs/2009.12-3/linux/lib -O -I/tool/cbar/apps/vcs/2009.12-3/include    -c ../test.cpp
if [ -x ../simv ]; then chmod -x ../simv; fi
g++  -o ../simv -melf_i386 -m32   test.o  5NrI_d.o 5NrIB_d.o jAci_1_d.o Yrj5_1_d.o gzYz_1_d.o SIM_l.o    rmapats_mop.o rmapats.o    /tool/cbar/apps/vcs/2009.12-3/linux/lib/libvirsim.a /tool/cbar/apps/vcs/2009.12-3/linux/lib/librterrorinf.so /tool/cbar/apps/vcs/2009.12-3/linux/lib/libsnpsmalloc.so     /tool/cbar/apps/vcs/2009.12-3/linux/lib/libvcsnew.so     /tool/cbar/apps/vcs/2009.12-3/linux/lib/vcs_save_restore_new.o /tool/cbar/apps/vcs/2009.12-3/linux/lib/ctype-stubs_32.a -ldl  -lc -lm -lpthread -ldl
gzYz_1_d.o: In function `T_VCSgd_test_1_2_0':
(.text+0x12a): undefined reference to `fact'  -------------------------------------------------> look at here!!!!
collect2: ld returned 1 exit status
make: *** [product_timestamp] Error 1
Make exited with status 2
CPU time: .134 seconds to compile + .054 seconds to elab + .523 seconds to link
发表于 2012-3-23 19:02:59 | 显示全部楼层
正在学习中。。。。。。。。。。。。
发表于 2012-3-24 21:23:22 | 显示全部楼层
two options:
[1]chage c code file name from test.cpp to test.c
[2]change test.cpp
extern "C" {
  you code ...
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-21 14:35 , Processed in 0.018766 second(s), 10 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表