What a CPU does
A 3 GHz processor ticks 3 billion times a second, one tick every third of a nanosecond.
Picture a computer class. (This is a made-up scene.) Sixteen numbered boxes are drawn on the board, each with eight bits written in it. Three students play the CPU. One holds a card marked PC, one a card marked IR, one a card marked ACC. The PC card says 0. The IR student walks to box 0 and copies what is there, 0001 1110, and the PC student changes the card to 1. The class looks up the first four bits in a table on the wall: 0001 means LOAD. The last four, 1110, are 14. So the ACC student goes to box 14 and copies the 7 she finds there. Then the whole thing starts again from box 1.
Box 1 says ADD 15, so ACC becomes 7 + 5 = 12. Box 2 says STORE 13, and the ACC student writes 12 into box 13. Box 3 says HALT, and everyone sits down. Twelve moves in all. None of the three needed to know that the program "adds 7 and 5". Each one followed one small rule. The boxes are the memory, the cards are registers and the table on the wall is the decoder. A real CPU works the same way, billions of times a second, and nobody inside it understands the program either.
The same short loop, billions of times a second
Gates can add, compare and choose, but something has to tell them what to do, in what order and with which numbers. That is the job of the central processing unit, the CPU. It repeats one short loop. The program counter (PC) holds the address of the next instruction. Fetch: the CPU reads the cell the PC points to into the instruction register (IR) and moves the PC on by one. Decode: control circuits look at the opcode bits and set up the right paths, for instance connecting the adder for ADD. Execute: the work is done. A number is loaded, added or stored, or the PC is changed so the program jumps somewhere else. Then the loop starts over. One instruction, JZ, jumps only when the accumulator is zero, and that single kind of jump is what lets a program decide and repeat.
Drag to turn. Scroll or pinch to zoom.
The scene runs the same program the class acted out. Press Step and the PC, IR and ACC change exactly as the cards did: LOAD 14, then ADD 15, STORE 13 and HALT, four instructions of three phases each, twelve phases in all. The multiplication program uses the same few instructions, but its JZ and JUMP send the PC back to 0 twice before the counter in cell 15 reaches zero, so it runs 24 instructions in 72 phases. Six times the instructions of the addition.
The program sits in the same memory as the numbers
On the board, the instructions and the numbers 7 and 5 were in the same row of boxes. That is no accident. In June 1945 John von Neumann wrote the "First Draft of a Report on the EDVAC", describing a computer that keeps its instructions in the same memory as its data, and almost every computer since has worked that way. An instruction is just a number whose bits are split into fields. In this toy computer each cell holds 8 bits. The first four say what to do, the opcode, and the last four say which cell to use, the address. 0001 is LOAD, so 0001 1110 means "LOAD 14": copy the number in cell 14 into the accumulator, the CPU's working register.
How fast the loop goes
The steps keep time with a clock signal, a voltage that flips on and off at a steady rate. A 3 GHz clock ticks 3,000,000,000 times a second, so one tick lasts 1 ÷ 3,000,000,000 seconds, about 0.333 nanoseconds. Light covers only about 10 centimetres in that time. At one phase per tick, that is enough ticks to run the toy's 7 + 5 program 250 million times a second. Real processors don't finish one whole instruction per tick in the simple way our toy does. They overlap the phases of several instructions like an assembly line, which is called pipelining, and today's chips hold several complete processors, called cores, side by side. The toy has none of that, which is exactly why you can follow it by hand.
| Opcode | Name | What it does |
|---|---|---|
| 0000 | HALT | Stop |
| 0001 | LOAD a | ACC = cell a |
| 0010 | ADD a | ACC = ACC + cell a |
| 0011 | SUB a | ACC = ACC − cell a |
| 0100 | STORE a | cell a = ACC |
| 0101 | JUMP a | PC = a |
| 0110 | JZ a | if ACC = 0, PC = a |
- "The PC counts how many instructions have run." The PC holds the address of the next instruction. In the 4 × 3 program it is sent back to 0 twice, while the number of finished instructions keeps climbing to 24.
- "The CPU reads a program the way we read it." It reads 8 bits, splits them into an opcode and an address, and follows fixed wiring for that opcode. Like the students with the cards, it never knows that the program adds 7 and 5.
- "A higher GHz number always means a faster computer." The clock sets how often a step can happen, not how much gets done in each tick. Real chips overlap instruction phases and have several cores, so two chips at the same GHz can finish very different amounts of work.
- Put the phases of the instruction cycle in order.
- The CPU fetches the instruction at address 3. What is the PC right after the fetch?
- In the toy computer, what does 0010 1111 mean?
- ADD 15
- LOAD 15
- STORE 2
- ADD 7
- Write LOAD 14 as 8 bits.
- A clock runs at 3 GHz. How long is one tick, in nanoseconds? (three decimal places)
- How many instructions does the 7 + 5 program run, including HALT?
- Each instruction takes three phases. How many phases does the 7 + 5 program take?
- What does STORE 13 do?
- Copies the accumulator into cell 13
- Copies cell 13 into the accumulator
- Jumps to address 13
- Adds 13 to the accumulator
- Which instruction lets a program repeat a loop until a count reaches zero?
- JZ (jump if zero)
- STORE
- HALT
- LOAD
- In which year did von Neumann write the First Draft of a Report on the EDVAC?
- Programs are stored as numbers in the same memory as data (von Neumann, 1945).
- The CPU repeats fetch, decode, execute; the PC points to the next instruction.
- An instruction's bits split into an opcode and an address.
- The clock sets the pace: 3 GHz is one tick every 0.333 ns.
Sources for this course (9)
- (checked 2026-10-17; reordered 2026-10-19: standards first, then official documentation, then the teaching model and calculations, history sources last)
- Standards: NIST, "Prefixes for binary multiples" (physics.nist.gov/cuu/Units/binary.html: IEC approved kibi, mebi, gibi in December 1998; 1 B = 8 bit; 1 MiB = 1 048 576 B; 1 MB = 1 000 000 B; 1 GiB = 1 073 741 824 B; historical note: memory makers usually mean 2²⁰ bytes by megabyte, storage makers 1 000 000, and the "1.44 MB" diskette uses a megabyte of 1 024 000 bytes)
- IETF RFC 20 "ASCII format for Network Interchange" (1969, 7-bit codes, A = 65, a = 97, 0 = 48)
- IETF RFC 3629 "UTF-8, a transformation format of ISO 10646" (2003: 1 to 4 octets per character, ASCII unchanged, code points up to U+10FFFF, U+0800 to U+FFFF take three octets, "the first octet of a multi-octet sequence indicates the number of octets", example U+D55C U+AD6D U+C5B4 = ED 95 9C EA B5 AD EC 96 B4)
- Official documentation: MDN Web Docs, "<color>" (hexadecimal colour notation #RRGGBB)
- Intel, "Intel Chips" timeline poster (2012: Intel 4004 of 1971 with 2,300 transistors; 2nd generation Core 2010 with 1.16 billion)
- Claude E. Shannon, "A Symbolic Analysis of Relay and Switching Circuits", Transactions of the AIEE vol. 57 (1938)
- abstract of his MIT master's thesis. Computer History Museum, The Silicon Engine, "1947: Invention of the Point-Contact Transistor" (Bardeen and Brattain, December 1947, germanium)
- John von Neumann, "First Draft of a Report on the EDVAC" (30 June 1945, Moore School, reprinted in IEEE Annals of the History of Computing 15:4, 1993).
Checked: 2026-10-17