← Back to blogComputer memory

RAM vs ROM: The Essential Difference (with Circuits)

Compare RAM, ROM, SRAM, DRAM, EEPROM, and Flash—then build a 16×8 teaching memory from registers, a decoder, and a read multiplexer.

DennyDenny
10 min read
Chalkboard feature illustration for “RAM vs ROM: The Essential Difference (with Circuits)”

TL;DR: In an introductory computer, RAM is writable working storage and ROM supplies fixed instructions or constants. Physical technology adds important nuance: SRAM and DRAM are usually volatile, while mask ROM, EEPROM, and Flash retain data without power; nonvolatile RAM also exists. A register bank in a simulator can reproduce the logical address/read/write behavior of memory, but it is not a transistor-level model of SRAM, DRAM, or Flash.

“RAM versus ROM” is often taught as:

  • RAM: read/write and volatile
  • ROM: read-only and nonvolatile

That distinction is useful for a small CPU, but the acronyms do not define one pair of physical circuits. RAM describes direct addressable access; ROM describes a read-only or read-mostly role. Real systems contain several cell technologies, interfaces, and programming models under those broad names.

This article separates three layers:

  1. the logical interface seen by a CPU or teaching circuit
  2. the array organization used to select stored bits
  3. the physical cell technology that retains each bit

Keeping those layers distinct explains why a register bank, SRAM cache, DDR memory module, and Flash chip can all store bits while behaving very differently.

RAM vs ROM at the System Level

PropertyWorking RAM in a typical computerROM or nonvolatile program storage
Normal operationfrequent reads and writesfrequent reads; writes absent, restricted, or slower
Power removedSRAM and DRAM lose datamask ROM, EEPROM, and Flash retain data
Common roleactive code/data, stack, heap, buffers, cacheboot firmware, device configuration, program image, constants
Update granularitycommonly bytes, words, cache lines, or burststechnology-specific; programming and erase units may differ
Write endurancedetermined by device and use conditionsdetermined by technology, device, and programming conditions
Interfaceregister-like, on-chip array, memory bus, or DDR protocolparallel, memory-mapped, serial, or internal controller

Two caveats matter:

Volatility is common, not part of the word “RAM.” Battery-backed SRAM, MRAM, FRAM, resistive memories, and other NVRAM technologies provide random access while retaining data.

“ROM” is a family and a role. Mask ROM truly cannot be rewritten after manufacture. PROM is programmed once. EPROM, EEPROM, and Flash are reprogrammable under specific procedures, even though they are historically grouped with ROM.

For a simple DigiSim CPU, the distinction is intentionally cleaner: the RAM component is writable storage, while ROM supplies fixed contents.

The Logical Memory Interface

A small synchronous memory may expose:

  • an aa-bit address input
  • a ww-bit write-data input
  • a ww-bit read-data output
  • write enable
  • clock
  • optional chip enable or output enable

The capacity is:

2a words×w bits per word2^a \text{ words} \times w \text{ bits per word}

A memory with four address bits and eight data bits stores:

24×8=16×8=128 bits2^4 \times 8 = 16 \times 8 = 128\ \text{bits}

This interface does not reveal how the bits are stored. The implementation might be:

  • a set of flip-flop registers
  • an FPGA block RAM
  • an SRAM macro
  • a DRAM subsystem behind a controller
  • ROM synthesized from logic
  • Flash behind a memory controller

The read may be combinational or clocked. A write may occur on an edge or through a device-specific command. “Address in, data out” is an abstraction, not one universal timing protocol.

A Teaching Memory from Registers

A clear 16×8 teaching memory can be built from:

  1. sixteen 8-bit registers
  2. a 4-to-16 decoder for write selection
  3. an 8-bit-wide 16-to-1 multiplexer for reading
  4. shared address, data, clock, and write-enable signals

Conceptually:

address[3:0] ──► write decoder ──► one load-enable per register
       │
       └────────► read multiplexer select

write_data[7:0] ────────────────► all register data inputs
clock ──────────────────────────► all register clock inputs

sixteen register outputs ───────► read multiplexer ──► read_data[7:0]

For register ii:

loadi=write_enable∧(address=i)load_i = write\_enable \land (address = i)

On the active clock edge, only the selected register loads write_data; all others hold. The read multiplexer selects the output of the addressed register.

This is a register-file-style logical model. It is excellent for learning address decode, write selection, and read selection. It should not be called an SRAM cell array: flip-flops and SRAM bit cells have different transistor structures, port organizations, area, timing, and implementation flows.

