What Is an FPGA?
From PALs and CPLDs to modern FPGAs; FPGA versus CPU, GPU and ASIC; configuration memory and the bitstream; when an FPGA is the right tool.
1. A chip whose wiring you choose
In Part I you built adders, multiplexers, counters and registers from logic gates and flip-flops. On paper, a circuit is a set of gates plus the wires that connect them. When a company manufactures a chip, both the gates and the wires are fixed forever in the silicon. A field-programmable gate array(FPGA) is different: it is a chip full of small, generic logic elements and a huge network of programmable wires, and you decide — after the chip has left the factory, “in the field” — what each element computes and how they are connected.
The name explains itself. Gate array was an older kind of chip whose transistors were made in advance and whose final metal wiring layers were added to order by the manufacturer. Field-programmablemeans the customization is done by loading a file into the chip, in seconds, as many times as you like. That file is called the bitstream.
It helps to be precise about what an FPGA is not. It is not a processor: it does not fetch and execute instructions (unless you build a processor out of it). When you “program” an FPGA you are not writing a list of steps; you are describing a circuit, and the tools turn that description into the settings of millions of tiny switches. That is why this course talks about hardware description languages (Part III) rather than programming languages.
2. Before FPGAs: PLA, PAL, GAL and CPLD
Recall from Chapter 1 that any Boolean function can be written as a sum of products: an OR of several AND terms, such as \(y = a\,\bar b + \bar a\, c\, d\). The first programmable logic chips of the 1970s were built directly on this fact.
- A PLA (programmable logic array) has a programmable AND array that forms product terms from the inputs and their complements, followed by a programmable OR array that sums them. Flexible, but two layers of programmable connections made it slow and expensive.
- A PAL (programmable array logic, Monolithic Memories, late 1970s) keeps the AND array programmable but fixes the OR gates: each output sums a fixed number of product terms, typically seven or eight. Simpler and faster. PALs were programmed once by blowing tiny fuses.
- A GAL (generic array logic, Lattice, mid-1980s) is an electrically erasable PAL, and its outputs pass through a configurable macrocell that can include a flip-flop. Parts such as the 22V10 are still sold.
- A CPLD (complex programmable logic device) puts dozens of PAL-like blocks on one chip and joins them with a central programmable interconnect. Its configuration lives in on-chip flash or EEPROM, so it works the instant power is applied.
Sum-of-products devices are fast and predictable, but they scale badly. Each output can only use a few product terms, a flip-flop is tied to each output, and making the central AND array bigger makes every signal slower. Something different was needed to build circuits with thousands of gates.
3. 1985: the XC2064 and the FPGA idea
In 1984 Ross Freeman, Bernard Vonderschmitt and James Barnett founded Xilinx around a different idea. Instead of one big AND–OR array, place a regular grid of small, identical logic blocks, surround them with channels of wires, and put programmable switches where the wires cross. Each logic block would compute its function with a look-up table (LUT) — a tiny memory holding the function's truth table — followed by an optional flip-flop. The first product, the XC2064 (1985), had an 8 × 8 grid of 64 such configurable logic blocks, each able to compute any function of up to four inputs (or two functions of three) and to register the result.
Freeman's bet was that transistors would keep getting cheaper (Moore's law), so “wasting” most of a chip on programmability would become affordable. He was right. The XC2064 replaced roughly a thousand gates; the Zynq-7020 on your board has 53,200 six-input LUTs and 106,400 flip-flops, and the largest current devices have millions of LUTs.
The industry grew around a handful of companies: Xilinx (part of AMD since 2022) and Altera (bought by Intel in 2015, now an independent company again) dominate high-end parts; Lattice, Microchip, and newer firms such as Efinix and Gowin make smaller and low-power devices. The vocabulary differs between vendors — Altera says ALM and LAB where Xilinx says slice and CLB — but the architecture is recognisably the same. This course uses Xilinx names because the PYNQ-Z2 carries a Xilinx chip.
4. Configuration memory and the bitstream
How does a chip “become” your circuit? In a modern Xilinx FPGA, every programmable choice is controlled by one bit of configuration memory: static RAM (SRAM) cells scattered all over the die, right next to the thing they control. One bit stores one row of a LUT's truth table. Another bit turns on a pass transistor that joins two routing wires. Others select whether a flip-flop uses a clock enable, what voltage standard an I/O pin uses, and so on.
The bitstream is simply the file containing the value of every one of those cells, plus commands for the chip's configuration controller. Vivado (Chapter 13) produces it as a .bitfile at the end of the design flow. For the Zynq XC7Z020 it is about 32 Mbit (roughly 4 MB), whatever the size of your design: unused resources are configured too, just to “off”.
Because SRAM is volatile, the configuration disappears when power is removed. Every SRAM FPGA therefore has to be configured again at each power-up: from an external flash chip, through the JTAG debug port (what Vivado's Hardware Manager does), or — on the Zynq — by the ARM processor, which can read a bitstream from the SD card and load it into the programmable logic while Linux is running. That last trick is how PYNQ swaps “overlays” in Part VII.
| Technology | Reprogrammable? | Keeps config without power? | Typical use |
|---|---|---|---|
| SRAM (Xilinx, Altera, Lattice ECP…) | yes, unlimited | no — reload at power-up | mainstream FPGAs, highest density |
| Non-volatile: flash / SONOS (Microchip PolarFire, Lattice MachXO…) | yes, many times | yes — instant-on | low power, CPLD replacement |
| Antifuse (Microchip RTAX…) | no, one-time | yes | radiation-hard space hardware |
5. FPGA versus CPU, GPU and ASIC
FPGAs compete with three other ways of doing computation. The right choice depends on a handful of properties. A few terms first: latency is the time from an input arriving to its result being ready; throughput is how many results per second come out; NRE(non-recurring engineering) is the one-off cost of designing and manufacturing the first chip.
| CPU | GPU | FPGA | ASIC | |
|---|---|---|---|---|
| How it computes | instructions, in time | thousands of threads, same instruction | custom circuit, in space | custom circuit, in space |
| Clock (typical) | 2–5 GHz | 1–2 GHz | 100–500 MHz | 0.5–3 GHz |
| Parallelism | a few to tens of cores | very high (data-parallel) | very high, any shape | very high, any shape |
| Latency | µs, variable (caches, OS) | µs–ms (batching) | ns, fixed to the cycle | ns, fixed to the cycle |
| Energy per operation | high | medium | low–medium | lowest |
| NRE (first unit) | none | none | low (tools, engineering) | very high (masks: M$) |
| Change after shipping | new software | new software | new bitstream | impossible |
| Development effort | low | medium | high | very high |
The FPGA's clock is ten times slower than a CPU's, because programmable wires and LUTs are slower than custom ones. It wins when the algorithm has enough parallelism to keep thousands of small units busy at once, when latency must be short and exactly predictable, or when it must talk directly to unusual hardware (sensors, ADCs, high-speed serial links) with cycle-level timing that software cannot guarantee.
Against an ASIC (application-specific integrated circuit — a chip designed for one job), the FPGA trades performance and unit price for zero mask cost and the ability to fix bugs after shipping. If the total cost of \(N\) units is a fixed NRE plus a per-unit price \(c\), the two routes cost the same at
The program below plots this break-even with illustrative numbers, and compares the idealised throughput of a 64-tap FIR filter (a weighted sum of the last 64 samples, the subject of Chapter 18) on one CPU core and on FPGA fabric with one multiplier per tap.
Click Run to execute the Python code
Code will be executed with Python 3 on the server
The FPGA bar is only about three times the SIMD core, despite having 64 multipliers, because it runs at a fifth of the clock. But it is one filter; the XC7Z020 has 220 hardware multipliers (Chapter 6), so three such filters fit side by side, and the latency of each sample stays fixed at a few tens of nanoseconds.
6. Where FPGAs are used
- Prototyping chips. ASIC designers run their design on large FPGA boards before paying for masks, often thousands of times faster than simulation.
- Telecommunications and networking. Mobile base stations, routers and “smart” network cards process packets at line rate, and standards change faster than ASICs can follow.
- Instruments and science. Oscilloscopes, software-defined radios, radio telescopes, and the trigger systems of particle-physics detectors, which must decide in microseconds which collisions to keep.
- Aerospace and defence. Low volumes, long lifetimes, and radiation-tolerant parts.
- Finance. Trading systems where shaving a microsecond of latency is worth money.
- Data centres. Accelerators for search, compression, encryption and machine-learning inference.
- Industrial control, video and embedded vision. Motor control, camera pipelines, machine vision — exactly the niche of the Zynq.
- Hobby and education. Retro-computer recreations and courses like this one.
In space, radiation can flip a configuration bit (a single-event upset), silently changing the circuit. A classic defence is triple modular redundancy: build the circuit three times and take a bitwise majority vote, so a single faulty copy is outvoted. The voter is a good first look at the HDL you will write from Part III onward — do not worry about the syntax yet; notice only that it describes a circuit, not a sequence of steps.
// Bitwise 2-out-of-3 majority voter, as used in triple modular redundancy (TMR)
module vote3 #(
parameter WIDTH = 8
) (
input wire [WIDTH-1:0] a,
input wire [WIDTH-1:0] b,
input wire [WIDTH-1:0] c,
output wire [WIDTH-1:0] y
);
// Each output bit is 1 when at least two of the three copies say 1
assign y = (a & b) | (a & c) | (b & c);
endmoduleEach output bit depends on exactly three inputs, so the synthesiser maps each bit to one look-up table: eight LUTs for the default width of 8. A testbench (Chapter 10) applies all 4,096 combinations of three 4-bit inputs and compares against a direct count of ones; both languages print PASS: 4096 input combinations, 0 errors.
`timescale 1ns / 1ps
module vote3_tb;
reg [3:0] a, b, c;
wire [3:0] y;
reg [3:0] expected;
integer i, k, ones, errors;
vote3 #(.WIDTH(4)) dut (.a(a), .b(b), .c(c), .y(y));
initial begin
errors = 0;
for (i = 0; i < 4096; i = i + 1) begin // every combination of 3 x 4 bits
{a, b, c} = i;
#1;
for (k = 0; k < 4; k = k + 1) begin
ones = a[k] + b[k] + c[k];
expected[k] = (ones >= 2);
end
if (y !== expected) errors = errors + 1;
end
if (errors == 0)
$display("PASS: 4096 input combinations, 0 errors");
else
$display("FAIL: %0d errors", errors);
$finish;
end
endmodule7. Meet the Zynq-7020 on the PYNQ-Z2
The chip on your board, the XC7Z020-1CLG400C, is not a plain FPGA. It belongs to the Zynq-7000 family, a system-on-chip (SoC) that combines two worlds on one die:
- the processing system (PS): a dual-core ARM Cortex-A9 (650 MHz on this board) with caches, a DDR3 memory controller (512 MB on the board), USB, Ethernet, SD card and UART controllers. This is a complete computer; the PYNQ image runs Linux and Jupyter on it.
- the programmable logic (PL): an FPGA fabric of the Xilinx 7-series (similar to an Artix-7) with 53,200 LUTs, 106,400 flip-flops, 140 block RAMs of 36 Kb and 220 DSP48E1 multiply–accumulate slices.
The part number itself is a small data sheet:
| Field | Meaning |
|---|---|
| XC | Xilinx commercial product |
| 7Z020 | Zynq-7000 family, device 020 |
| -1 | speed grade: -1 is the slowest of the grades (-1, -2, -3) |
| CLG400 | package: 400-ball chip-scale BGA |
| C | commercial temperature range, 0 °C to 85 °C junction |
Parts II to VI use only the PL: you design a circuit, load it through JTAG, and watch LEDs and pins. Part VII brings the PS in, connecting your circuits to software through the AXI bus. Chapters 5 and 6 now open up the PL and look at what those 53,200 LUTs and 220 DSP slices actually are.
- Find the large square chip in the middle of the board and read its marking: it should say
XC7Z020andCLG400. - Locate the boot-mode jumper. JTAG is used when Vivado programs the PL directly (Part V); SD boots the PYNQ Linux image from the micro-SD card (Part VII).
- Find the 125 MHz clock path (it reaches the PL on pin H16), the four green LEDs LD0–LD3, the four push-buttons BTN0–BTN3 and the two slide switches. They are the first things your circuits will touch, in Chapter 14.
- Note the micro-USB connector marked PROG/UART: one cable gives power, JTAG programming and a serial console — the serial console belongs to the ARM side, not the PL.
LUTs (6-input) 53,200 -> Chapter 5 Flip-flops 106,400 -> Chapter 5 Block RAM (36 Kb) 140 -> Chapter 6 (4.9 Mb total) DSP48E1 slices 220 -> Chapter 6 Processor (PS) 2 x Cortex-A9 -> Chapter 6 (intro), Part VII
8. When is an FPGA the right tool?
A short checklist, in rough order of importance:
- Is there parallelism or streaming? Data that flows continuously (samples, pixels, packets) through a fixed sequence of operations is ideal. Branchy, pointer-chasing code is not.
- Do you need deterministic timing? Nanosecond-exact responses, precise pulse generation, or custom interfaces point to an FPGA.
- Is the volume moderate and the specification still moving? Then an ASIC is too expensive and too rigid.
- Is a CPU or GPU fast enough? If so, use it: software is far cheaper to write, debug and maintain.
Practice Problems
vote3 majority voter. If each copy independently gives a wrong output bit with probability \(p\), what is the probability that the voted bit is wrong? Evaluate for \(p = 10^{-3}\). What assumption does this rely on?