FPGA / HDL (honorable)

Digital logic & computing · tree view

An FPGA fabric is an array of look-up tables (small memories that compute any function of their inputs) plus flip-flops you wire by writing a hardware description language instead of soldering — Kuphaldt's ROM-as-look-up-table is the exact principle inside every LUT.

Prerequisites

flip-flop symbol
flip-flop
ttl-7400 symbol
ttl-7400
cmos-4000 symbol
cmos-4000
lut-half-adder.svg
lut-half-adder.svg
fpga-clb-lut-ff.svg
fpga-clb-lut-ff.svg

Suppose we had a ROM memory circuit written, or programmed, with certain data, such that the address lines of the ROM served as inputs and the data lines of the ROM served as outputs, generating the characteristic response of a particular logic function.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables source

Such a simple application, with definite outputs for every input, is called a look-up table, because the memory device simply "looks up" what the output(s) should to be for any given combination of inputs states.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables (verbatim, including the book's wording) source

Whereas the half-adder built from gates or relays processes the input bits to arrive at a specific output, the ROM simply remembers what the outputs should be for any given combination of inputs.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables source

the data stored at each address becomes the next storage location that the ROM gets addressed to

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Finite-state machines (ROM + feedback = FSM) source

Software is much easier to change than hardware.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables source
Show alternative explanations

We could even use an EPROM chip which could be re-written at will, giving the ultimate flexibility in function.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables source

Software such as the logic function example can be designed to perform functions that would be extremely difficult to emulate with discrete logic gates (or relays!)

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Look-up tables source

Having 16 addressable memory locations in the ROM, this Finite State Machine would have 16 different stable "states" in which it could latch.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 16 — Finite-state machines source

LUT prediction — an N-input look-up table computes any function of N bits

A 3-input LUT is nothing but an 8 x 1 memory: the three inputs are the address, and the 8 stored configuration bits are the function's truth table. Reprogram the cells and the same silicon computes a different function — no gates touched. Below, the identical LUT is first programmed as XOR-3, then as a majority vote.

To predict the outcome:

  1. Write the desired function's truth table as 8 configuration bits, one per input combination.
  2. At runtime the inputs 000–111 select the addressed cell — the output is whatever was stored there.
  3. Predict by pure table lookup: find the input row, read the stored bit. Verified for XOR-3 and majority(2 of 3) below.
  4. Note the size rule: every added input doubles the LUT's memory (see the sizing table that follows).
inputs_a_b_clut_as_xor3lut_as_majoritynote
00000same hardware, different programming
00110odd parity vs vote
01010
01101two 1s — majority fires
10010
10101
11001
11111both functions active

LUT sizing — inputs vs configuration cells

Because a LUT is a memory, its cost grows as 2^N configuration cells for N inputs. FPGA vendors therefore build 4–6 input LUTs and let the fabric combine several of them for wider functions — the direct descendant of Kuphaldt's "4 x 2 bit ROM (a very small memory!)" half-adder.

To predict the outcome:

  1. Take N = number of LUT inputs.
  2. Configuration cells = 2^N — each input combination owns exactly one stored output bit.
  3. Add 16 for 4 inputs, 64 for 6: the reason modern FPGA LUTs stop around 6 inputs.
  4. Wider functions are decomposed into several LUT stages, costing LUTs and propagation delay.
lut_inputs_nconfiguration_cellsexample
24Kuphaldt's ROM half-adder stores a 2-output table
38XOR-3 or majority as in the table above
416classic FPGA-4 LUT
664modern 6-input LUT fabric
8256Kuphaldt's 256-location 4-bit adder ROM

ROM as half-adder — the book's look-up table, bit for bit

Kuphaldt programs a 4 x 2 bit ROM with the half-adder's truth table: address lines A and B are the addend inputs, data lines carry Σ (sum) and C_out. Prediction: drive each address, read the stored pair, and compare against gate-computed a+b.

To predict the outcome:

  1. Address = the two input bits; data = (Σ, C_out) stored at programming time.
  2. 00 → 00; 01 → 10; 10 → 10; 11 → 01 — sum bit first, carry second.
  3. Cross-check each row against a ⊕ b and a ∧ b: identical.
  4. The lesson: synthesis into LUTs is table storage, not gate wiring — "software (data), not hardware."
address_a_bstored_sumstored_coutgate_check
00000 ⊕ 0 = 0, 0 ∧ 0 = 0
01100 ⊕ 1 = 1, 0 ∧ 1 = 0
10101 ⊕ 0 = 1, 1 ∧ 0 = 0
11011 ⊕ 1 = 0, 1 ∧ 1 = 1 — carry

FPGA vs microcontroller vs ASIC — conceptual verdicts

Neither Kuphaldt nor NEETS covers FPGA fabrics or HDL synthesis — this table is conceptual, flagged as such, and limited to verdicts that follow from the LUT principle above plus the MCU material of the previous lesson.

To predict the outcome:

  1. Hardware definition: an FPGA is programmable logic structure (LUTs + flip-flops, connected by configuration); an MCU is a fixed CPU executing software; an ASIC is the function hard-wired in silicon at manufacture.
  2. Change cost: FPGA — reconfigure the bitstream; MCU — recompile software; ASIC — respin the silicon.
  3. Predict unit cost and performance direction: per-chip price falls from FPGA to MCU to ASIC at volume, while hard-wired silicon is fastest and lowest power.
  4. Apply: prototypes and glue logic → FPGA; control-heavy products → MCU; millions of units of a frozen function → ASIC.
aspectfpgamcuasic
what defines itreconfigurable LUT/flip-flop fabricfixed CPU + on-chip memory running softwarefunction etched into silicon at fab
change a designreprogram bitstream in secondsreflash softwarenew mask set — weeks and $$$
per-unit cost at volumehighestlowlowest
parallelismtrue hardware concurrency — everything runs at oncesequential instruction streamas parallel as designed
best useprototypes, glue logic, custom protocolsembedded control, consumer deviceshigh-volume frozen products

HDL describe-vs-wire — what code means in hardware (conceptual)

Books are thin here: HDL is modern synthesis practice with no coverage in either source, so this table is flagged conceptual. The rule a beginner needs: every Verilog/VHDL statement either describes combinational wiring (a LUT) or a clocked register (a flip-flop).

To predict the outcome:

  1. Continuous assignment (Verilog assign, VHDL concurrent) → pure combinational logic: output follows input like a bundle of wires.
  2. Clock-edge process (always @(posedge clk) / rising_edge(clk)) → register: output changes only on the edge, exactly the D flip-flop from the sequential-logic lesson.
  3. Mixing them up is the classic bug: a signal assigned in one style behaves as a wire, in the other as a register.
  4. After synthesis, both reduce to the same physical menu — LUTs and flip-flops — which is why Kuphaldt's memory-as-logic still explains the fabric.
hdl_constructsynthesizes_tooutput_updatesanalogous_to
assign y = a & b; (or concurrent signal assignment)one LUT — combinational ANDas soon as inputs change (gate delay)wired gate
always @(posedge clk) q <= d; (or clocked process)D flip-flop registeronly on the clock edgeedge-triggered D flip-flop
if/else chains on current state + inputsnext-state logic into a register — an FSMon clock edges, per transition tableFSM design from the counters lesson
case (addr) ... endcase selecting stored valuesROM / LUT contentsaddress change → data out (combinational read)look-up table (this lesson's quotes)

Candidate projects — awaiting review

  • HDLBits problem ladder: work the free interactive Verilog sets from gates through counters and FSMs — each answer is checked against the exact behaviour prediction habit this lesson builds. (https://hdlbits.01xz.net/wiki/Step_one, community)
  • First FPGA program, the Nandland way: write and simulate an LED blinker in both Verilog and VHDL (counter + enable generator), then program a real board — simulation-first is the habit that separates HDL from Arduino-style coding. (https://nandland.com/your-first-verilog-program-an-led-blinker/, community)
  • Classic progression: blink at 1 Hz, then a BCD counter on 7-segment displays, then a traffic-light FSM, then a UART transmitter — the r/FPGA-recommended ladder from first blink to real protocol. (https://www.reddit.com/r/FPGA/comments/uol51n/what_are_some_good_beginner_fpga_projects_what/, community)
  • Nandgame: build AND/OR/XOR from NAND transistors, then memory and a small CPU, level by level — the gate-to-computer path that explains what synthesis is really asking of the fabric. (http://www.nandgame.com/, community)