Module 9 · How RAM Remembers

How can switches remember anything after you let go?

Lesson 9.1 · A Circuit That Remembers

Jenny · Sarah

Press, let go. The light remembers.

Jenny points out that every logic gate the crew has built forgets the moment you change its inputs.

Jenny says memory needs a trick: loop a gate’s output back into its own input, so it keeps itself on.

She wires two gates in a little circle. Sarah presses a button marked Set and the light comes on. She lets go.

The light stays on. She presses Reset and it goes off, and stays off.

The short answer

By looping back on themselves. Two gates wired in a circle hold a bit for as long as there’s power. Latches need power to keep looping. Grandma Ruth’s RAM sticks use a cheaper trick (lesson 9.3), but they forget for the same basic reason: no power, no bit.

Try it yourself

Step through how two gates wired in a loop can hold a bit.

Set buttonReset buttonStored bit
upup0

Two gates, each feeding its output into the other’s input. Right now the stored bit is 0.

Step 1 of 5

What you just did has a name

A latch

A latch, or flip-flop, is a little circuit of gates wired in a loop so it holds one bit: set it and it stays 1, reset it and it stays 0, for as long as the power is on.

Registers and cache are built from circuits like this, and they’re very fast.

Main RAM uses a cheaper trick, a tiny stored charge, which Lesson 9.3 gets to.

A few more things

Feedback is the trick

Every circuit in Modules 4 to 6 ran one way: inputs in, output out. Memory needs a loop, where the output helps hold itself in place.

Why it needs power

The loop keeps itself going with electricity. Cut the power and the loop stops, which is why this kind of memory is volatile.

Eight latches make a byte

Put eight latches side by side and you can store a byte. A register in the processor is a row of latches.

Go deeper

The longer version, if you want it.

The clock again

In a real processor, most latches only change on the tick of the clock from Module 6. That keeps millions of them in step: everything reads, then everything updates together on the next tick.

That’s why the clock matters so much. It’s the drumbeat that tells every bit of memory in the processor when it’s allowed to change.

Quick check

What lets a latch remember a bit after you let go of the button?

Let’s take it slower

Think of two friends who agree: “I’ll keep my hand up as long as you keep yours up.” Once one raises a hand, both stay up, holding each other there, even after whoever started it walks away. To change it, somebody has to step in and pull a hand down. That’s a latch. Two gates holding each other in place.

More examples

1

The push-on, push-off button

A lamp with one button that turns on with a press and off with another press keeps track of its state. Inside is a tiny latch, or something that acts like one.

2

The processor’s registers

The working number and the program counter from Module 6 are rows of latches, updated on every tick.

Back to the question

So how can switches remember?

Show the answer

By looping back on themselves. Two gates wired in a circle hold a bit for as long as there’s power. Latches need power to keep looping. Grandma Ruth’s RAM sticks use a cheaper trick (lesson 9.3), but they forget for the same basic reason: no power, no bit.

More on this: What is RAM, and how much do you need?

One last question

Mark asks how a circuit remembers. Who got it right?

Talk Card

Talk Card · 9.1

A latch is gates wired in a loop so the output holds itself. It stores one bit as long as there’s power. Registers and cache are built from them.

How Computers Work · pettigrewlab.com/learn

Next lesson