I successfully used MinGW. http://www.mingw.org/ an OpenSource distribution of gcc (GNU Compiler Collection)
- ModelSim PE or ModelSim Xilinx edition (Free limited download)
- OpenCV Library
The paths below are derived from the windows installer default install paths of OpenCV version 1.0- C/C++ compiler
ModelSim claims support for MinGW (gcc) and Microsoft Visual C++ 4.1 or greater. ModelSim has stated that Cygwin GCC will not work.
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.dllThe .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
- g++ -c -o imageSensor.o imageSensor.cpp -Ic:/Program\ Files/OpenCV/cv/include -Ic:/Program\ Files/OpenCV/cxcore/include -Ic:/Program\ Files/OpenCV/otherlibs/highgui -Ic:/Modeltech_xe_starter/include
Link the sensor module
The ModelSim VPI library must be linked into our VPI module as well as the OpenCV libraries. The ModelSim librarymtipli
will be referenced from its install location while the OpenCV libraries have been copied into the working directory.
- g++ -shared -o imageSensor.dll imageSensor.o -L. -Lc:/Modeltech_xe_starter/win32xoem -lcxcore100 -lhighgui100 -lcv100 -lmtipli
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
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.
- Create the Verilog library
vlib work
- Compile the Verilog files
vlog sensor.v
vlog top.v
- 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 thetop.v
file)vsim -c -pli imageSensor.dll -pli imageDisplay.dll testbench
Create a project withsensor.v
andtop.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.