Memory and processor
Flip-flops and memory
A new problem: remembering
The gates seen so far are combinational: their output depends only on the current inputs, never on the past. But a computer must memorize: retain a result, hold a value while waiting. We therefore need a circuit able to keep a bit even after the input has changed. This is the role of flip-flops.
The idea: loop the output back to the input
The secret of a memory is feedback: the circuit's output is sent back to its input. The circuit then maintains itself in its state, like a switch that stays in the position you put it in.
Flip-flop (stores 1 bit):
write=1, data D --->[ ]---+---> Q (stored bit)
[ ] |
+-----------[ ]<--+
| (feedback loop: the output returns to the input)
state:
write=1 : Q takes the value of D (writing)
write=0 : Q keeps its last value (storing, D is ignored)
From bit to register, from register to memory
A single stored bit is of little use. By placing 8, 32 or 64 flip-flops side by side, you get a register, able to hold a byte or a whole word. By lining up millions of registers and numbering them with an address, you get random-access memory (RAM): a huge set of pigeonholes where each slot has its number.
The clock
In a real processor, writing does not happen at just any time: it is paced by a clock, a signal that ticks at regular intervals (billions of times per second). At each tick, the flip-flops all update their value at the same time, which keeps the circuit synchronized.
Classic pitfall
Don't confuse a combinational circuit (no memory, the output instantly follows the inputs) with a sequential circuit (with memory, the output also depends on the stored state). It is precisely feedback that takes you from one to the other: without a feedback loop, no circuit can remember anything at all.

