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

DPI use flow<br />

Steps in flow<br />

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

Correct use of <strong>ModelSim</strong> DPI depends on the flow presented in this section.<br />

.v<br />

vlog<br />

vsim<br />

vlog -dpiheader dpiheader.h<br />

vsim<br />

exportobj.o<br />

1 Run vlog (CR-358) to generate a dpiheader.h file.<br />

This file defines the interface between C <strong>and</strong> <strong>ModelSim</strong> for exported <strong>and</strong> imported tasks<br />

<strong>and</strong> functions. Though the dpiheader.h is a user convenience file rather than requirement,<br />

including dpiheader.h in your C code can immediately solve problems caused by an<br />

improperly defined interface. An example comm<strong>and</strong> for creating the header file would<br />

be:<br />

vlog -dpiheader .h<br />

dpiheader.h<br />

vsim -dpiexportobj exportobj.o<br />

mtipli.lib<br />

Step 4 Simulate<br />

vsim -sv_lib <br />

Step 1 Create header<br />

Step 1.5 Windows only<br />

.so<br />

shared object<br />

ld/link<br />

loader/linker<br />

Step 2 Include header<br />

#include "dpiheader.h"<br />

.c<br />

gcc<br />

C compiler<br />

.o<br />

compiled<br />

user code<br />

Step 3<br />

Compile<br />

<strong>and</strong> load/link<br />

C code

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

Saved successfully!

Ooh no, something went wrong!