I have a further question that whether the import/export function declaration must be inside a module ? The error information is shown below.
Error-[DPI-DXFNF] DPI export function not found
Please check the called DPI export function/task is defined in the mentioned
module, or check if the DPI declaration of the DPI import function/task
which invokes that DPI export function/task is made with ‘context’. Another
work-around is using svGetScopeFromName/svSetScope to explicitly set the
scope to the module which contains the definition of the DPI export
function/task.
DPI imports/exports do not need to be in a module.
Did you follow all the advice given by the error message? Did you package import the DPI exported function into the module where you called the DPI imported function?
Hi Dave,
Do you mean the DPI imports/exports function needs to be inside a module, right ?
I am sorry the example I currently have is a bit complicated and I have little idea how to express it here…
Now I fixed the “DPI not found” issue but encountered next error which is Segmentation Fault.
May I know how to debug this kind of error ? It looks like too little error information in the logfile.
Here is my code:
C file:
[c]
struct reg_t {
unsigned int addr;
unsigned int data;
}
extern “C” void exported_sv_function(reg_t a);
extern “C” void get_all_reg() {
reg_t tmp;
unsigned int total = 500;
unsigned int idx;
for (idx = 0; idx < total; idx++) {
tmp.addr = idx;
tmp.data = idx;
exported_sv_function(tmp);
}
[/c]
and in my sv file :
typedef struct {
logic [31:0] addr;
logic [31:0] data;
} reg_t;
reg_t my_reg_array[$];
export"DPI-C" function exported_sv_function;
function void exported_sv_function(input reg_t x);
my_reg_array.push_back(x);
endfunction
import "DPI-C" context function void get_all_reg();
and in my test (my_test.sv file)
...
task my_test::run_phase(uvm_phase phase);
get_all_reg(); // The Segmentation fault is happened here
endtask
...
And the whole error information is shown below.
An unexpected termination has occurred in /proj/out/…/sim/exec/vcs_sim_exe due to a signal: Segmentation fault
Dumping VCS Annotated Stack: #0 0x00000033dda0b63c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x00002aaad1154240 in ndpBIMT_popElem () from /tool/cbar/apps/verdi/2017.03-SP2-11/share/PLI/lib/LINUXAMD64/libsscore_vcs201703.so #2 0x00002aaad115482e in ndpBIMT_ConsumerMain () from /tool/cbar/apps/verdi/2017.03-SP2-11/share/PLI/lib/LINUXAMD64/libsscore_vcs201703.so #3 0x00000033dda07a51 in start_thread () from /lib64/libpthread.so.0 #4 0x00000033dd2e896d in clone () from /lib64/libc.so.6 #0 0x00000033dd2ac6cd in waitpid () from /lib64/libc.so.6 #1 0x00000033dd23e609 in do_system () from /lib64/libc.so.6 #2 0x00000033dd23e940 in system () from /lib64/libc.so.6 #3 0x00002aaab41f71bb in SNPSle_10ee25eff68cd8461c9146fa1d0b35e87067f3c8015b313e639d2928478c79b3f673f99203bcf8be64600612100082236bffb2007f1e0ef9 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so #4 0x00002aaab41f8bc6 in SNPSle_10ee25eff68cd8461c9146fa1d0b35e87067f3c8015b313efba706aab251478fa49e66610e453774633a6c152e7ef778f2202cda681f3d4e () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so #5 0x00002aaab41f1c95 in SNPSle_d35ca1ff70d465c2b9b1a72eee90a506fdd009d3de3db1de () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/liberrorinf.so #6 0x00002aaab733ce68 in SNPSle_64133461705005bb725549e2e6fa1b3f () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #7 0x00002aaab719e43e in SNPSle_82244d58c54c18c70d63edc9becab634 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #9 0x00000033dd283900 in memmove () from /lib64/libc.so.6 #10 0x00002aaab84715c4 in SNPSle_2681ff91466c07ba85e55d8e718f74c7f0dd524361188f7def6afc2d54b39315 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #11 0x00002aaab847442f in SNPSle_64cf966be35473e7c27d42cab9451f7c620b2a08eac4939b () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #12 0x00002aaaac929ba9 in F_VCSgd_EaWgM_166_0 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so #13 0x00002aaaaf36b5b2 in exported_sv_function () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so #14 0x0000000000427655 in rlc_get_all_reg () #15 0x00002aaaac913059 in U_VCSgd_EaWgM_136 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so #16 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #17 0x00002aaaac8fc15f in U_VCSgd_EaWgM_16 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_29753_archive_1.so #18 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #19 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #20 0x00002aaab73ba864 in SNPSle_ba9d6ef1a21efcfe () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #21 0x00002aaaafb7e629 in U_VCSgd_hEeZs_211 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so #22 0x00002aaaafb7f11d in F_VCSgd_hEeZs_13328_0 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so #23 0x00002aaaafb7e97a in U_VCSgd_hEeZs_212 () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so #24 0x00002aaaaf634f83 in N_VCSgd_irqrb () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_prev_archive_1.so #25 0x00002aaab72ed620 in SNPSle_63c7abb936d47b07d29d61775f9dbe8c () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #26 0x00002aaab7351f2f in SNPSle_490598bfebcc8e81efcf3d1815066cc9 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #27 0x00002aaab7367178 in SNPSle_490598bfebcc8e81 () from /tool/cbar/apps/vcs-mx/2017.03-SP2-11/linux64/lib/libvcsnew.so #28 0x00002aaab3814717 in main () from /proj/…/pub/sim/exec/vcs_sim_exe.daidir/_csrc0.so #29 0x00000033dd21ed5d in __libc_start_main () from /lib64/libc.so.6 #30 0x0000000000426289 in _start ()
Debugging DPI code requires tool specific help, and this Mentor sponsored public forum is not for tool specific issues. Please contact your vendor directly.
As a follow-up to Dave’s comment, you should read Appendix H of the LRM regarding the DPI C layer and how data types are mapped. A logic[31:0] is not compatible with unsigned int.