C745 of 57
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C7 · Lesson 45 · Memory arrays and programmable logic

Organizing memory, and logic you can rewrite after it's built

A memory is a lookup table: give it an address and it returns the word stored there. Turn that around and a lookup table is a circuit: store a function's truth table in a small memory, feed the function's inputs to the address lines, and the memory computes the function. That's exactly what an FPGA does, thousands of times over, with programmable wiring between the tables, so one chip can become any digital circuit you describe. This lesson covers how memories are organized and combined, and how memory becomes logic.

  • A 3-input lookup table, the heart of an FPGA: eight configuration bits K0 to K7 feed an 8-to-1 multiplexer whose select lines are the logic inputs A, B and C.
  • It's configured as 3-input odd parity: K1, K2, K4 and K7 are 1. Flip A, B and C and Y follows A⊕B⊕C.
  • Now change the configuration bits: set only K7 and it becomes a 3-input AND, with no change of wiring.

Predict

A memory chip holds 512K words of 8 bits. How many address lines does it need?

Name it

Organization

A memory of 2n words of m bits has n address lines and m data lines, and stores 2n×m bits. Physically it's a nearly square grid of cells: part of the address drives a row decoder that selects one word line, and the rest drives column multiplexers that pick the wanted bits from the long row, which keeps both the decoder and the lines short.

Building bigger memories

  • Wider words: put chips side by side, sharing the address lines; each supplies some of the data bits.
  • More words: put chips in parallel on the data lines and decode the extra (top) address bits into chip selects, so exactly one chip responds.

The number of chips is (words needed ÷ words per chip) × (width needed ÷ width per chip).

Memory as logic

A 2n×m ROM implements any m functions of n inputs: the address is the input and each data bit is one function's truth table. A PLA (programmable logic array) saves space for sparse functions with a programmable AND plane producing product terms and an OR plane combining them.

FPGAs

An FPGA is a grid of configurable logic blocks, each with a few k-input lookup tables (2k bits of configuration memory driving a 2k:1 multiplexer, typically k = 4 to 6) and flip-flops, surrounded by programmable routing. Functions of more than k inputs are split across several LUTs. FPGAs add block RAMs, multiplier (DSP) blocks and clock managers. Loading a new bitstream changes every LUT and connection: the same chip becomes a different circuit.

Worked example

Build a 64K × 16 memory from 16K × 8 chips.

Show the solution
  1. Width. 168=2 chips side by side.
  2. Depth. 64K16K=4 rows of chips, selected by a 2-to-4 decoder on the top 2 of the 16 address bits.
  3. Total. 8 chips, each seeing the low 14 address bits.

Answer 8 chips, in 4 rows of 2.

Worked example

A 4-input LUT implements a 7-input AND. How many LUTs does it take?

Show the solution
  1. First LUT. One LUT can AND 4 inputs.
  2. Second LUT. A second ANDs its output with the remaining 3.
  3. In general. An n-input AND needs ⌈(n−1)/3⌉ 4-input LUTs.

Answer two LUTs.

Worked example

A full adder is stored in a ROM. How many address and data bits, and how many bits in all? What about a 4-bit adder with carry in?

Show the solution
  1. Full adder. Three inputs (A, B, carry in) address 23 = 8 words, each holding two outputs (sum and carry): 8×2=16bits
  2. 4-bit adder. It has 9 inputs and 5 outputs (four sum bits and a carry out): 29×5=2560bits
  3. Chained full adders. Chaining four full-adder ROMs needs only 64 bits: decomposing a function into small blocks is what keeps lookup-table logic practical.

Answer 3 address bits and 2 data bits, 16 bits in all; a 4-bit adder with carry in needs 2560 bits.

Check

How many address lines does a memory of 2k words need, for k = 16?

Check

A memory holds 64K words of 8 bits. How many kibibytes is that?

Check

How many 32K × 8 chips make a 64K × 16 memory?

Check

How many bits must a ROM store to implement 1 functions of 8 inputs?

Check

How many configuration bits does a 5-input LUT hold?

Check

How many 4-input LUTs does a 19-input AND gate take?

Check

A 2-input LUT's configuration bits are K0 = 0, K1 = 1, K2 = 1, K3 = 0 (selected by AB). What function does it compute?

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

A 64K × 32 memory is built from 64K × 16 chips.

(a)

How many chips?

(b)

How many address bits drive the chip-select decoder?

Check

An n-input, m-output function is built as a ROM, or as an n-input AND from k-input LUTs.

Step 1

How many bits does the ROM need?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

How can a lookup table replace any logic gate network?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.