SRAM: Static, Volatile Storage

A conventional CMOS 6T SRAM cell contains:

  • two cross-coupled inverters that hold complementary internal values
  • two access transistors controlled by a word line
  • a pair of complementary bit lines used for read and write

“Static” means the cell does not require periodic refresh while valid power remains applied. It does not mean nonvolatile: remove power and the stored state is lost.

During a read, bit lines are prepared, the word line connects the cell, and a sense amplifier detects the resulting differential signal. During a write, write drivers force the bit lines strongly enough to establish the new cell state. Cell sizing, read stability, write ability, noise margin, and peripheral circuitry are part of real SRAM design.

Six-transistor cells are common, but they are not the only SRAM topology. Extra-transistor cells can add read ports, improve stability, or serve specialized voltage and performance goals.

SRAM is widely used for on-chip caches, scratchpads, and some memory structures where low latency or high bandwidth justifies its area and leakage cost. Processor register files may use custom multiported cells, latches, or synthesized registers; describing every register file as ordinary cache SRAM would be inaccurate.

DRAM: Charge, Sensing, and Refresh

A conventional 1T1C DRAM cell uses one access transistor and one storage capacitor. The stored charge represents the bit.

The charge leaks, so the memory must periodically refresh its rows. Reading also relies on detecting a small charge-sharing effect; the sense amplifier resolves the value and restores a full level. That restore operation is why DRAM reads are commonly described as destructive at the cell level even though the external requester receives an ordinary read result.

Modern DRAM is organized into banks, rows, and columns. A simplified access sequence is:

  1. activate a row into local sense amplifiers or a row buffer
  2. read or write selected columns
  3. precharge the bank so another row can be activated
  4. schedule required refresh operations

This is much richer than a flat asynchronous address → data box. DDR devices transfer commands and data on a timed interface, and a memory controller manages scheduling, refresh, bank state, bursts, and signal timing.

DRAM usually provides greater density per stored bit than conventional SRAM because the cell is simpler. The actual latency, bandwidth, power, retention, and density depend on the device generation and operating conditions; fixed nanosecond or “times denser” numbers should come from the selected datasheet, not a universal table.

Robert Dennard’s foundational field-effect transistor memory patent describes the one-transistor/one-capacitor principle behind the classic DRAM cell.

ROM and Programmable Nonvolatile Memory

Mask ROM

Mask ROM encodes contents through manufacturing choices. There is no in-system programming path. It can be attractive for stable, high-volume data because the bit pattern is part of the manufactured array, but it carries fabrication and update constraints.

PROM

One-time-programmable memory changes fusible or antifuse-like elements to encode data. Exact erased polarity and programming mechanism depend on the device; “all ones, then blow selected bits to zero” is one implementation convention, not the definition.

EPROM

Classic EPROM uses floating-gate devices programmed electrically and erased with ultraviolet light, typically through a quartz package window. Erasure affects a large region or the complete array rather than an individual byte.

EEPROM

EEPROM supports electrical erase and programming with finer granularity than bulk-erased EPROM. Some devices expose byte-level operations; internal page buffers and programming rules remain device-specific.

Flash

Flash is electrically erasable nonvolatile memory optimized around larger arrays and grouped erase operations. A critical distinction is:

  • read granularity
  • program granularity
  • erase granularity

They need not be equal. One device may program words or pages but erase larger pages, sectors, or blocks. Programming typically changes cells in one direction from the erased state; returning them requires an erase of the containing unit.

Therefore, “Flash writes require erasing the entire block first” is directionally useful but incomplete. Some updates can program still-erased bits without an immediate erase, while rewriting arbitrary existing data requires an erase-and-preserve strategy for unaffected contents. Controllers and Flash-aware filesystems handle wear leveling, error correction, bad blocks, and update granularity.

Never copy a generic endurance or retention number into a design. Both depend on the exact part, temperature, programming history, error-correction assumptions, and vendor qualification. Use the device datasheet.

Microchip’s documentation provides a concrete example in which Flash page programming uses a page buffer and a defined erase/write sequence. Other devices use different granularities, which is precisely why the programming manual matters.

Word Lines, Bit Lines, and Decoders

Many semiconductor arrays organize cells by rows and columns:

                  column / bit-line circuitry
                         │   │   │   │
address ─► row decode ─► cell cell cell cell
                         cell cell cell cell
                         cell cell cell cell

