Skip to content

Computer Architecture

How a register holds a value until it's told to load

A register is memory that keeps its value until it's told to change. A D flip-flop alone copies its input on every clock tick, so it forgets each tick. Put a picker, a two-input multiplexer, in front of its D input, controlled by a LOAD line: with LOAD at 1 the tick takes the new input; with LOAD at 0 the tick takes the flip-flop's own output back, and the value stays put.

The picker on D

D = (IN AND LOAD) OR (Q AND NOT LOAD)

That's five parts per bit: the flip-flop, two ANDs, an OR and a NOT.

  • LOAD = 1: the IN gate is open, the keep gate is shut. D = IN, and the tick loads it.
  • LOAD = 0: the IN gate is shut, the keep gate is open. D = Q, and the tick reloads what's already there.

The clock goes to the flip-flop untouched, every time. The register ticks on every edge; LOAD only decides what it ticks in.

Tick by tick

TickLOADINQ after
1111
2001, kept
3100

On tick 2 the input changed and the register ignored it. That's its whole job: hold a number steady while the wires around it carry other things.

Live experiment

Load, hold, load

IN and LOAD are switches, a picker sits in front of the flip-flop's D, and Tick is the clock. Load a 1, then set IN to 0 and tick with LOAD off: Q keeps its 1. Then load the 0. The strip below records IN, LOAD and Q at every tick.

Try it yourself: free lesson

“Hold it until told” is lesson 4 of 6 in Register Reef, Computer Architecture World 1. Free with an account. Lessons unlock in order, so you’ll do the 3 before it first.

From one bit to a byte

Put eight of these side by side, sharing one LOAD and one clock, and you have an 8-bit register: a byte that loads all at once and holds all at once. A processor has dozens of registers, 64 bits wide in a modern one, sitting right beside its arithmetic unit. The instruction being run decides which register's LOAD goes high on the next tick, and that's how a result gets written to one register while every other register keeps its value.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Hold it until told” is lesson 4 of 6 in Register Reef, Computer Architecture World 1. Free with an account. Lessons unlock in order, so you’ll do the 3 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3Feed IN straight to D, no picker. The register…
    Show the answer

    Answer: Loads IN on every tick: it can't hold anything while IN changes. A bare flip-flop copies D every tick. Without the picker there's no way to say keep what you have.

    • Why not “Holds forever”? It only holds if D is fed its own Q. Fed IN, it changes whenever IN does.
    • Why not “Never loads”? A bare flip-flop loads on every tick. The trouble is that it can't stop.
    • Why not “Works the same”? Without the picker there's no keep path, so the flip-flop copies IN on every tick whatever LOAD says.
  2. Question 2 of 3Q is 1. You set IN to 0 and LOAD to 0, then tick three times. Q is…
    Show the answer

    Answer: 1: with LOAD at 0 every tick reloads Q's own 1. LOAD 0 shuts the IN gate and opens the keep path, so D is Q's own 1. Each tick copies that 1 back. IN can say what it likes.

    • Why not “Whatever D was before”? D is worked out fresh each tick, and with LOAD at 0 it's Q's own 1.
    • Why not “0: IN is 0”? IN only reaches D when LOAD is 1. With LOAD at 0 the register ignores it.
    • Why not “It toggles 0, 1, 0”? Toggling needs Q̄ fed back. Here D gets Q itself, so each tick copies the same 1.
  3. Question 3 of 3The clock input of the flip-flop comes from…
    Show the answer

    Answer: CLK1, straight. The register ticks with the clock every time. LOAD doesn't gate the clock; it gates what D sees. Gating the clock is a classic way to make a flaky circuit.

    • Why not “LOAD”? LOAD chooses what D sees. Driving the clock from LOAD would tick the register whenever LOAD changed, not with the system clock.
    • Why not “The OR”? The OR's output is D, the data. The clock pin needs the clock.
    • Why not “IN”? IN is data. On the clock pin, every change of IN would tick the register.
Keep practising: free lesson

“Hold it until told” is lesson 4 of 6 in Register Reef, Computer Architecture World 1. Free with an account. Lessons unlock in order, so you’ll do the 3 before it first.

Questions people ask

What is the difference between a register and a flip-flop?

A flip-flop stores one bit and copies its input on every clock edge. A register is a row of flip-flops, one per bit, sharing a clock and usually a load enable, so a whole number is stored together and only changes when it's told to.

Why not just switch the clock off to make a register hold?

Gating the clock with ordinary logic is risky: the gate delays the clock, so some flip-flops tick later than others, and a change in the enable at the wrong moment makes a short glitch that can tick a flip-flop by accident. Chips that do gate clocks, to save power, use special cells designed for it.

Is load enable the same as clock enable?

Yes, in practice. Data sheets often call it clock enable or CE even though the clock itself runs untouched: the enable picks whether the flip-flop reloads its own value or takes the new one. The 74HC377, an 8-bit register, works this way.

Every topic