FPGA Development in Elphel cameras

From ElphelWiki
Revision as of 21:53, 28 January 2008 by Andrey.filippov (talk | contribs)
Jump to: navigation, search

Introduction

Much of the performance and flexibility of the Elphel cameras are provided by the reconfigurable FPGA chips. FPGA is used on the main camera board (currently it is 10353) and on some of the extension ones (10347, 10359, 10357). On the main board the FPGA chip complements CPU to perform video processing and compression - it does this nearly 100 times faster than the CPU alone, but generally it is significantly more difficult to implement some functionality in the FPGA than it can be done in the software. And so the camera (like many other modern devices) combines the strong features of both: FPGA performs computationally intensive but algorithmically relatively simple operations (working with the images on the pixel level, providing image compression) and the CPU is responsible for the higher level functions, interface and overall control of the camera.

Elphel does not make secrets of the FPGA code, all the source code is available under GNU GPL v 3.0 license, the same one as used for the camera software. Elphel software distribution (available both on Sourceforge project page and inside each camera file system) includes both binary FPGA image ("bit file") and the source code needed to re-create the FPGA image and/or simulate the design. Also included are the log files generated by the FPGA "compiler" during creation of the provided bit file so you may look inside even if you do not have the necessary FPGA tools, you may also find these files useful to compare with the output that you get from those tools.

FPGA design flow

There are two main activities during development of the FPGA code: synthesis and simulation.

  • Synthesis (the whole process involves more steps in addition to just strictly "synthesis" itself) is needed to translate the source code into the "executable" and
  • Simulation - software emulation of the FPGA functionality. Simulation runs about million times slower than the real thing, but it allows easy analysis of what is going inside the design, provides ability to test and troubleshoot project as a whole or individual modules.

Software required for FPGA development with Elphel products

Software for synthesis

Elphel cameras use 1200K gates Xilinx Spartan(R) 3e FPGA (XC3S1200E-5FT256C) that are supported (among others) by free for download (but non-free software) ISE WebPACK (R) tools (registration required for download).

That software package is really good for "compiling" your design into silicon, but the simulator provided with the free for download tools has reduced functionality.

Software for simulation

Luckily there are really free (GNU GPL) tools available for simulation and Elphel provides scripts for simulation of the design using these tools. Simulation software we use consists of two parts (that require separate installation), provided are the links to the current (as of January,28 2008) releases:

Note:You will still need to download and install Xilinx ISE WebPACK (R) even for simulation only. That package includes Verilog source code library that describes the FPGA device primitives used in the design and the current license does not allow to distribute this library with the design.

Installation of the Xilinx ISE WebPACK

Current versions of Xilinx ISE WebPACK install on Linux rather smoothly (Last time I used WebPACK 9.2 and Kubuntu 7.04) but minor tweaking was needed to launch programs like Timing Analyzer or FPGA Editor. They needed additional package to be installed (don't remember - will put here when find out) and "export DISPLAY=:0" to run correctly (without that ISE "as if" launches those programs, but nothing really happens). I just created a small startup script launch_ise.sh in the WebPACK installation directory (it was /usr/local/Xilinx92 in my case) with the following content:

#!/bin/sh
cd $(dirname $0)
export DISPLAY=:0
./bin/lin/ise

Importing Elphel project into Xilinx ISE WebPack

All the FPGA code for Elphel products is located in the fpga directory of the top installation directory that will be created when you run "./install_elphel" script inside the directory created when you inflate the Elphel software distribution. The project files for the main board (10353) FPGA is included in the fpga/x3x3 subdirectory.

When you start the ISE WebPack you need to select (from the top menu)"

Project -> Source Control -> Import

And then for the "Project file to import" navigate to the fpga/x3x3 subdirectory of you project and select file x353_import.tcl. For the "Directory to import to" select the same directory (you may just click on "..." button and then on "OK").

That should conclude importing of the project, the x353.ise will be created and you should be able to view/edit project files and run synthesis and implementation tools.

Simulating 10353 board FPGA with Icarus Verilog and GTKWave