Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

ROM vs RAM: read-only memory and random-access memory compared

RAM (random-access memory) and ROM (read-only memory) are the two basic kinds of memory in a computer. RAM is the working memory: the processor reads and writes it constantly, it is fast, and it is volatile, so it loses its contents when the power goes off. ROM is non-volatile: it keeps its contents without power and holds what must survive a restart, such as the firmware that starts a computer. The names are partly historical: ROM is also randomly addressable, and many modern ROM types (EEPROM and flash) can be rewritten, only more slowly and less often than RAM. In one line: RAM is for what the computer is working on now; ROM is for what it must still know after the power has been off.

What each one is good at

RAM is good at speed and rewriting: every running program and its data live there, and the processor writes it as often as it likes. It comes as static RAM (SRAM), fast cells built from cross-coupled transistors used for caches, and dynamic RAM (DRAM), denser cells that store a bit as charge on a capacitor and must be refreshed, used for main memory; our SRAM vs DRAM lesson explains why both exist. ROM is good at permanence: mask ROM is fixed when the chip is made, PROM is written once, EPROM is erased with ultraviolet light, EEPROM is erased electrically, and flash is a kind of EEPROM erased in blocks, which is what SSDs and memory cards use.

Both, live in digiwleea

In digiwleea's course you build RAM yourself: registers made from flip-flops, an address decoder that selects one cell, a write that stores the data bus into it and a read that drives it back onto the bus through a tri-state buffer, as the RAM lesson explains; the live register file works the same way. ROM shows up as logic: the ROM and PLA lesson treats a ROM as a truth table you can address, and the microprogrammed control unit reads its control signals from a control memory, one word per step. For the bigger picture, see the memory hierarchy.

ROM and RAM side by side

RAMROM
Keeps data without powerNo (volatile)Yes (non-volatile)
WrittenConstantly, fastRarely: once, or slowly in blocks
Typical contentsRunning programs and their dataFirmware, boot code, fixed tables
KindsSRAM, DRAMMask ROM, PROM, EPROM, EEPROM, flash
SpeedFast (SRAM fastest)Slower to write; reads vary by type

No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.

More comparisons: Digital logic concepts compared

See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.

Open the digiwleea lab →

Frequently asked

What is the main difference between RAM and ROM?

RAM is volatile working memory that the processor reads and writes constantly and that loses its contents without power. ROM is non-volatile memory that keeps its contents without power and is read far more often than it is written.

Is ROM volatile or non-volatile?

ROM is non-volatile: it keeps its data when the power is off. RAM is volatile: it loses its data when the power is off.

Can ROM be written?

Some kinds can. Mask ROM is fixed at manufacture and PROM can be written once, but EPROM (erased with ultraviolet light), EEPROM and flash (both erased electrically) can be rewritten, more slowly and fewer times than RAM.

Is flash memory RAM or ROM?

Flash is a non-volatile, electrically erasable memory, a kind of EEPROM, so it belongs on the ROM side even though it can be rewritten. SSDs and USB drives use it.

What is the difference between SRAM and DRAM?

Both are RAM. SRAM keeps each bit in a small latch of transistors, so it is fast and needs no refresh, and is used for caches. DRAM keeps each bit as charge on a capacitor, so it is denser and cheaper but must be refreshed, and is used for main memory.