Part 14 · Electronics and Computing
Microprocessors and Personal Computers
A whole processor on one chip, with memory chips beside it, makes a computer small and cheap enough for one person. How a microprocessor works inside, how memory chips store bits, how buses join the chips, how to build a working 8-bit computer from a handful of chips, how keyboards, screens and storage attach to it, and what an operating system does.
- Difficulty
- ●●●●●
- Time
- A weekend to wire a single-board computer from finished chips; months to write its first programs and operating system; years to design and make your own microprocessor
- Steps from zero
- 69 prerequisites →
The full path from nothing — 69 steps before this one
- Fire
- Cordage and Rope
- Stone Tools
- Finding and Preparing Clay
- Finding and Identifying Ores
- Sulfur
- Writing and Numbers
- Hunting and Trapping
- Basic Woodworking
- The Kiln
- Pottery
- Charcoal
- Arithmetic and Fractions
- Hides and Leather
- Lime
- Bricks
- Salt
- Mercury
- Lye and Potash
- Fermentation
- The Wheel and Axle
- Logic and Binary
- Glass
- Firebrick and Refractories
- Bellows
- Saltpeter
- The Lathe
- Gears
- Glass Fibre and Glass Wool
- Copper Smelting
- Iron (the Bloomery)
- Lead
- Laboratory Glassware
- Sulfuric Acid
- Pumps
- The Waterwheel
- Lenses
- Blacksmithing
- Gold and Silver
- The Blast Furnace and Cast Iron
- Bronze
- Hydrochloric Acid
- The Battery
- The Vacuum Pump
- Magnets
- Steel
- Chimneys, Stoves and Heating
- Bearings and Lubrication
- The Steam Engine
- The Light Bulb
- Copper Wire
- Electrolysis
- Photography
- Hydrogen, Oxygen and Gases
- Centrifugal Pumps and Fans
- Machine Tools
- The Generator
- The Vacuum Tube
- The Electric Arc Furnace
- Ammonia
- Ice and Refrigeration
- Pure Silicon
- Ventilation and Air Conditioning
- Semiconductors and the Transistor
- Clean Rooms
- Integrated Circuits
- Making Microchips
- The Computer
- Programming
- Microprocessors and Personal Computers
Do them roughly in this order. See it on the tech tree →
Why it matters
The The Computer chapter builds a working stored-program machine from 30–40 simple chips. Put all of its processor — registers, adder, program counter, control unit — on one chip, and you have a microprocessor. Add one memory chip, one chip for input and output, and a crystal, and you have a whole computer on a board the size of a book, drawing a few watts. Make it cheap, give it a keyboard and a screen, and it becomes a personal computer: a machine that one farmer, teacher, doctor or engineer can own and use alone.
Between 1971 and 1981 that change put calculation, writing, accounts and design into ordinary hands. Microprocessors also sit inside almost every modern machine — cars, phones, robots, machine tools — where they are called microcontrollers (Microcontrollers).
There are two jobs in this chapter. The first, building a computer from finished chips, is within reach of one careful person in a few weekends. The second, making the microprocessor itself, needs the 10-micrometre chip line of Making Microchips and a design team. Both are described.
How it works
A processor on one chip
An 8-bit microprocessor of the late 1970s contains, on a chip about 4 mm square:
- Registers: an accumulator (A), one or two index registers (X, Y) for stepping through lists, and a status register of flags (zero, negative, carry, overflow).
- ALU: the adder and logic gates of The Relay Computer, 8 bits wide.
- Program counter: 16 bits, so it can reach 65,536 memory cells (64 kilobytes).
- Stack pointer: points to a region of memory used as a stack (Programming) to remember where to return after a subroutine or an interrupt.
- Instruction decoder and control: the table of The Computer, now a grid of transistors on the chip, turning each instruction code into a sequence of control signals.
- Clock and bus drivers: strong transistors at the edges that drive the outside wires.
It has 40 legs in a dual in-line package: 16 address lines, 8 data lines, power (+5 V and ground), the clock, a read/write line, reset, and one or two interrupt lines that let an outside device make the processor stop what it is doing, run a short routine, and go back.
| Chip | Year | Bits | Transistors | Clock |
|---|---|---|---|---|
| Intel 4004 | 1971 | 4 | about 2,300 | 0.74 MHz |
| Intel 8080 | 1974 | 8 | about 4,500 | 2 MHz |
| MOS 6502 | 1975 | 8 | about 3,500 | 1–2 MHz |
| Zilog Z80 | 1976 | 8 | about 8,500 | 2.5–4 MHz |
| Intel 8086 | 1978 | 16 | about 29,000 | 5–10 MHz |
| Motorola 68000 | 1979 | 16/32 | about 68,000 | 8 MHz |
A rebuilding society with a 10 μm line can make chips of the first four kinds. They need no special tricks beyond those in Making Microchips.
Memory chips
A memory chip is a square grid of cells, one bit each, with an address decoder along two sides: half the address bits choose a row, half choose a column. A 64-kilobit chip is a grid of 256 × 256 cells.
| Kind | Cell | Keeps data with power off? | How written | Use |
|---|---|---|---|---|
| Mask ROM | A transistor present or missing at each crossing, fixed by one mask | Yes | When the chip is made | Fixed programs in large numbers |
| PROM | A tiny fuse at each crossing | Yes | Once, by blowing fuses with a pulse of current | Small fixed tables |
| EPROM | A transistor with an extra, buried, insulated gate that holds trapped electrons for decades | Yes | By a high-voltage pulse; erased by strong ultraviolet through a quartz window in the lid | Programs you change now and then |
| Flash | The same, erased electrically in blocks | Yes | In the computer itself | Storage in every modern device |
| Static RAM | A flip-flop of 4–6 transistors | No | Any time, fast | Small fast memory |
| Dynamic RAM | One transistor and one tiny capacitor | No — the charge leaks away in thousandths of a second | Any time; every row must be read and rewritten ("refreshed") every few milliseconds | Large main memory |
For a first computer use static RAM and EPROM: they need no refresh circuits and keep the design simple. Dynamic RAM packs four times as many bits in the same area, which is why every large computer uses it.
Buses and the memory map
Every chip in the computer hangs on the same wires: the address bus (16 lines), the data bus (8 lines) and a few control lines (read/write, clock). Only one chip may drive the data bus at a time. So each memory and input/output chip has a chip select leg; when it is off, the chip's outputs float as if disconnected (they are called three-state outputs). A few gates watch the top address lines and turn on exactly one chip for each address. This is address decoding, and the result is a memory map: a plan of which chip answers at which addresses.
Input and output chips look to the processor just like memory: writing a number to a certain address sets eight output wires; reading another address reads eight input wires. This is why one processor can drive a keyboard, a screen, a printer and a motor with the same two instructions, LOAD and STORE.
What you need
For the single-board computer below:
| Part | Notes |
|---|---|
| Microprocessor | Any 8-bit type; the example uses a 6502-like chip, which starts by reading its first address from the top two cells of memory |
| EPROM | 8–16 kilobytes, for the monitor program |
| Static RAM | 32 kilobytes |
| Input/output chip | Two 8-bit ports (a "versatile interface" or "parallel port" chip); a serial chip if you will use a The Teleprinter or terminal |
| Gates | One chip of four NAND gates for address decoding |
| Crystal | 1–4 MHz, with an oscillator (Quartz Crystals and Frequency Control) |
| Reset | A push button, a 10 kΩ resistor and a 10 μF capacitor, so the processor starts cleanly at power-on |
| Power supply | 5 V within ±5%, 1 A, regulated, from a The Transformer and rectifier or a battery |
| Board | Stripboard or an etched board with sockets (Building Circuits: Boards, Connectors and Cables); a 0.1 μF capacitor at every chip |
| Test gear | A meter, LEDs with resistors on spare pins, a logic probe; an oscilloscope if you have one (Electronic Test Equipment) |
Step by step: the single-board computer
1. Power and clock
Build and test the 5 V supply under load first; a computer on a wrong supply dies at once or fails at random. Then the clock: check it is a clean square wave. Note that some processors (most early n-channel ones) forget their registers if the clock stops or runs below about 100 kHz; CMOS versions can be stopped and stepped one pulse at a time by hand, which is far easier to debug. Choose a CMOS processor if you can.
2. The free-run test
Before any memory exists, prove the processor works. Tie each data line through a 4.7 kΩ resistor to + or −, so the processor always reads the code for "do nothing" (NOP — on a 6502 it is 11101010, EA in hexadecimal). Put LEDs (with resistors) on the top four address lines. Release reset: the processor reads NOP, steps to the next address, reads NOP again, for ever. The address lines count upward in binary: at 1 MHz, the top line A15 blinks about 8 times a second, A14 about 15 times. If they count, the processor, clock and reset all work.
3. Address decoding
The example memory map (16-bit addresses, written in hexadecimal):
| Addresses | A15 A14 | Chip |
|---|---|---|
| 0000–7FFF | 0 – | RAM, 32 KB |
| 8000–BFFF | 1 0 | Input/output chips |
| C000–FFFF | 1 1 | EPROM, 16 KB (holds the start address at FFFC–FFFD) |
RAM's chip select is simply A15 (active when low). The EPROM is selected when A15 and A14 are both 1: one NAND gate. Input/output, when A15 is 1 and A14 is 0: an inverter (a NAND with its inputs joined) and one more NAND. On many processors you must also allow RAM writes only during the second half of each clock cycle, when the address is steady: gate the RAM's write line with the clock.
4. The EPROM programmer
You need to put a first program into the EPROM before the computer can run anything. The EPROM programmer is a board with a socket, 16 address switches, 8 data switches, and a push button that applies the programming pulse (typically 12.5–25 V, as printed on the chip's data sheet or found by careful trial with spare chips — start low) for about 1–50 milliseconds. Set an address, set the byte, press. Read back to check. It is slow — a 200-byte monitor takes an evening — but you only do it until the computer can program EPROMs itself.
Erase an EPROM by putting it, window up, 2–3 cm under a short-wave ultraviolet lamp (a mercury lamp in a quartz tube, without the glass envelope or phosphor of an ordinary fluorescent tube — Arc Lamps, Neon and Fluorescent Lights) for 15–30 minutes. Cover the window with an opaque label afterwards: sunlight erases it slowly.
5. First program: a blinking lamp
Write the start address (C000) into the top cells, and at C000 a loop that writes 1 to an output port, counts down a delay, writes 0, counts down, and jumps back. An LED on that port bit blinks. It is a small program, but if it works, the processor, EPROM, decoding and output chip all work.
6. RAM test
Add a loop that writes a pattern into every RAM cell, reads it back, and turns on an error lamp if any cell is wrong; then the opposite pattern; then each cell's own address. Let it run for an hour.
7. The monitor program
The monitor is the computer's first real program, 256 bytes to 2 KB in the EPROM. It reads characters from a keyboard or serial terminal and understands three commands, typed in hexadecimal:
C000— show the byte at address C000.0300: A9 01 8D 00 80— store those bytes from address 0300 onward.0300 R— run the program at 0300.
With a monitor, you enter, test and change programs from the keyboard instead of burning EPROMs. Add commands to save memory to tape or disk and load it back, and the computer can now build its own tools: an assembler, an EPROM-programming routine, and an interpreter for a simple language such as the one in Programming.
The keyboard
A keyboard for a computer is a grid of switches read by the processor. Its typewriter layout is from The Typewriter; what is new is that the keys only make electrical contact and the computer works out which key it was.
The matrix. Sixty-four keys need only 16 wires: 8 rows × 8 columns, with a switch at each crossing. The columns are held at 1 by resistors (10 kΩ to +5 V). Every 10 milliseconds the processor makes one row 0 at a time and reads the columns: a 0 in any column means the key at that crossing is down. Without diodes, three keys held at the corners of a rectangle make a fourth appear pressed ("ghosting"); a small diode in series with each switch prevents it.
Debouncing. Metal contacts bounce, opening and closing several times in the first 1–5 milliseconds. Accept a key only when it reads the same on two scans 10–20 milliseconds apart. Then look up the row and column in a 64-byte table to get the character code (ASCII, as in The Computer), using a second table when Shift is held.
The switches. In order of difficulty:
- Leaf-spring contacts: two strips of springy brass or phosphor bronze 0.2 mm thick, 25 mm long, held 1 mm apart; the key plunger presses one onto the other. Gold or silver plating on the touching ends keeps them clean for years (Electroplating). A coil spring returns the key.
- Rubber dome: a moulded dome of rubber with a pill of carbon-loaded rubber inside its top. Pressed, it collapses with a click-like feel and the pill bridges two interleaved copper fingers on the circuit board. Cheapest of all once you can mould rubber, and used in most keyboards since the 1980s.
- Membrane: two plastic sheets printed with silver-ink tracks, separated by a third sheet with holes; pressing a spot pushes the tracks together. Thin and sealed against dust and water.
- Reed switches: two nickel–iron reeds sealed in a small glass tube, pulled together by a magnet in the key. Very long life (Magnets).
Sizes. Keys sit 19 mm apart, centre to centre, in each direction; key tops are 12–15 mm across, slightly dished. A key should travel about 3.5–4 mm and need 0.5–0.7 newtons — the weight of 50–70 grams — to press. Each row of keys is offset sideways from the one above by about a quarter and a half key, as on a typewriter. A keyboard frame of plywood or hardwood, with the keys sliding in drilled guide plates, works well.
Good or bad: every press registers exactly once at any typing speed; two or three keys held together give exactly those keys; nothing rattles or sticks.
Screen and storage
The screen is a raster text display (Displays, Printers and Data Storage) whose memory the processor sees as ordinary RAM: 40 characters × 24 lines is 960 bytes. The video circuit reads it 50–60 times a second, looks up each character's 8 × 8 dots in a small ROM, and sends about 6 million dots a second to a Cathode Rays and Television set; processor and display take turns on the bus, each on half of every clock cycle. Later a flat screen replaces the tube. Storage runs from tones on cassette tape through floppy disks to flash chips, always reached through an input/output chip and a program.
The operating system
On a small computer, every program has to talk to the keyboard, screen and disk itself. An operating system collects those routines once and gives every program the same simple way to use them. It has layers:
- Firmware in ROM (the monitor, later called the BIOS): starts the machine and holds routines such as "read a key", "print a character", "read disk block n".
- Booting: at power-on, the ROM reads the first disk block into memory and jumps to it; that block loads the rest of the system.
- A file system: the disk is divided into numbered blocks, typically 512 bytes. A directory lists each file's name, first block and length; a free list records unused blocks.
- A command shell: reads a line such as
COPY ACCOUNTS BACKUPand carries it out. - Multitasking, on larger machines: a timer interrupts every 10–20 milliseconds, and the system saves the running program's registers and switches to another. With hardware that stops one program writing into another's memory, many users can share one computer safely.
A complete operating system for an 8-bit machine fits in 8–16 kilobytes: a few months' work for two or three programmers in the assembly language of Programming. Keep printed listings.
The personal computer
A personal computer is just this: microprocessor, 16–64 KB of memory or more, keyboard, screen, storage, an operating system, and a simple language in ROM so it does something useful the moment it is switched on. Put it in one case with a power supply and a row of expansion sockets (slots wired to the buses), so that anyone can add a printer, a network card or more memory later. What made such machines personal was not new science but price: by 1977 a complete computer cost about as much as a good second-hand car, and a few years later as much as a television.
Making the microprocessor itself
Once you have a 10 μm chip line, the road to your own microprocessor is:
- Bit-slice chips first. Make a 4-bit ALU chip and a 4-bit register chip, each a few hundred transistors. Four of each, side by side, make a 16-bit processor on a board, controlled by a microcode ROM (The Computer). Small chips yield well (Making Microchips) and this teaches the design team.
- Then a 4-bit or 8-bit processor on one chip, 2,000–5,000 transistors, 4–5 mm square. Define the instruction set; draw the block diagram; design every gate; then lay out every transistor and wire. Layout is drawn on gridded plastic film at about 500 times full size, one colour per mask layer: a 4 mm chip becomes a drawing 2 m square. Overlay the layers on a light table and check every spacing rule by hand, twice, by different people.
- Simulate before you make. Write a program on your existing computer that runs every gate of the design, and run real test programs on the simulated chip. It is slow, but a mistake found in simulation costs a day; one found in silicon costs a new mask set and a month.
- Expect several rounds. The first chips will have faults. Probe them, find which gate is wrong, correct the mask, and run again. The 6502's designers, veterans of earlier chips, got theirs very nearly right first time; a new team should plan for three rounds.
How to tell it worked
- Free-run test: address lines count steadily.
- Blink test: the lamp blinks at the rate your delay loop predicts.
- RAM test runs all night without an error.
- Monitor: you can examine and change any memory cell and run a program from the keyboard.
- Keyboard: typing a sentence fast echoes it on the screen exactly, with no doubled or missing letters.
- The system boots from disk, lists its files, copies one, and the copy compares equal to the original.
Note Troubleshooting. Address lines do not count → reset held on, clock missing, or a data line not tied; check power at the processor's own legs. Works for a while, then crashes → supply droops or noise; add capacitors, thicken ground wires. Program runs but RAM data is wrong → writes not gated with the clock, or two chips selected at once; check the decoder with a logic probe while single-stepping. Processor runs off into garbage at start → the start address at the top of the EPROM is wrong or the EPROM is not selected at those addresses. Wrong or repeated key characters → no debounce, or debounce too short; ghost keys → missing diodes. EPROM will not program → wrong voltage or pulse too short; it was not fully erased; check with a blank-check routine first.
Dangers
Danger Mains power supplies and tube screens can kill. The transformer side carries mains voltage; a cathode-ray screen holds thousands of volts for minutes after switch-off. See Wiring and Electrical Safety and Cathode Rays and Television. Build and test the supply first, enclosed, and work on the logic board only with the low-voltage side connected.
Warning Short-wave ultraviolet from an EPROM eraser burns the eyes (like snow blindness) and skin in seconds and you will not feel it until hours later. Put the lamp in a closed box with a switch that turns it off when the lid opens.
- Lead solder fumes and flux smoke: work in moving air; wash hands before eating.
- Static electricity from your body destroys MOS chips without a spark you can feel. Touch the grounded board before handling chips; keep chips in conductive foam or with their legs pressed into aluminium foil.
- Long hours at a keyboard strain wrists, neck and eyes: keep the keyboard at elbow height, the screen at eye level, and stop every hour.
What this unlocks
- The Internet: personal computers joined by Networks and the Internet.
- Robots and Automation and CNC Machines and 3D Printing: microcontrollers running machines.
- Smartphones: a personal computer and a radio in a pocket.
- Flat Screens: LCD and LED Displays, driven by their own controller chips.
- Word processing, spreadsheets, accounts, records, teaching programs, and the digital keeping of this book (Programming).
How it was first done
In 1969 the Japanese calculator maker Busicom asked Intel for a set of custom chips. Ted Hoff proposed a general-purpose processor programmed by ROM instead; Federico Faggin, with Masatoshi Shima and Stanley Mazor, designed and made it, using Faggin's silicon-gate process. The Intel 4004 went on sale in November 1971. The 8-bit 8008 (1972) and 8080 (1974) followed, and Motorola's 6800 (1974). In 1975 Chuck Peddle, Bill Mensch and colleagues at MOS Technology launched the 6502 at 25 dollars, a fraction of its rivals' price, and in 1976 Faggin's new company Zilog launched the Z80. Intel's 1103 (1970) was the first successful dynamic memory chip; Robert Dennard at IBM had invented the one-transistor memory cell in 1966; Dov Frohman at Intel invented the EPROM in 1971, and Fujio Masuoka at Toshiba invented flash memory in the early 1980s.
The Altair 8800 kit, built around the 8080 and programmed by front-panel switches, appeared on a magazine cover in January 1975. Gary Kildall's CP/M (1974) became the first widely used operating system for small computers. In 1977 three ready-made personal computers went on sale — the Apple II, the Commodore PET and the Tandy TRS-80 — and in 1981 IBM's Personal Computer gave the whole class its name. The Xerox Alto of 1973, with its windows and mouse, showed what came next; the Apple Macintosh brought it to the public in 1984.
Source: content/entries/electronics/microprocessors.md