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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

UM-574 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 />

<strong>ModelSim</strong> does not have direct support for any language other than st<strong>and</strong>ard C; however,<br />

C++ code can be loaded <strong>and</strong> executed under certain conditions.<br />

Since <strong>ModelSim</strong>'s PLI/VPI/DPI functions have a st<strong>and</strong>ard C prototype, you must prevent<br />

the C++ compiler from mangling the PLI/VPI/DPI function names. This can be<br />

accomplished by using the following type of extern:<br />

extern "C"<br />

{<br />

<br />

}<br />

The header files veriuser.h, acc_user.h, <strong>and</strong> vpi_user.h, svdpi.h already include this type of<br />

extern. You must also put the PLI/VPI/DPI shared library entry point (veriusertfs,<br />

init_usertfs, or vlog_startup_routines) inside of this type of extern.<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>.<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, see "DPI file<br />

loading" (UM-580).<br />

For PLI/VPI only<br />

If app.so is not in your current directory you must tell Solaris 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 foreign attribute specification. (The path may include<br />

environment variables.)<br />

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

LD_LIBRARY_PATH= <br />

Microsoft Visual C++ 4.1 or later<br />

cl -c [-GX] -I\modeltech\include app.cxx<br />

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

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

The -GX argument enables exception h<strong>and</strong>ling.<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!