Field Programmable Gate Arrays are a form of chip that is similar to a microprocessor, but with some key differences. FPGAs are not something that the average home user will know about, but they are the largest selling type of computer, because they are embedded into so many different systems. The early FPGAs featured around 10,000 logic gates and 10,000 bits of memory, which is a far cry from a standard microprocessor. Today, FPGAs are faster, have more gates, and have more memory, but they’re still slower than a microprocessor because they are designed with versatility in mind rather than raw speed.
FPGAs are programmed in a way that is rather different to microprocessors, and this is what can cause frustration and confusion for some. Unlike microprocessors, where software programming languages tend to be (for the most part) higher level, with FPGAs, the developer has more direct access to the logic gates. Those who have experience of embedded systems programming will find FPGA development quite intuitive.
FPGAs vs Microprocessors
With microprocessors, programs are coded in languages such as C / C++, JAVA, or an OS-specific language. FPGA programming languages are slightly different, with Verilog and VHDL being two popular options. The programs are not compiled into .dll or .obj formats, rather they are ‘synthesized’. Where microprocessor programs are compiled and then linked (to make a .exe), FPGA programs are synthesized, then placed and routed.
Architectural Design for FPGAs
The architectural-design phase that FPGAs follow is similar in a lot of ways to that used in embedded systems programming. There are a few different options for how to approach development. In many cases, for bigger projects, a developer will perform a first cut using pseudocode, which can then be re-done in a more common language. This helps people to think through the code and figure out the approach that they want to take. Being able to express logic in a programming language such as C will stand people in good stead for development.
If you understand the basics of compiling, assembling and linking from software development, then understanding the slight differences between synthesizing, placing and routing will not be too difficult.
Verilog’s syntax is C-like, and you can use any editor to prepare a.v file for an FPGA. Many people find it helpful to use editors that have some syntax highlighting features, but it is not compulsory to do so.
Once you have the code written out, the next step is to convert it into a format that the FPGA can understand. For an FPGA, this means taking the .v file and turning it into Register Transfer Logic (RTL) netlists. With these, data is transferred into registers. FPGA programming differs from microprocessor programming in some ways here because there is an extra process required to produce bits, or the intermediate objects that can be converted to bits, which will control the gates, registers, and memory that makes up the FPGA. This means that people are programming ‘gate-level’ logic, which is then output to an Electronic Design Interchange Format file.
Where microprocessor code is compiled, FPGA is synthesized, and there are some significant differences between these two things. Compilers produce bits which control a set of gate patterns that are fixed. Microprocessors are set up in one specific way. FPGAs, on the other hand, are rather different in that the instructions are mapped to logical gates. There are multiple gate structures on the FPGA and developers have unprecedented control over which gates do what. After microprocessor code is compiled, it is linked. Again, FPGAs differ here. The FPGA will place and route code over a two-dimensional array of logic gates and buses, to allow the systems to perform as required.
This is one area where embedded systems developers might feel like they are ‘in home territory’. An embedded program is often embedded into some physical ROM. FPGA programs are embedded in the FPGA itself. The programming file is written and then downloaded onto the FPGA. If the FPGA is nonvolatile then the program will be burned into the hardware, and that’s a one-off thing. If the FPGA is volatile, then this is something that is done at power-up and different code can be added as required. The bits are compiled, synthesized, then placed and routed to do their job.
Before code is sent to a physical FPGA, most developers will test it on a simulator that runs on a microprocessor. This allows the developer to identify any bugs early on. It is possible to step through the logic as the program is being ‘executed’ to see what is happening in each register, and see flags set and memory allocated. Once it is clear that the program is being executed as expected, it makes sense to then download it into the FPGA and run it there.
Drawing Up Verilog
Verilog allows developers to wire up different gates, giving lots of control over how the FPGA is optimized. One area where many microprocessor developers get confused is that with FPGA development, everything is happening at the same time. Even if the design is clocked, it is not executed sequentially. You are dealing with electronics, not with code. It is possible to make sequential designs with VHDL, but it is important to remember that you will need to latch or clock each element to control when it changes. If you do not do this, then the changes will be unpredictable based on the signal propagation time. They will appear to be near-instant, and this can make for some unpredictable behavior in your system.
HDL is simply a drawing that is made with words, and it is a good way to express the program for a complex design. It is still a drawing, and it still follows the same rules as Verilog. Software developers will need to put some time in to get used to the idea of instant and simultaneous execution, but once that new paradigm is understood, much of the rest of the development process remains the same. To find out more checkout http://www.directics.com – Altera Fpgas available now.