VPI Simulation With ModelSim On Windows

These instructions should work similar for any UNIX version of ModelSim, just change the paths and parameters from "Windows" style to "UNIX" style. I do not have a UNIX version of ModelSim available for testing.

Requirements

I successfully used MinGW. http://www.mingw.org/ an OpenSource distribution of gcc (GNU Compiler Collection)

Command Line Building the Sensor and Display libraries

The OpenCV runtime dll's will need to be available. I found the easiest method, is to copy all the runtime dll's to the working directory.

These consist of:

cv100.dll, cvcam100.dll, cxts001.dll, highgui100.dll, ml100.dll, cvaux100.dll, cxcore100.dll

The .dll's can be found in the OpenCV directory C:\Program Files\OpenCV\bin

The OpenCV headers will also be needed, however, those can either be copied or referenced with a compiler include directive. The command-line below references the include files as if OpenCV is installed in C:\Program Files\OpenCV

The ModelSim VPI header is also included from the ModelSim installation directory. Change paths as necessary in the command line below.

Compile the sensor module

Link the sensor module

The ModelSim VPI library must be linked into our VPI module as well as the OpenCV libraries. The ModelSim library mtipli will be referenced from its install location while the OpenCV libraries have been copied into the working directory.

Compile and link the display module

g++ -c -o imageDisplay.o imageDisplay.cpp -Ic:/Program\ Files/OpenCV/cv/include -Ic:/Program\ Files/OpenCV/cxcore/include -Ic:/Program\ Files/OpenCV/otherlibs/highgui -Ic:/Modeltech_xe_starter/include
g++ -shared -o imageDisplay.dll imageSensor.o -L. -Lc:/Modeltech_xe_starter/win32xoem -lcxcore100 -lhighgui100 -lcv100 -lmtipli

Command Line Simulation with ModelSim

  1. Create the Verilog library
    vlib work

  2. Compile the Verilog files
    vlog sensor.v
    vlog top.v

  3. Run a simulation
    You must find an image file and place it in the working directory as "image.jpg". (The file path is set as a parameter in the top.v file)

    vsim -c -pli imageSensor.dll -pli imageDisplay.dll testbench

After a brief period of time, a window should appear on the screen and your image should appear. Depending upon the speed of the simulation machine and size of the image, it may take several seconds to even a minute. Its best to try this first on a small image <= 640x480. On an 1.6GHz machine with a 640x480 input image, it will take around 20sec.

ModelSim GUI

Create a project with sensor.v and top.v as you usually would with any other Verilog project. When you get ready to generate a simulation, open the "Simulation Properties" dialog and select the "Others" tab. In the "Other Vsim Options" box enter: "-pli sensor.dll -pli display.dll"

Run the simulation and you should see a window with your image file appearing after a bit of simulation running. Using the "wave" window, you should be able to trace the signals and see the VACT, HACT and pixel data "D" for your image file.