24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UM-568 D - Verilog PLI / VPI / DPI<br />

Compiling <strong>and</strong> linking C applications for PLI/VPI/DPI<br />

Windows platforms<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong><br />

The following platform-specific instructions show you how to compile <strong>and</strong> link your<br />

PLI/VPI/DPI C applications so that they can be loaded by <strong>ModelSim</strong>. Various native C/<br />

C++ compilers are supported on different platforms. The gcc compiler is supported on all<br />

platforms.<br />

The following PLI/VPI/DPI routines are declared in the include files located in the<br />

<strong>ModelSim</strong> /modeltech/include directory:<br />

acc_user.h declares the ACC routines<br />

veriuser.h declares the TF routines<br />

vpi_user.h declares the VPI routines<br />

svdpi.h declares DPI routines<br />

The following instructions assume that the PLI, VPI, or DPI application is in a single source<br />

file. For multiple source files, compile each file as specified in the instructions <strong>and</strong> link all<br />

of the resulting object files together with the specified link instructions.<br />

Although compilation <strong>and</strong> simulation switches are platform-specific, loading shared<br />

libraries is the same for all platforms. For information on loading libraries for PLI/VPI see<br />

"PLI/VPI file loading" (UM-580). For DPI loading instructions, see "DPI file loading" (UM-<br />

580).<br />

For all UNIX platforms<br />

If app.so is not in your current directory, you must tell the OS where to search for the shared<br />

object. You can do this one of two ways:<br />

Add a path before app.so in the comm<strong>and</strong> line option or control variable (The path may<br />

include environment variables.)<br />

Put the path in a UNIX shell environment variable:<br />

LD_LIBRARY_PATH= (for Solaris/Linux)<br />

or<br />

SHLIB_PATH= (for HP-UX)<br />

Microsoft Visual C 4.1 or later<br />

cl -c -I\modeltech\include app.c<br />

link -dll -export: app.obj \<br />

\modeltech\win32\mtipli.lib -out:app.dll<br />

For the Verilog PLI, the should be "init_usertfs". Alternatively, if there is<br />

no init_usertfs function, the specified on the comm<strong>and</strong> line should be<br />

"veriusertfs". For the Verilog VPI, the should be "vlog_startup_routines".<br />

These requirements ensure that the appropriate symbol is exported, <strong>and</strong> thus <strong>ModelSim</strong> can<br />

find the symbol when it dynamically loads the DLL.<br />

When executing cl comm<strong>and</strong>s in a DO file, use the /NOLOGO switch to prevent the<br />

Microsoft C compiler from writing the logo banner to stderr. Writing the logo causes Tcl<br />

to think an error occurred.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!