Skip to main content

Hardware Design

FPGAs for the rest of us

FPGAs can be programmed to become digital circuit of choice. The code becomes the hardware! We explore the mechanics behind how the FPGA might be able to implement circuits.

FPGA stands for Field Programmable Gate Arrays. You can think of it as something programmable like a CPU, except that the code becomes the hardware! The code for an FPGA is essentially a digital circuit described somehow (we'll look at this in later posts) in a text file. Once compiled and flashed, the internal blocks of the FPGA rewire themselves to become the stated logic!

In this post, we will build a mental model of how the FPGA might be implementing the programmed logic.

Let's talk about a simple two-input AND gate. It takes two inputs, say A and B, and has an output C. We will refer to positive logic to avoid confusion. What that means is that 1 represents digital HIGH, and 0 represents digital LOW.

The AND Gate

Output is 1 only if both its inputs are 1!

That's the definition of AND gate. Now, think about how it may be implemented?

AND Gate and its truth table. Note that the truth table completely describes the Gate.

Well, one way is to go down to the semiconductor physics level and arrange transistors to make an AND gate. The problem with this is that you need a lot of industrial equipment/process, special technologies, experienced labor, time, etc. That is too much work to implement a single AND gate!

If you were to design a digital circuit full of transistors, build it by putting transistors in place, one transistor at a time; good luck to you! Watch Sam Zeloof make a chip at home in the video below. It should convince you of the complexity involved.

As a side note, this is exactly what established semiconductor companies like Intel, AMD, Apple, etc. do to make their chips/silicon; they work with fabrication facilities like TSMC, to get the chips printed.

Back to the FPGA. So, the FPGA gives us a way to make a circuit in silicon (almost!) by rewiring pre-existing circuits within it (very different from picking and connecting transistors and logic gates). Remember, AND gate's working is represented by its truth table. If we can cook up

a circuit that can look at the inputs, read the truth table and tell us what the output has to be,

we would have found a way to implement the AND gate.

Of Course, this comes at a cost - generic circuits (think lego like something) is power hungry and bulky (meaning that it takes more number of transistors to implement it). This is no problem for prototyping and experimenting!

Since these circuits read a table, they can be used to implement almost any digital circuit. After all, the individual circuit is just looking at the inputs, then looking up the answer in a table and telling the output. The output of one such circuit can be connected to another and so on. Β Making complex digital logic would be possible.

As you can imagine, implementing a digital circuit is thus, putting it's truth table in the chip and routing the connections between the generic circuits. Easy and powerful, eh?

side note: Some manufacturer could give us a chip with a sea of such circuits. They could could in fact make lot of copies of that generic circuit and provide a way to wire the inputs and outputs within a single chip. This is what companies like - Xilinx, Lattice and Intel do for their line of FPGA offerings :).

This in fact is the central idea of FPGAs. The generic circuit that does the job of reading the table to see what the output has to be for the given inputs is called a Lookup Table (LUT). Yes! The name is very obvious and so is the functionality.

This is the key component/circuit of an FPGA and everything else that lives inside it is just the supporting infrastructure. Let us now predict the design of the LUT. The most basic possible one.