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.

Registering DPI applications<br />

Registering DPI applications UM-565<br />

DPI applications do not need to be registered. However, each DPI imported or exported<br />

task or function must be identified using SystemVerilog ‘import “DPI”’ or ‘export<br />

“DPI”’syntax. Examples of the syntax follow:<br />

export “DPI” t1;<br />

task t1(input int i, output int o);<br />

.<br />

.<br />

.<br />

end task<br />

import “DPI” function f1 void (input int i, ouput int o);<br />

Your code must provide imported functions or tasks, compiled with an external compiler.<br />

An imported task must return an int value, "1" indicating that it is returning due to a disable,<br />

or "0" indicating otherwise.<br />

These imported functions or objects may then be loaded as a shared library into the<br />

simulator with either the comm<strong>and</strong> line option -sv_lib or -sv_liblist<br />

. For example,<br />

vlog dut.v<br />

gcc -shared -o imports.so imports.c<br />

vsim -sv_lib imports top -do <br />

The -sv_lib option specifies the shared library name, without an extension. A file extension<br />

is added by the tool, as appropriate to your platform. For a list of file extensions accepted<br />

by platform, see "DPI file loading" (UM-580).<br />

You can also use the comm<strong>and</strong> line options -sv_root <strong>and</strong> -sv_liblist to control the process<br />

for loading imported functions <strong>and</strong> tasks. These options are defined in the SystemVerilog<br />

3.1a LRM.<br />

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

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

Saved successfully!

Ooh no, something went wrong!