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-562 D - Verilog PLI / VPI / DPI<br />

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

The storage for each usertf entry passed to the simulator must persist throughout the<br />

simulation because the simulator de-references the usertf pointer to call the callback<br />

functions. We recommend that you define your entries in an array, with the last entry set to<br />

0. If the array is named veriusertfs (as is the case for linking to Verilog-XL), then you don't<br />

have to provide an init_usertfs function, <strong>and</strong> the simulator will automatically register the<br />

entries directly from the array (the last entry must be 0). For example,<br />

s_tfcell veriusertfs[] = {<br />

{usertask, 0, 0, 0, abc_calltf, 0, "$abc"},<br />

{usertask, 0, 0, 0, xyz_calltf, 0, "$xyz"},<br />

{0} /* last entry must be 0 */<br />

};<br />

Alternatively, you can add an init_usertfs function to explicitly register each entry from the<br />

array:<br />

void init_usertfs()<br />

{<br />

p_tfcell usertf = veriusertfs;<br />

while (usertf->type)<br />

mti_RegisterUserTF(usertf++);<br />

}<br />

It is an error if a PLI shared library does not contain a veriusertfs array or an init_usertfs<br />

function.<br />

Since PLI applications are dynamically loaded by the simulator, you must specify which<br />

applications to load (each application must be a dynamically loadable library, see<br />

"Compiling <strong>and</strong> linking C applications for PLI/VPI/DPI" (UM-568)). The PLI applications<br />

are specified as follows (note that on a Windows platform the file extension would be .dll):<br />

As a list in the Veriuser entry in the modelsim.ini file:<br />

Veriuser = pliapp1.so pliapp2.so pliappn.so<br />

As a list in the PLIOBJS environment variable:<br />

% setenv PLIOBJS "pliapp1.so pliapp2.so pliappn.so"<br />

As a -pli argument to the simulator (multiple arguments are allowed):<br />

-pli pliapp1.so -pli pliapp2.so -pli pliappn.so<br />

The various methods of specifying PLI applications can be used simultaneously. The<br />

libraries are loaded in the order listed above. Environment variable references can be used<br />

in the paths to the libraries in all cases.

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

Saved successfully!

Ooh no, something went wrong!