I promised that this time I’d wrap up talking about FPGA fundamentals – at least for awhile. Over the last few weeks, I talked about Verilog, flip flops, combinatorial logic, and how to get started with programmable logic devices. Hopefully you have a good idea of what these devices can do and how to get your feet wet.
Not everyone uses FPGAs the same way. Obviously, you can use an FPGA or a CPLD to consolidate “glue logic” in your designs. Memory and I/O decoding, oscillators, PCI interfaces, and all the other little bits of logic you need for a practical design can reside on an FPGA.
There are two other common strategies for using FPGAs. One is to use the device as a super I/O chip along with a normal processor. The processor can load the FPGA’s configuration and then use the devices implemented by the FPGA. You don’t see it very often, but you can even load different configurations for different circumstances.
The other common design is to put a CPU “core” on the FPGA itself along with whatever circuitry you want. This is very similar to having an external CPU, except it is all in one package. Of course, you have to have an external method to configure the FPGA because the CPU doesn’t exist until the FPGA starts up.
There are plusses and minuses to each method. An external CPU is usually cheap, but an all-in-one (SOC or system on a chip) solution can have a very low parts count. On the other hand, it also consumes part of your FPGA. Some FPGA vendors have even started shipping devices with one or more CPUs already hardwired on the chip – sort of a hybrid of the two approaches.
One exciting (but underexplored) idea is to use FPGAs for reconfigurable computing. Imagine a compiler that could look at your program and deduce that it would be optimal to have a CPU with (for example) three integer adders, a multiply accumulate unit, and two floating point arithmetic units. It could build a virtual CPU for the FPGA, compile the code for the custom CPU, and then achieve superior performance compared to normal CPUs.
If you want to integrate a CPU on the chip, you have several choices. Designing your own is fun and instructional, but not really practical for most projects. Many vendors have CPU cores available (some free and some that require payment) along with development toolchains. You can also find third parties willing to supply you with FPGA configurations that implement CPUs, including many open source or free ones (see www.opencores.org, for example). Many of these CPUs mimic traditional CPUs so you can use existing toolchains to work with them. Others have their own toolchains.
You can find cores for lots of things, not just CPUs. For example, the opencores site has video controllers, math coprocessors, and many more virtual devices you can use in your own designs. Sometimes these are delivered as Verilog or VHDL source. Other times cores will be EDIF files, which are more like object files for software.
I could go on for another month or more, but I promised I’d wrap up this week. So if you want to know more, you should have a good start. You can download the Xilinx or Altera tools free from their websites and work through their tutorials. You’ll need real hardware eventually, but both packages have great simulators – you might be surprised how much you can accomplish with nothing but the free tools.
Once you outgrow the vendor tutorials, you’ll find plenty of information online, including in the back pages of Dr. Dobb’s. For example, see http://is.gd/5q6N9a, http://is.gd/FbAYE0, and http://is.gd/qu2zRT. You might also enjoy my old-fashioned 16-bit minicomputer design. You can see a video of that computer in action (including the very novel front panel) in Blue 16-bit FPGA CPU Demo (Xilinx Spartan 3).