User`s manual

Using the Verilog PLI
5-84 Verilog Simulation ModelSim Xilinx Users Manual
See also Appendix A - ModelSim Variables for more information on the
modelsim.ini file.
PLI Example
The following example is a trivial, but complete PLI application.
hello.c:
#include "veriuser.h"
static hello()
{
io_printf("Hi there\n");
}
s_tfcell veriusertfs[] = {
{usertask, 0, 0, 0, hello, 0, "$hello"},
{0} /* last entry must be 0 */
};
hello.v:
module hello;
initial $hello;
endmodule
Compile the PLI code for Solaris operating system:
% cc -c -I<install_dir>/modeltech/include hello.c
% ld -G -o hello.sl hello.o
Compile the Verilog code:
% vlib work
% vlog hello.v
Simulate the design:
% vsim -c -pli hello.sl hello
# Loading work.hello
# Loading ./hello.sl
VSIM 1> run -all
# Hi there
VSIM 2> quit