Remembering
Cut the power and DRAM forgets: its bits are tiny charges that leak away. Flash is non-volatile: it keeps its bits with no power at all. That is how a phone keeps your photos when its battery dies.
Read-only memory (ROM) is written when the chip is made. In a mask ROM, each bit is set by whether a transistor is built at that spot or left out. It can be read forever, but never changed.
The flash cell
Flash can be rewritten. Each bit is one transistor with an extra gate, the floating gate, sealed in insulating oxide between the control gate and the channel. Electrons placed on it stay trapped, even without power, for years.
To program a cell, the chip puts a high voltage on the control gate. It pulls electrons up from the channel, through the thin oxide, onto the floating gate. This is called tunnelling. When the voltage stops, the electrons are stuck.
Trapped electrons are negative, so they cancel part of the control gate's push. Now the gate needs a higher voltage before the channel opens: the threshold voltage (Vth) has moved up. That shift is the stored bit.
To read, the chip sets the control gate to a read voltage between the low and the high threshold. An empty cell switches on and current flows: it reads 1. This cell holds electrons, so it stays off and reads 0.
Blocks and pages
Electrons can only be pulled off in bulk. Flash erases a whole block at once, for example 64 pages: every cell empties and reads 1. There is no way to erase just one cell.
Writing happens a page at a time, for example 2 KB. Programming can only turn 1s into 0s, so a used page must be erased before it is written again. To change data, the controller writes a fresh page instead.
Each erase wears the thin oxide a little. A simple one-bit-per-cell chip is rated for 100,000 erase cycles; denser chips for far fewer. So the controller spreads writes over all blocks: wear levelling. Block C is least worn, so it goes next.
Real chips
NOR flash wires every cell to its bit line, so any byte can be read quickly: good for code a chip runs straight from flash. NAND chains cells in series strings, packing more bits into less space: good for storage.
NAND flash fills SSDs, USB sticks and phone storage. A small flash chip on a computer's main board holds the firmware that starts it up. All of them keep their data when you switch off.
In detail
;; step 1/11 · volatile volatile memory needs power to hold its bits (SRAM, DRAM) non-volatile memory keeps its bits without power (ROM, flash) In the figure the plug is pulled: the DRAM bits fade to ?, while the flash block keeps every bit. When power returns the DRAM bits stay ?: what they held is gone.
The figure is a teaching model: the block is drawn with 4 pages of 8 cells, the threshold gauge has no units, and the erase counts on the controller are illustrative. Page, block, endurance and retention figures are from Micron's MT29F1G08 SLC NAND datasheet: 64 pages per block, 2048 + 64 bytes per page, 100,000 program/erase cycles and 10 years of data retention. Erased flash reads as all 1s; programming can only turn 1s into 0s (Micron datasheet). Which voltage level means 1 is a convention that this lesson follows.