In the previous tutorial, FPGA and microcontrollers were compared. The FPGA is one of the technologies which let an embedded engineer access hardware design of an embedded system. Its greatest advantages include multi-threading, real-time processing, wide scope for custom ASIC design (within available logic blocks on the FPGA chip), reusability and single chip solution. It is highly recommended to get hands dirty on an FPGA board after some work on microcontrollers. After all, hardware design is just another essential twin to software design in embedded engineering discipline.
Here is how any enthusiastic embedded engineer can start off the FPGA journey –
Getting clear with the pre-requisites –
While working on microcontrollers, all efforts revolve around software design of an embedded system with a given architecture and instruction set. Whether the system is coded with assembly language or the embedded C, the similar software principles apply to the development. The FPGA is an entirely different approach to embedded design. FPGA chips contain the programmable logic components i.e. logic blocks and the reconfigurable switches. By interconnecting the logic blocks (logic gates and other digital or analogue components), a complete, custom designed system on chip solution can be developed. So FPGA is all about the digital design and the integrated hardware development. So, it is must that before starting off with FPGA, one has basics of digital electronics and digital design strong and clear. Once done with that, it’s time to learn Verilog or VHDL as the programmable logic is all coded in them.
Choosing an FPGA board –
After having some knowledge of digital electronics, VHDL and Verilog, an engineer does have a conceptual idea of the digital design. Now, he is ready to get hands dirty. So, first thing first – getting an FPGA board. While microcontroller boards are available in few dollars, no FPGA board comes less than $50. One can buy a suitable board only in a price range of $50 and $100. The high price of FPGA boards is one reason that they are not as popular as microcontrollers among electronics hobbyists. However, the price of an FPGA board is covered up after long term use as these boards are reusable and digital designs can be tested on them hundreds of times without any hassle.
There are different types of FPGA boards available. The FPGA boards can be categorized into the following three categories –
1) SRAM based FPGA
2) Flash based FPGA
3) Anti Fuse based FPGA
SRAM based FPGA – These FPGA boards have static memory to store configuration data. The board reads the configuration data either from an external memory chip which is called Master mode or from a processor which is referred as slave mode. In slave mode, usually the configuration data is passed to the static memory via JTAG. There are also many FPGA boards available which come with internal flash memory. Since static memory is volatile in nature, the configuration data is loaded to the memory on start up. Some of the popular SRAM based FPGA boards include Xilinx Virtex, Altera Stratix, Xilinx Spartan (like Papilio Pro) and Cyclone.
Fig. 1: Papilio Pro FPGA development board from Xilinx Spartan 6 Family
Flash based FPGA boards – These FPGA boards have dedicated flash memory to store configuration data. They don’t have SRAM or any volatile memory. These boards are different from SRAM based FPGA with internal flash. In SRAM based FPGA with internal flash, the configuration data is loaded on the start up in the internal memory. In Flash based FPGA, the configuration data remains on the internal flash memory and is not lost on shutdown. These boards are also power efficient compared to SRAM based FPGA. Some of the popular Flash based FPGA include Igloo, and ProASIC3 boards from Actel.
Fig. 2: ProASIC3 Flash based FPGA Development Board from Actel
Anti-Fuse based FPGA boards – These FPGA boards contain anti fuse which can be burned to conduct current. Once the anti fuse are burned, they cannot be altered. So, these FPGA boards are one-time programmable and cannot be reused. The Accelerator from the Actel is one good example of Anti-Fuse based FPGA boards.
For starting development, either a SRAM based FPGA (like Papilio Pro) or a Flash based FPGA (like ProASIC3) should be preferred. Papilio Pro is a popular FPGA board that is commonly used. It costs around $75 and is easily available. The Papilio Pro runs on 3.3 V, so it may require a logic converter for interfacing with 5V devices. It has 48 I/O pins and comes with a USB port and on-board FTDI converter for interfacing with a computer.
Setting Development Environment –
Each FPGA board requires its own set of development tools which are usually available for free from its vendor. Like for developing on Papilio Pro, Papilio loader from Gadget Factory and ISE Design Suite from Xilinx are the required development tools. For downloading the ISE Design Suite, one needs to create an account on Xilinx website. The account creation and download can be done for free. The download is an evaluation version which is free to use only for a period of time. The development environment could be in few GB, so it may take some time to download it.
Beginning the Verilog Way –
Once the development tools are installed, one can start coding with VHDL. One can create a new project from Project Navigator and specify Location and Working Directory. Next one needs to specify the Product details in the Project Settings. Like, Papilio Pro belongs to Spartan 6 family and it has a specific device name and package name. These specifications can be checked from the official documentation of the board or can be examined from the chip label. The selection of programming language should be Verilog. Next step is to add the source code.
Fig. 3: Typical VHDL Source Code
The source code is compiled to two files – one is the Verilog code with .V extension and other is the user constraints file with .ucf extension. The Verilog code uses labels to specify I/O connections and wire connections to specify hardware connections between logic blocks. The UCF file contains the information about the specific chip and various parameters and constraints.
For adding source code, ‘New Source’ need to be selected under Project menu and the file type to new source should be selected ‘Verilog module’. For adding UCF file, ‘New Source’ need to be selected under Project menu and the file type to new source should be selected ‘Implementation Constraints File’. After creating the source code and UCF file, the configuration file having .bit extension can be created by double clicking “Generate Programming File”. The programming file can be opened in Papilio Loader. Now the FPGA board can be connected to the PC and the programming file can be loaded to the board using Papilio Loader. As the programming file is burnt to the board, the board begins operating accordingly.
Fig. 4: ISE Project Navigator
So, get a development board like Papilio Pro and set up the development environment. One may need additional components for different applications. So, collect the components, interface them to I/O header and start off with various Verilog code experiments.
Filed Under: Tech Articles