A word line selects a row or group of cells. Bit lines connect columns to read-sense or write circuitry. Address decoding determines which region is active.

That picture is a useful common abstraction for SRAM, DRAM, and several ROM structures, but the electrical operation differs:

  • SRAM often uses complementary bit-line pairs and nondestructive cell retention
  • DRAM senses stored charge and restores the activated row
  • ROM encodes whether a selected path conducts
  • Flash uses floating-gate or charge-trap behavior and high-voltage program/erase circuitry

Large memories also use hierarchical row and column decoding, banking, redundancy, error correction, predecode, and local/global data lines. They do not implement a monolithic nn-input decoder feeding 2n2^n long wires.

Worked Example: 16×8 Register Memory

Let addresses range from 0x0 through 0xF.

AddressSelected word
0000 (0x0)word 0
0001 (0x1)word 1
0010 (0x2)word 2
⋮\vdots⋮\vdots
1111 (0xF)word 15

Assume a synchronous write and combinational read:

  1. Set address = 0x9.
  2. Set write_data = 0xA3.
  3. Assert write_enable with adequate setup time.
  4. Apply the active clock edge.
  5. Deassert write_enable.
  6. Read address 0x9; the multiplexer should return 0xA3.

Then verify isolation:

  • writing word 9 does not alter word 8 or word 10
  • changing address without a write does not alter any stored word
  • reset behavior matches the design; do not assume memory contents clear unless implemented
  • simultaneous read/write behavior at the same address follows a stated policy

Real synchronous RAM primitives often document same-address read-during-write behavior as “old data,” “new data,” “no change,” or device-dependent. A testbench must match the selected primitive rather than inventing a universal result.

The Basic RAM Memory System and RAM with Address Control templates let you inspect the logical interface. The ROM Memory Demonstration Circuit provides a fixed-content comparison. Treat each as an educational model of data flow.

Endianness Is Above the Bit Cell

Suppose a byte-addressed memory stores the 16-bit value 0x1234 starting at address 0x0:

Byte orderAddress 0x0Address 0x1
Big-endian0x120x34
Little-endian0x340x12

The physical byte cells do not know whether they hold the most- or least-significant part of a larger value. Byte order is defined by the processor architecture, data format, peripheral, or protocol that maps multibyte values to byte addresses.

x86 uses little-endian byte order. Arm architectures can support configurable byte order depending on profile and implementation; software must follow the active execution environment rather than assume one universal Arm mode. Network and file formats define their own external order.

The dedicated endianness guide covers byte layout, portable C inspection, and conversion boundaries.

Common Design Mistakes

Treating the names as complete specifications

“RAM,” “ROM,” and “Flash” do not specify latency, bus protocol, port count, endurance, reset value, or read-during-write behavior. The component or device specification does.

Modeling DRAM as a flat zero-latency array

That abstraction can be appropriate for functional logic simulation, but it cannot answer performance questions involving activation, row locality, refresh, banks, or controller scheduling.

Treating Flash like byte-writable RAM

An apparently small update may require buffering data, erasing a larger region, programming it again, and verifying the result. Power loss during that sequence can corrupt state unless the update protocol is designed for recovery.

Assuming reset clears memory

Some register models reset every bit; many RAM macros do not. Clearing a physical memory may require an initialization file, configuration support, or a controller that writes every address after reset.

Confusing logical and physical timing

A functional memory model verifies addressing and data flow. Hardware closure requires the target primitive’s setup, hold, clock-to-output, access, protocol, and routing analysis.

Choosing the Right Memory

Ask:

  1. Must data survive power loss?
  2. How often is it written?
  3. What read latency and bandwidth are required?
  4. What capacity and physical area are available?
  5. What write and erase granularity can software tolerate?
  6. What retention and endurance does the environment require?
  7. Is the interface random-access, burst, serial, or controller-managed?
  8. What happens on reset or power failure?
  9. Are error detection and correction required?
  10. Which implementation primitive is supported by the target device?

Those answers select a memory technology more reliably than the two-column RAM/ROM classroom distinction.

Continue Learning

Build the 16×8 register memory first because every selection signal is visible. Then replace the bank with DigiSim’s RAM component and verify that the external cycle-level behavior matches your specification. Compare it with ROM, where writes are absent from the educational interface.

Next, follow a stored instruction through the fetch-decode-execute cycle, or study how the program counter supplies the address used for instruction fetch.

Apply the concept in a simulator model.