Electrical Engineering › Section V · Programmable logic and data storage › Topic V.3
Semiconductor memory: RAM, ROM, and flash
Every digital system needs somewhere to keep its data and programs. Semiconductor memories trade speed, density, cost and the ability to survive power loss, and choosing among SRAM, DRAM, ROM and flash starts with knowing how each one stores a bit.
Cells, words and addresses
A semiconductor memory is an array of storage cells, each holding one bit. The cells are grouped into words of a fixed width, often 8, 16, 32 or 64 bits; 8 bits make a byte. Each word has an address, its position in the array. Capacity is written as words × bits per word, so a 1M × 8 memory holds about a million 8-bit words. An address with \(n\) bits selects one of \(2^n\) locations. Here k means \(2^{10} = 1024\) and M means \(2^{20}\); standards bodies write KiB and MiB for these binary units, because kB and MB strictly mean powers of ten.
Reading and writing
A memory connects to the rest of the system through three groups of lines. The address bus carries the location, the data bus carries the word in or out, and control lines such as chip enable, write enable and output enable say what to do. An internal address decoder turns the address into the select signal for one word. To write, the system places an address and a data word on the buses, then pulses write enable. To read, it places an address and asserts output enable, and after the access time the stored word appears on the data bus. Reading does not change the stored data.
Worked example: sizing a memory
A memory chip has 15 address lines and an 8-bit data bus. 1. Locations: \(2^{15} = 32{,}768\), which is 32k. 2. Capacity in bits: \(32{,}768 \times 8 = 262{,}144\) bits, which is 32 KiB. 3. Address range: \(0000_{16}\) to \(7FFF_{16}\), because fifteen 1s are \(7FFF_{16}\). 4. Reverse problem: a 512k × 16 memory needs \(\log_2(524{,}288) = 19\) address lines and holds \(524{,}288 \times 16 = 8{,}388{,}608\) bits, exactly 1 MiB. 5. Check: each extra address line doubles the locations, and \(2^{19} = 2^{15} \times 16\), so the second chip has 16 times the locations of the first.
Static RAM
Random-access memory (RAM) can be read and written at any address in about the same time, and it is volatile: it loses its data when power is removed. Static RAM (SRAM) stores each bit in a latch, typically six transistors forming two cross-coupled inverters, a bistable cell like the gate latches of "Latches and flip-flops". The bit stays as long as power does, with no refresh. SRAM is fast but takes much more silicon per bit than DRAM. Asynchronous SRAM responds directly to its address lines; synchronous burst SRAM is clocked and can deliver several consecutive words from one starting address. Processor caches, the small fast memories on the processor chip, are SRAM.
Dynamic RAM
Dynamic RAM (DRAM) stores each bit as charge on a tiny capacitor reached through a single transistor, so it packs many more bits into a chip than SRAM. The charge leaks away, so every cell must be refreshed, read and rewritten, within a set period: 64 ms for DDR4 and 32 ms for DDR5 at normal temperatures. Reading a cell also disturbs it, so the sensing circuit restores it. To save pins, the address is multiplexed: the row address is sent first and the column address second. Computer main memory is DRAM, today mainly DDR4 and DDR5 modules, with LPDDR in phones and laptops, GDDR on graphics cards and stacked HBM beside AI accelerators. These generations change quickly.
Worked example: DRAM refresh timing
A DDR4-style DRAM bank has 8192 rows, and every row must be refreshed within 64 ms. The controller spreads the work evenly. 1. Refresh commands needed per period: one per row, so 8192. 2. Interval between commands: \(64\,\text{ms} \div 8192 = 7.8125\,\mu\text{s}\), about \(7.8\,\mu\text{s}\). 3. Commands per second: \(8192 \div 0.064\,\text{s} = 128{,}000\). 4. Meaning: each cell is refreshed about 16 times a second, and during each refresh that bank cannot serve reads or writes, a small but real cost in bandwidth. 5. Check: \(7.8125\,\mu\text{s} \times 8192 = 64.0\,\text{ms}\).
ROM and its programmable relatives
Read-only memory (ROM) is nonvolatile: it keeps its data without power, and in normal use it is only read. A mask ROM has its data fixed during manufacture, worth it only in large volumes. A PROM is programmed once by the user, typically by blowing fusible links. An EPROM stores charge on a floating gate and is erased by exposing the chip to ultraviolet light through a quartz window. An EEPROM is erased and rewritten electrically, often one byte at a time, and suits small amounts of settings or calibration data. Each kind is organised like RAM, with an address decoder selecting a stored word.
Worked example: a ROM as a look-up table
Any truth table can be stored in a ROM: the inputs are the address and the outputs are the stored word. Design a ROM that outputs the square of a 3-bit number. 1. Inputs: 3 bits, so \(2^3 = 8\) addresses. 2. Outputs: the largest square is \(7^2 = 49\), which needs 6 bits, so the ROM is 8 × 6. 3. Contents: address \(101_2\) (5) stores \(011001_2\) (25), and address \(111_2\) (7) stores \(110001_2\) (49). 4. Check: \(011001_2 = 16 + 8 + 1 = 25\). The same idea underlies the FPGA look-up tables of "SPLDs, CPLDs, and FPGAs".
Flash memory
Flash memory is nonvolatile, electrically rewritable and very dense, because each cell is a single transistor that stores charge on a floating gate or in a charge-trapping layer. Stored charge shifts the transistor's threshold voltage, and reading senses that shift. Programming adds charge and erasing removes it, but erasing works on a whole block at once. NOR flash allows fast random reads and often holds microcontroller program code. NAND flash is denser and is read and written in pages, which suits solid-state drives, phones, memory cards and USB drives. Cells wear out after a limited number of program and erase cycles, so controllers spread writes evenly, called wear levelling.
More bits per cell, more layers
Modern NAND stores more than one bit per cell by using several charge levels. Storing \(b\) bits needs \(2^b\) distinguishable levels: SLC stores 1 bit with 2 levels, MLC 2 bits with 4, TLC 3 bits with 8 and QLC 4 bits with 16. More levels raise density and cut cost, but the levels sit closer together, so reading is slower and endurance falls. Manufacturers also stack cells vertically in 3D NAND, which passed 300 layers in products by 2025. Together these explain why a phone can now hold hundreds of gigabytes, figures that keep rising.
Common mistakes to avoid
First, calling ROM "non-random": ROM is randomly accessed too; what defines it is that it is read-only in normal use and nonvolatile. Second, thinking DRAM refresh is needed because of reads: leakage alone discharges the capacitors. Third, mixing binary and decimal prefixes: 32k locations means 32,768, not 32,000. Fourth, counting address lines as bits of capacity: n lines give \(2^n\) locations, each as wide as the data bus. Fifth, assuming flash can rewrite one byte in place: it must erase a whole block first.
Key takeaways
A memory is an array of cells grouped into words; n address lines select \(2^n\) words, and capacity is words × bits per word. SRAM stores bits in latches: fast, volatile, no refresh, used for caches. DRAM stores bits as capacitor charge: dense and volatile, refreshed every few tens of milliseconds, with multiplexed row and column addresses. ROM, PROM, EPROM and EEPROM are nonvolatile, and a ROM can serve as a look-up table. Flash stores charge in one transistor per cell, erases by blocks, comes as NOR or NAND, and uses multi-level cells and 3D stacking for density.
Flashcards
Flashcard
Number of words × bits per word
Test your understanding
Question 1 of 5
A memory has 12 address lines and a 16-bit data bus. What is its capacity?
Question 2 of 5
Why must DRAM be refreshed while SRAM need not be?
Question 3 of 5
A DRAM has 16,384 rows that must each be refreshed within 64 ms, evenly spaced. About how often is a refresh command issued?
Question 4 of 5
A ROM is to act as a look-up table with 4 inputs and 5 outputs. What size must it be?
Question 5 of 5
Which statement about NAND flash is correct?
