宁安找小姐小妹包夜上门服务 ... https://blog.eetop.cn/116762 [收藏] [复制] [分享] [RSS] 【微信:99093588】宁安找小姐上门服务【微信:99093588】宁安找小姐保健按摩服务【微信:99093588】《宁安小姐服务电话》【微信:99093588】《宁安 ...

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

cosim/DPI/gcc

已有 2050 次阅读| 2012-6-21 20:51 |个人分类:verilog/systemverilog

今天早上复习了DPI,发现cadence的sysverilog.pdf上gcc编译c语言少了个选项

今天又重新拾起cosim,却发现怎么编译都报错,找了之前的ppt,又仔细观摩了NCsystemverilog.pdf,就是不行,老是报这个错误:

icds:liawang@shaltc01:[~/nc_prj/nc_dpi_first]> ncsim -sv_lib hello hello

ncsim: 09.20-s016: (c) Copyright 1995-2010 Cadence Design Systems, Inc.

ncsim: *W,NOLDPI: Unable to load hello.

OSDLERROR: ./hello.so: cannot open shared object file: No such file or directory or file is not valid ELFCLASS32 library..

ncsim: *F,NOFDPI: Function pass_string_c not found in any of the shared object specified with -SV_LIB switch.

我简直头大,一切都是按照Cadencesysverilog.pdf来的啊,怎么就能出错呢??

ncvlog -sv hello.sv

ncelab -access +RWC hello

gcc -fPIC -shared -o libdpi.so hello.c -I /tools/ius-9.20.016/tools/inca/include

ncsim -messages hello

显然是c语言文件生成的so文件没有被ncsim正确load,那么问题出在哪儿呢?问题大概出现在gcc的编译选项上。后来看了之前自己的笔记,发现这个gcc的编译选项漏了-m32,加上以后真的就好了!!

icds:liawang@shaltc01:[~/nc_prj/nc_dpi_first]> ncsim -sv_lib hello hello

ncsim: 09.20-s016: (c) Copyright 1995-2010 Cadence Design Systems, Inc.

ncsim> run

DPI: pass it ON

Exported Verilog String=
string passed from C

Verilog: C: give up a string

Gimme String

Simulation complete via $finish(1) at time 0 FS + 0

./hello.sv:22
$finish;

ncsim> exit

下面两个文件分别是设计文件和c文件,后面还有在nc环境下的仿真命令:

//hello.sv

module hello();

import "DPI-C" context pass_string_c= task pass_string_sv(input string a);

import "DPI-C" context string_c2v_c= function string string_c2v_sv();

string some_string;

// This doesnt work in IUS583, will work in IUS6.0

export "DPI-C" print_string_c = function print_string_sv;

   

function void print_string_sv(input string aaa);


$display("Exported Verilog String=
%s", aaa);

endfunction

initial


begin


some_string = "pass it ON";


// enable when running IUS6.0


pass_string_sv(some_string);
// pass string to C


$display("Verilog: %s \n", string_c2v_sv() );
// get string from C


$finish;

end

endmodule

//hello.c

#include <stdio.h>

#include <svdpi.h>

// to use io_printf (prints to ncsim.log)

#include <veriuser.h>


void pass_string_c(const char* a) {


io_printf("DPI: %s\n", a);


// now call exported function


print_string_c("string passed from C");
// This wont work in IUS583

}


const char* string_c2v_c(void) {


io_printf("C: give up a string\n");


return "Gimme String";

}

//cmd

ncvlog -sv hello.sv

ncelab -access +RWC hello

gcc -m32 -fPIC -shared -o libdpi.so hello.c -I /tools/ius-9.20.016/tools/inca/include

ncsim -messages hello

我还没来得及看-m32选项的作用,希望大家能够顺利cosim


点赞

发表评论 评论 (2 个评论)

回复 lxttian 2012-9-3 11:33
这个Cosim指的是处理器的C语言和Verilog一起仿真?
回复 bright1224 2012-12-27 17:11
是的

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 1

    粉丝
  • 3

    好友
  • 0

    获赞
  • 6

    评论
  • 470

    访问数
关闭

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

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

GMT+8, 2024-5-9 08:40 , Processed in 0.028746 second(s), 15 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部