Hi, everyone!
I’m trying to use DPI-C in my TB, and have some problems with adding .so files to my testbench
my c code (i post partly, because it’s too big) loks like this:
void write_tx_output_c (
long* data_re_h,
long* data_re_l
) {
data_re_h= fir_40_l_out[HALF_UPPER];
data_re_l= fir_40_l_out[HALF_LOWER];
}
i announce it in my code like this:
package tx_fir_scoreboard_pkg;
import uvm_pkg::*;
import tx_fir_test_params_pkg::*;
import one_signal_seq_item_pkg::*;
import fft_seq_item_pkg::*;
import "DPI-C" context function void write_tx_output_c (
output longint data_re_h,
output longint data_re_l
);
`include "tx_fir_scoreboard.svh"
endpackage: tx_fir_scoreboard_pkg
and use it like this:
longint data_re_h, data_re_l;
write_tx_output_c (data_re_h, data_re_l);
i compile it with shell script:
#!/bin/csh
set machine=`uname`;
echo $machine
if ($machine == "Linux") then
limit stacksize u
set STACK=;
# set GCCPATH = /usr/local/bin;
else
set STACK = -Wl,--stack=800000000;
set GCCPATH = /usr/bin;
endif
/cadtools/mentor/questa10.6d/questasim/gcc-5.3.0-linux_x86_64/bin/g++ -fPIC -g -W -shared -lstdc++ -g $STACK -lm -lstdc++ -std=c++14 -O3 -I. -I../../ ../c_model/c_model.cpp -o c_model.so -I /vlsi-opal/sdave/suman/questa_10.3_022415/questasim/include -DCOSIM
and compilation passes without errors, so i get file c_model.so
after that i try to start simulation with this TCL (i use Modelsim) script:
vsim {-voptargs=+acc} work.tx_fir_top +UVM_TESTNAME=tx_fir_simple_test -sv_lib /eng/sandbox/bkhlopunov/standalone/tx/tx_fir/scripts/c_model
/eng/sandbox/bkhlopunov/standalone/tx/tx_fir/scripts/ is the directory where c.model.so is stored.
But after elaboration phase i get this warning in transcript:
Failed to find user specified function ‘write_tx_output_c’ in DPI precompiled library search list “/eng/sandbox/bkhlopunov/standalone/tx/tx_fir/scripts/c_model.so”
Could anyone please tell me, what am I doing wrong? Right now i am not even sure, if this is SV problem or tool problem, that’s why i’m asking here.
It looks to me that i’m doing everything as shown here:
https://verificationacademy.com/forums/systemverilog/can-i-use-.o-files-compiled-c-files-and-use-compile-sv-files-dpi
Thank you!