VITON13School
Free tools of the school

How does a computer work? Bits, transistors, logic gates and the processor explained

A computer works by turning all information into bits, 0 and 1, held as low or high voltage in billions of tiny transistor switches. Logic gates built from transistors, AND, OR and NOT, combine the bits by simple rules to do arithmetic, and the processor repeats one cycle, fetch an instruction, decode it, execute it, billions of times a second. A modern processor holds more than 10 billion transistors and ticks at 3 to 5 GHz, so one tick at 3 GHz lasts about 0.33 nanoseconds.

By , Founder of VITON13 SCHOOL
Microscope photo of the bare silicon die of a Z80-compatible 8-bit microprocessor: dense grey-blue circuitry in rectangular blocks, ringed by square bonding pads

A computer can show a film or play chess, yet underneath it knows only two symbols. Below you will see how bits stand for numbers and letters, how a transistor works as a switch, how three gates can add, what the processor does with each instruction, and how memory differs from storage.

Key ideas

  • All data is bits. Eight bits make a byte with 256 patterns. The binary pattern 1011 is the number 11, and the capital letter A is stored as 65, which is 01000001.
  • A transistor is a switch with no moving parts. Bell Labs built the first one in December 1947, and a modern processor carries more than 10 billion.
  • Three gates, AND, OR and NOT, are enough to build any logical rule, including a half adder that adds two bits and passes a carry.
  • A processor repeats fetch, decode, execute. At 3 GHz one tick lasts about 0.33 ns, and in that time light travels only about 10 centimetres.
  • RAM is fast but forgets when the power goes off, while storage such as flash keeps data without power. The closer to the processor, the faster and smaller the memory.

Two symbols are enough

A bit is the smallest piece of information: 0 or 1, off or on, low or high voltage. Eight bits make a byte, which can hold 256 different patterns. Binary counts like we do, only with two digits instead of ten. The pattern 1011 means 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1 = 11.

Letters, colours and sounds are just agreed patterns. The capital letter A is 01000001, which is 65 in the common ASCII code. Every extra bit doubles the number of patterns: 8 bits give 256, 10 bits give 1,024 and 32 bits give about 4.3 billion. The binary converter on VITON13 SCHOOL lets you flip bits and watch the number change.

[1]

A switch made of silicon

In December 1947 at Bell Labs in New Jersey, John Bardeen and Walter Brattain, in a group led by William Shockley, made the first transistor. The three shared the Nobel Prize in Physics in 1956. A transistor is a switch with no moving parts: a small voltage on one terminal lets current flow between the other two, or blocks it. It replaced vacuum tubes, which were about as big as a thumb, hot and fragile.

The first transistor was handmade and about a centimetre across. Today a single processor holds more than 10 billion, the largest AI chips around 100 billion, and all of them are made at once by printing patterns of light onto a disc of silicon.

Gates are tiny rules

Wire a few transistors together and you get a logic gate. NOT flips its input, so 0 becomes 1. AND answers 1 only when both inputs are 1. OR answers 1 when at least one input is 1. Nothing else is needed: every logical rule in a computer can be built from these three.

Now add two single bits. 0 + 0 = 0, 0 + 1 = 1, and 1 + 1 = 10 in binary, which is a sum bit 0 and a carry bit 1. The carry is simply a AND b. The sum is “one or the other but not both”: (a OR b) AND NOT (a AND b). A few gates give a half adder. Chain several, each handing its carry to the next, and numbers of any length can be added. Subtraction and multiplication are built on top of adding.

The processor: fetch, decode, execute

A CPU, the central processing unit, is gates arranged to fetch an instruction from memory, decode it and carry it out, and then fetch the next one. An instruction is itself a pattern of bits, for example “add the number in register A to the number in register B”. A game or a browser is millions of such instructions, and the processor works through them in order, unless an instruction tells it to jump somewhere else.

The first single-chip microprocessor, in 1971, had 2,300 transistors and ticked at 740 kHz. A modern processor ticks at 3 to 5 GHz. At 3 GHz one tick lasts 1 / 3,000,000,000 s, about 0.33 nanoseconds, and in that time light travels only about 10 centimetres, which is one reason chips must be small. Modern processors also have several cores, copies of the processor that work side by side.

The photo shows the bare silicon die of an 8-bit microprocessor of the Z80 family. The orderly blocks and the busier tangle of logic are all made of transistors and wires, and the small squares round the edge are pads where thin wires connect the chip to the outside.

Memory and storage

The processor wants its data close by. RAM is the working memory: very fast, but it forgets everything when the power goes off. A small, even faster cache sits between the two. Storage, such as the flash chips in a phone or an SSD, keeps data without power by trapping tiny electric charges.

A byte is 8 bits, so a 256 GB phone holds about 256 × 8 = 2,048 billion bits, roughly 2 trillion. The rule of thumb: the closer to the processor, the faster and smaller the memory. Every app you open is this same dance of bits, repeated on a gigantic scale.

How the VJOURNAL SMART BOOK shows it

The chapter “The computer and the chip” in the VJOURNAL SMART BOOK “How it works”, Volume I, has five animated moments: a row of cells glows as bits, a transistor switches, three gates add two numbers, a processor ticks in gigahertz, and memory is told apart from storage. In the animation the gates are little blocks with lights on their wires, and the signals flow from left to right.

Under the picture is a sandbox. Set the input bits yourself, follow the signal through the gates and try all four input pairs of the half adder, reading the sum and the carry. The chapter also has key facts, a three-question quiz with explanations and the sources.

[2][3]

In everyday language

A computer is a huge crowd of light switches wired so that flipping some of them flips others by fixed rules. Do it fast enough, billions of times a second, and the switches add, draw pictures and play music.

Try it yourself

Convert the binary number 1101 to decimal, then add 1011 to it in binary. Check the answer by adding in decimal.

Expected result

1101 = 8 + 4 + 0 + 1 = 13, and 1011 = 11. In binary, 1101 + 1011 = 11000, which is 16 + 8 = 24, equal to 13 + 11.

Check your answer: How many different values can 10 bits hold?

2 to the power 10, which is 1,024 values, counting from 0 to 1,023.

Questions

What does a computer actually do?

It follows instructions: fetch one from memory, decode it, carry it out, repeat. The instructions are simple, such as add two numbers, compare them or jump elsewhere, and everything you see on screen is built from billions of them per second.

Why do computers use binary?

Two states are easy to tell apart reliably. A transistor is either conducting or not, a voltage is either low or high, and a little electrical noise does not turn one into the other. Many-valued signals would be much harder to keep clean.

What is the difference between a CPU and RAM?

The CPU processes data. RAM holds the programs and data that are in use right now, so the CPU can reach them quickly, and it loses its contents when the power is switched off.

How many transistors are in a computer chip?

The first transistor of 1947 was a single one. The 1971 microprocessor had 2,300. A modern processor has more than 10 billion, and the largest AI chips around 100 billion.

What does 3 GHz mean?

A gigahertz is a billion ticks per second, so 3 GHz means about 3 billion ticks every second. One tick lasts about 0.33 nanoseconds, and a processor may do a piece of work in each tick.

Remember three lines: everything is bits, a transistor is a switch, and gates built from transistors can add. Then open the chapter and add two bits yourself in the sandbox.

Sources and further reading

  1. Nobel Prize: Physics 1956, the transistor ↗Sources checked:
  2. Computer History Museum: The Silicon Engine ↗Sources checked:
  3. Computer History Museum: the microprocessor integrates the CPU onto a single chip ↗Sources checked:
  4. Britannica: Transistor ↗Sources checked: