I've seen a lot of people talking about FPGA's before and I know that it stands for field-programmable gate array but how does it work and what is the purpose of using an FPGA?


5 Answers 5


They are electronic components that add logic to your circuits (so they are similar to micro-controllers). But the design approach is then completely different than in the uC (micro controller). In a uC, you can't change the internal uC design; you can only run "classical" programs on it. Programing FPGAs is more like creating new hardware. You create new connections between logical gates and create a new, specialized processor. And you can do it all in your home, on your desk and your PC.

Sounds cool? Yes, but there are some disadvantages. For example, price (but I think it's hard to compare it), higher power consumption, and lower clock speeds (but you can design your application in a smart way, and do more operations in one clock cycle).

Useful links:

Example usage: http://nsa.unaligned.org/

  • 3
    \$\begingroup\$ I will note that many FPGAs are large enough to contain multiple CPU cores, thus allowing the FPGA to be an entire computer unto itself. \$\endgroup\$ Dec 16, 2009 at 15:03
  • 3
    \$\begingroup\$ As a note, I think lower clock speeds can be misleading. compared to a PC, yes. Compared to a pic16, they can be faster, but it depends on the cost. Most of the cheaper ones I have had my hands on run at 40MHz, but again, product to product variation. \$\endgroup\$
    – Kortuk
    Dec 17, 2009 at 4:41

An FPGA is literally an array of logic gates that can be programmed in the field. Flip flops, multiplexers, 4-bit look up tables, etc. that can be connected any way you want, using a C-like language (Verilog).

A uC, such as an AVR, is also made of similar logic gates, but they are configured when the device is made. Sure, it has RAM and Flash so you can write software to read inputs and control outputs, but you can't change the actual arrangements of the gates. The gates will always be arranged into an ALU, a memory controller, a serial port, etc.

The benefit of the uC is that you can program it in the field (at your desk), with an easy to use, familiar, high level language such as C. The problem is, software is "slow". To have an input control an output, in the simplest case, you might write:

void loop(){ buttonState = digitalRead(buttonPin); if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else { digitalWrite(ledPin, LOW); } }

That would be turned into a dozen assembly instructions, so the loop would take a microsecond or so to control that one output from one input. And it takes the whole uC chip to do it that fast. Sure, you can do much much more, but then your ability to control that output will slow down as the uC gets busy doing other things.

In an FPGA, I could configure the gates to have an input control an output in 1 clock. So the output would follow the input with a delay of perhaps 25 nanoseconds. That's 40X faster, using the same clock period. And the rest of the gates in the FPGA are available to do many other things, which won't affect the speed of this little function.

The code for the FPGA would be a simple flip flop:

always @ (posedge clock) ledPin <= buttonPin;

This would take only 1 FPGA cell, about 40 gates, out of tens of thousands in an FPGA.

I can reprogram my FPGA to do something else, for example control the led based on a combination of four inputs, still in one clock, still using that 1 FPGA cell. Or control the led based on a serial stream from the input, in a few FPGA cells, which would be 100's of gates. So I could control the LED based on serial data, say "ON" or "OFF", with the serial stream at a very high rate (easily 20MHz), and still only use a tiny fraction of the FPGA's capacity.

So the advantage of an FPGA is clearly speed. It can do anything a uC can do, and it can do it much faster, with everything done in parallel. Complex things that a uC would take milliseconds do to, an FPGA could do in microseconds or less. As long as there are gates left over in the FPGA, I can add more functions to it without affecting the speed or operation of previous functions in the FPGA. By the way, an FPGA can very easily run a clock rate of 20MHz.

Cost is not a differentiator. I can buy an FPGA that could implement almost any Arduino design I have ever seen for about $5, about the same as an Arduino AVR chip. There are also free toolchains (IDE, compiler, debugger) for FPGAs.

Power is not a differentiator. Since I can run the FPGA at a much lower clock rate to get the same function as a uC, and use a small portion of its gates (unused gates use only leakage power), an FPGA can beat the power of almost any uC-based design.

The biggest downside to an FPGA is that it is much more complex and time consuming to define, write the code, and debug a non-trivial FPGA design than a uC program. A typical uC project that you might do in an evening could take days on an FPGA.

Other, potentially fixable problems are that most people are trained in software programming, but few understand hardware programming. You can learn Verilog fairly easily. But you would also need to think in terms of hardware design instead of software design. The design patterns are much different.

Another issue is that FPGA's don't come in little 8 to 20 pin DIP packages. They tend to come in 100-pin or larger surface mount packages, so building the boards is harder.

And a final problem is that a whole lot of interesting projects can be implemented just fine in those easy to use uC's, so why bother with an FPGA?

  • 2
    \$\begingroup\$ "I can buy an FPGA that could implement almost any Arduino design I have ever seen for about $5" I'm sorry, but hvæt? Where? \$\endgroup\$
    – shieldfoss
    Aug 16, 2013 at 14:07

If you are familiar with basic logic gates, you should know that they're virtually instantaneous. The operation A and B OR C changes instantly when A, B or C change.

An FPGA is (sort of) a matrix of programmable logic gates. You can define the inputs and outputs (as a combination of the inputs).

In a uC, A+B/C*sqrt(D) would take several clock cycles and some memory. In an FPGA, the result is almost immediate.

They are great for video, DSP, cryptography...

That's the main advantage. Modern FPGAs are suited now with memory and there are uC/FPGA hybrids.

  • \$\begingroup\$ I know many Practicing EEs with many years of experience that will often just through an FPGA into the design instead of a uC where you used to see uC. I really think they are great for interface handling. \$\endgroup\$
    – Kortuk
    Dec 17, 2009 at 4:50
  • \$\begingroup\$ Yes I think this is nice example: armadeus.com/english/index.html. Specially interesting for me is servo control example: marwww.in2p3.fr/~duval/wiki_html_dump/articles/m/o/t/… \$\endgroup\$ Dec 21, 2009 at 8:07
  • 2
    \$\begingroup\$ Also of note is that there are more and more "C to VHDL" or "C to Verilog" converters. They aren't the most efficient things yet but you can convert already written code into hardware that can be utilized for a speed improvement. Pretty cool if you ask me (and if you have the dough for it). \$\endgroup\$ Feb 23, 2010 at 16:40

They are used for cracking encryption keys much faster than a general-purpose computer could. :D

  • 1
    \$\begingroup\$ Haha, I enjoyed your very functional description. They are absolutely amazing at parallel processing. \$\endgroup\$
    – Kortuk
    Dec 17, 2009 at 18:54
  • \$\begingroup\$ A codebreaker project: copacobana.org \$\endgroup\$
    – hhh
    Jun 18, 2010 at 8:00

To save money and risk vs. an ASIC. Unless you

  1. Deeply care about power or
  2. Are building a bunch of them (say >10k units)

the fixed (NRE) costs of doing an ASIC make it cost prohibitive.

Since you can change a FPGA easily, you can simulate the design less and get into lab quicker. Also you can do a partial design and build on it, as in software.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.