| |
今天又重新拾起cosim,却发现怎么编译都报错,找了之前的ppt,又仔细观摩了NC的systemverilog.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. 我简直头大,一切都是按照Cadence的sysverilog.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= Verilog: C: give up a string Gimme String Simulation complete via $finish(1) at time 0 FS + 0 ./hello.sv:22 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);
endfunction initial
end endmodule //hello.c #include <stdio.h> #include <svdpi.h> // to use io_printf (prints to ncsim.log) #include <veriuser.h>
}
} //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 |