A lookup table (LUT) is a tiny memory that stores a truth table. Instead of working out a function with gates, it looks up the stored answer for the current inputs. Change the stored bits and the same hardware turns into a different function.

LUTs are what an FPGA is built from, and that’s the kind of chip the labs run on.

Intuition

A truth table lists the output for every input combination. A LUT is that exact table, stored in memory:

  • A -input LUT has storage cells, one per row of the truth table.
  • The inputs act as an address that selects one cell.
  • The selected cell’s stored bit is the output.
Stored bit
00
01
10
11

To make an AND gate, store . To make an OR gate, store . The wiring stays the same and only the four stored bits change.

How the lookup works

The selection is done with a tree of multiplexers (see Ch 6):

  1. Two multiplexers, both controlled by , each narrow a pair of cells ( and ) down to one.
  2. The last multiplexer, controlled by , picks one of those two.

Each input cuts the number of candidates in half, so inputs pick one of cells.

Why FPGAs use them

A fixed gate like AND can only ever be an AND. A LUT can be any function of its inputs, so one kind of logic block can be loaded with whatever the design needs:

  • A typical FPGA logic block has a LUT with 4 or 5 inputs, often followed by a flip-flop for sequential circuits.
  • Bigger functions are built by connecting several LUTs through the chip’s programmable routing.
  • The stored bits get loaded when the chip is configured, which is why an FPGA loses its design when the power goes off and has to be reloaded each time. See the PLD section in Ch 3.

Worked example

Make a 2-input LUT act as an XNOR, which is 1 when the inputs match. The rows should give , so store 1, 0, 0, 1. To change it to a NAND, store 1, 1, 1, 0 instead.

Common mistakes

  • Thinking a LUT has separate gates inside. It’s stored bits plus a multiplexer tree.
  • Forgetting that the size grows fast. A 5-input LUT needs cells and a 6-input one needs 64.