digiwleeaLearn
Open the lab →

Memory: RAM

Addressable storage on a bus

4 min read

RAM is a bank of registers paired with an address decoder: the address selects one cell, a write stores the data bus into it, and a read drives that cell's value back onto the bus through a tri-state. It is where a program and its data live.

Now we assemble three blocks you already have into memory. RAM (random-access memory) is a set of numbered storage cells: you give it an address, and either write the value on the data bus into that cell or read that cell's value back out. The three ingredients are storage (registers), addressing (a decoder), and shared output (tri-state buffers).

The address picks one cell

Feed the address bits into a decoder. It raises exactly one select line, the one naming the cell you want. That single select line does double duty, gating both the write into that cell and the read out of it, so only the addressed cell ever participates.

Writing: select AND write-enable

Every cell is a register sharing the common data-in bus and the clock. The trick is its write-enable: cell k loads only when its decoder select is high and a global WR line is high. So WE_k = select_k AND WR. With the address steering the decoder, a single clock edge writes the data bus into just the one addressed cell; every other cell holds.
WE_k = select_k WR (only the addressed cell loads on a write)

Reading: one tri-state onto the bus

For reads, every cell's output goes onto a shared DOUT bus through a tri-state buffer, and that buffer's enable is the same decoder select line. Because the decoder raises only one select, only one cell drives the bus; all the others are in high-Z and stay clear. Address in, one cell's byte out, exactly the shared-bus pattern from the tri-state lesson.
Try it
In the lab: address A1 A0 = 10, set DIN = 1, raise WR, and clock once. Then set address 11 and read DOUT, then back to 10 and read again. What do you see, and why?
A 4-word by 1-bit RAM (RAM4): a 2-to-4 decoder picks one of four cells; WR gates the write, and the addressed cell's tri-state drives DOUT on a read. Open it in the lab: set an address and DIN, raise WR and pulse the clock to store, then drop WR and pulse again to read it back. A cell you never wrote reads Z.
This 4 x 1 memory has the entire architecture; only the numbers change for a real one. Widen each cell from one register bit to an 8-bit register and you store a byte per address. Widen the address and decoder and you get more cells. A 16 x 8 RAM is sixteen 8-bit registers, a 4-to-16 decoder, and a byte-wide tri-state bus, wired exactly like this.
Memory holds both the program and its data. With the program counter supplying an address and RAM returning the byte there, the CPU can fetch instructions one after another. The next piece catches that fetched byte and pulls it apart into an operation and an operand: the instruction register.

Frequently asked

What is RAM?

RAM (random-access memory) is a bank of numbered storage cells: you give it an address to select one cell, then either write the value on the data bus into it or read its value back out. It is built from storage cells (each a register) plus a decoder for addressing and tri-state buffers for a shared output bus.

How does an address select a single cell in RAM?

The address bits feed a decoder, which raises exactly one select line, the one naming the wanted cell. That single line does double duty: it gates the write into that cell (WE_k = select_k AND WR) and enables that cell's tri-state onto the read bus, so only the addressed cell ever participates.

Why does reading an unwritten RAM cell give Z?

On a read, only the addressed cell's tri-state drives the shared DOUT bus; every other cell stays in high-impedance (Z). A cell that was never written has nothing meaningful driving it, so reading it shows Z rather than a defined 0 or 1.

What is the difference between RAM and a register?

A register is a single fixed storage location you read and write directly. RAM is *many* such cells behind an address: you must first select a cell by its address, then read or write it. RAM is essentially a bank of registers plus addressing and a shared bus.

Every lesson here builds toward one thing: a working CPU, from the transistor up.

Open the free lab →
Found this useful? Share itShare on X