A register file can hold only four numbers. But just opening one phone photo means over 10 million pixels, and each pixel needs numbers for its color. To hold all of them, we need tens of millions of slots.
The register file picked one of four slots with a 2-bit address. The decoder picked the slot to write with WA, and the MUX picked the slot to read with RA. To get more slots, we add address bits.
| Address bits | Slots | Example |
|---|---|---|
| 2 | 4 | Register file |
| 10 | 1,024 | One 32×32 icon |
| 16 | 65,536 | One 256×256 image |
| 24 | About 16.78 M | One 10-megapixel photo |
| 32 | About 4.3 B | 4 GB, the limit of memory for old 32-bit computers |
The image examples assume one pixel fits in one slot. Each extra bit doubles the number of slots, so adding just a few bits quickly gives an enormous number of slots.
A storage device with a huge number of slots, where we pick one slot by its address to read or write, is called memory. The slot number is the address. It does the same job as a register file, just with far more slots.
Then why not make every register as big as memory? The more slots there are, the bigger the circuit that decodes the address and picks a slot, and the longer the wires to each slot, so reading and writing take longer.
On top of that, real memory isn’t built by lining up registers. A register takes dozens of transistors per bit, but memory builds each bit from one transistor and one tiny capacitor that holds charge. Since each slot is so small, a single chip can hold billions of slots, but reading out the charge takes time, and the charge slowly leaks away, so it must be refilled periodically.
So computers keep both. Registers sit inside the CPU, so they can be read and written right away. Memory sits separately outside the CPU, so fetching a value from it takes longer. That’s why only the numbers being computed right now are brought into registers, and the rest stay in memory.
Now we can hold a great many numbers. In the next post, let’s go beyond just remembering values and see how to make new values from the remembered ones, repeating this to produce useful results.
To pick one of more than 1000 slots, at least how many bits must the address have? Answer with a number.