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.

Key idea: computing in space instead of in time
A processor computes in time: one small arithmetic unit is reused, step after step, following instructions. An FPGA computes in space: every operation in your algorithm gets its own piece of hardware, and they all work at once on every clock edge. Ten additions in your design are ten adders, side by side.

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.
aabbccP1P2P3P4××××××P4: every fuse intact, so P4 contains a AND NOT a = 0 (unused term)y1y2programmable AND planefixed OR gates
A PAL computes sums of products. Each dot is a programmable connection: here output y1 = a·b̄ + ā·c and y2 = b·c. The AND plane is programmable; each OR gate always takes the same fixed set of product terms.

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.

CLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsCLBLUTs + flip-flopsIOBIOBIOBlogic blockswitch boxrouting wiresI/O blockone routed netreal devices: tens of thousands of blocks, and far more wires per channel than drawn
The island-style FPGA architecture introduced with the XC2064 and still used today: logic blocks (CLB) in a grid, routing channels between them, switch boxes at the crossings, and I/O blocks (IOB) around the edge. Highlighted: one routed connection, from a CLB output to another CLB input, through two switch boxes.

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.

0ba=001ba=011ba=100ba=11MUXa, bySRAM cells = truth tablewire Awire B1SRAM config bitpass transistor: bit = 1 → A and B joined
Configuration bits at work. Left: four SRAM bits hold the truth table of a 2-input LUT (here XOR: 0,1,1,0), and the inputs simply select one of them. Right: one SRAM bit drives the gate of a pass transistor; when it holds 1, wire A is connected to wire B.

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.

TechnologyReprogrammable?Keeps config without power?Typical use
SRAM (Xilinx, Altera, Lattice ECP…)yes, unlimitedno — reload at power-upmainstream FPGAs, highest density
Non-volatile: flash / SONOS (Microchip PolarFire, Lattice MachXO…)yes, many timesyes — instant-onlow power, CPLD replacement
Antifuse (Microchip RTAX…)no, one-timeyesradiation-hard space hardware
Common mistake: thinking the bitstream is like a program binary
A CPU executable is a list of instructions; you can disassemble it into steps. A bitstream is a configuration: a snapshot of millions of switch settings, with no order of execution at all. Its format is largely undocumented, so you cannot sensibly edit it by hand. To change the circuit you change the HDL and rebuild.

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.

CPUGPUFPGAASIC
How it computesinstructions, in timethousands of threads, same instructioncustom circuit, in spacecustom circuit, in space
Clock (typical)2–5 GHz1–2 GHz100–500 MHz0.5–3 GHz
Parallelisma few to tens of coresvery high (data-parallel)very high, any shapevery high, any shape
Latencyµs, variable (caches, OS)µs–ms (batching)ns, fixed to the cyclens, fixed to the cycle
Energy per operationhighmediumlow–mediumlowest
NRE (first unit)nonenonelow (tools, engineering)very high (masks: M$)
Change after shippingnew softwarenew softwarenew bitstreamimpossible
Development effortlowmediumhighvery 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

\[ \text{NRE}_\text{ASIC} + N^{*} c_\text{ASIC} \;=\; \text{NRE}_\text{FPGA} + N^{*} c_\text{FPGA} \quad\Longrightarrow\quad N^{*} = \frac{\text{NRE}_\text{ASIC} - \text{NRE}_\text{FPGA}}{c_\text{FPGA} - c_\text{ASIC}} \]

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.

Python
script.py63 lines

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.

vote3 — a 2-out-of-3 majority voter for triple modular redundancy
// 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);
endmodule

Each 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.

Exhaustive self-checking testbench for vote3
`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
endmodule

7. 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:

FieldMeaning
XCXilinx commercial product
7Z020Zynq-7000 family, device 020
-1speed grade: -1 is the slowest of the grades (-1, -2, -3)
CLG400package: 400-ball chip-scale BGA
Ccommercial 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.

On the board: identifying the parts of the PYNQ-Z2
  1. Find the large square chip in the middle of the board and read its marking: it should say XC7Z020 and CLG400.
  2. 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).
  3. 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.
  4. 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.
Resources of the XC7Z020 programmable logic
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:

  1. 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.
  2. Do you need deterministic timing? Nanosecond-exact responses, precise pulse generation, or custom interfaces point to an FPGA.
  3. Is the volume moderate and the specification still moving? Then an ASIC is too expensive and too rigid.
  4. Is a CPU or GPU fast enough? If so, use it: software is far cheaper to write, debug and maintain.
Key idea: the Zynq gives you both
Most real systems need both kinds of computing: flexible software for control, files, networking and user interfaces, and dedicated hardware for the few tight loops that matter. The Zynq puts them on one chip. This course teaches the hardware half from the ground up, then joins it to the software half.

Practice Problems

Progress: 0/5 (0%)
1
⭐ Easy
A 4-input look-up table stores one output bit for every possible input combination. How many configuration bits does it need? How many for a 6-input LUT?
2
⭐ Easy
A product needs a custom chip. The ASIC route costs 3 million dollars up front and 5 dollars per chip; the FPGA route costs 100,000 dollars up front and 40 dollars per chip. Above what volume is the ASIC cheaper?
3
⭐⭐ Medium
The configuration bitstream of the XC7Z020 is about 32 Mbit. How long does it take to load over JTAG with a 15 MHz test clock (one bit per clock)? Why do SRAM FPGAs need this step at every power-up while a CPLD does not?
4
⭐⭐ Medium
An FPGA processes a video stream through a 12-stage pipeline clocked at 125 MHz, accepting one pixel per clock. (a) What is the latency from a pixel entering to its result leaving? (b) What is the throughput? (c) A CPU handles the same pixel in 400 instructions at 1 GHz with one instruction per cycle; what are its latency and throughput per core?
5
⭐⭐⭐ Hard
In space, a particle can flip a configuration bit (a single-event upset). A designer triplicates a circuit and adds the 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?

Problem Set Statistics

Total Problems
5
Attempted
0
Completion
0%
Share:XRedditLinkedIn
Rate this chapter: