Blog

From Transistor to CPU: How Switches Learned to Count

A single transistor is just a switch. Stack the idea one simple rung at a time and you get logic, arithmetic, memory, and the fetch-decode-execute loop. This is how a CPU works, from one switch to tens of billions.

Tan Kok XinTan Kok XinElectricity Fundamentals
Zoom cascade from a single amber transistor symbol to a logic gate cluster to a vast glowing processor die

A Silicon Annex extra to Cobler's Electricity Fundamentals course: the course's story, continued from electrons into computation.

The power electronics article left the transistor doing an honest day's work: a fast switch, slamming kilowatts on and off thousands of times a second to fake a sine wave for a motor. Useful, muscular, dumb. Now watch the same device do something that should be impossible for a switch. You tap a figure into your phone and the answer is just there before your thumb has lifted. Somewhere in that flat grey rectangle, billions of switches just cooperated to add two numbers and show you the result.

Here is the dormant question about how a CPU works, the one nobody stops to ask because the answer feels like it must be hard. A switch can only do two things: carry current or block it. On or off. How does anything that simple end up counting, remembering a number, and deciding what to do next? The honest surprise is that the whole tower is a ladder of steps, each one almost insultingly simple. No one rung is clever. The stack of them is.

A transistor is just a switch another voltage can flip

Start with the rung we already have. A MOSFET is a switch, but instead of a finger or a coil closing it, a voltage on one tiny terminal (the gate) does the closing. Put voltage on the gate and a conducting path opens between the other two terminals; take it away and the path vanishes. In power work you drive it hard on or hard off to chop current. In computing you do exactly the same thing, only now the point is not the current. The point is that the switch's position, open or shut, stands for something. Call shut a one and open a zero and you have stopped moving power and started storing a fact.

The trick that makes this practical is called CMOS: transistors paired up, one type that switches on with voltage and one that switches on without it, wired so that the pair barely draws any current except at the instant it flips (CMOS basics). That is why a chip with tens of billions of switches does not melt. It only spends energy in the moment of changing its mind.

Wire a couple together and you get a logic gate

Take two of those switches, stack them so the output only goes low when both inputs are high, and you have built a NAND gate: four transistors that answer one small question about their inputs. That is the entire leap from electronics to logic. The gate does not know it is doing arithmetic. It just reports a one or a zero depending on the ones and zeros you feed it.

The reason NAND matters more than the others is that it is universal. Every other logic function you can name (AND, OR, NOT, the lot) can be built out of NAND gates and nothing else (NAND is functionally complete). Tie its inputs together and it becomes an inverter. Chain a few and you get any decision you like. A whole processor could, in principle, be one enormous field of NAND gates. It is the single Lego brick from which the rest is assembled, and it is cheaper and faster to make than its rivals. Its series-wired cell structure is also why the flash memory in your phone is literally named after it.

Gates that can add

Now make the gates do arithmetic, which turns out to be embarrassingly close to how you were taught to add in school. Adding two single bits has only four cases. Zero and zero is zero. Zero and one is one. One and zero is one. One and one is zero, carry one. That last case is the whole of it: sometimes a column overflows and you carry into the next.

A handful of gates wired one way produces the answer bit; a couple more produce the carry bit. That little bundle is a full adder, and to add two eight-bit numbers you simply lay eight of them in a row and let each one's carry spill into the next, exactly as you carry the one across a column of sums by hand. No cleverness has entered the building. It is still just switches answering yes-or-no questions. String enough of them together and the yes-or-no answers happen to spell out sums.

A switch that remembers one bit

Everything so far forgets instantly. Change the inputs and the output changes with them; there is no yesterday. Computing needs memory, and here the ladder does something quietly beautiful. Feed a gate's output back into its own input and the loop can hold itself: once it settles on a one, it keeps telling itself one, and it will sit there remembering that single bit until you deliberately overwrite it. Add a clock, a steady tick that says "update now, and only now," and you have a flip-flop, a one-bit memory that changes only on the beat. A row of flip-flops holding a whole number is a register.

If that self-holding trick sounds familiar, it should. Industry built the same idea out of iron decades before silicon. In a motor control panel, the classic start-stop rung uses a contactor whose own auxiliary contact feeds its coil: press start and the contactor pulls in, and its contact then keeps the coil energised after you let go. It remembers that it was started until someone presses stop. That is a one-bit mechanical memory, a latch made of a relay. The flip-flop is that exact circuit shrunk into transistors and paced by a clock. The control panel in your switchroom and the register in your laptop are cousins.

So how does a CPU work?

Put the pieces on one bench. A clock ticking billions of times a second. Registers holding numbers. An adder (and its friends) to work on them. A counter that remembers which instruction comes next. On every tick the machine does the same tiny loop: fetch the next instruction from memory, decode what it is asking for, execute it by pushing numbers through the adder or moving them between registers, then step the counter on and do it again (the fetch-decode-execute cycle). That heartbeat, repeated a few billion times a second, is the whole engine. Every app, every spreadsheet, every dashboard is that loop running fast enough to look like thought.

The only trick left is doing it a billion times over

Nothing above is modern. The genuinely astonishing part is scale. Intel's 4004, the first commercial microprocessor in 1971, held about 2,300 transistors (IEEE Spectrum). The chip in a current laptop or tablet, such as Apple's M4, holds around 28 billion (transistor count). That is not an improvement. It is roughly a twelve-million-fold multiplication of the same idea in about half a century.

You cannot solder billions of anything. You print them with light. Sand is mostly silicon dioxide; refine it to silicon that is 99.9999999 per cent pure, melt it and pull a single flawless crystal out of the melt, then slice that into mirror-polished wafers (the process). Then, layer by layer, project the circuit pattern onto a light-sensitive coating, etch away what the light touched, dope the silicon underneath, and repeat dozens of times until the transistors and their wiring stand built. The leading edge does this with extreme-ultraviolet light at 13.5 nanometres, made by zapping molten tin droplets into plasma inside machines from ASML, the only company on earth that builds them (EUV). A speck of dust is bigger than a transistor, so it all happens in air filtered cleaner than an operating theatre.

Scale is also why the chip in your pocket is not just a CPU. It is a system on a chip: the processor cores, the graphics engine, the memory controller, the cellular modem, and a neural unit for AI tasks, all printed onto one sliver of silicon so the signals never have to leave home. Putting them on one die is what makes a phone a phone.

Where this lives in your switchroom

Once you see the ladder you cannot unsee it, and it is not confined to consumer gadgets. The smart meter on the incomer, the BMS controller humming in the grey box on the wall, the brain inside every VFD that decides how to shape the waveform feeding a motor: each one is this same tower. Switches flipping other switches, gates deciding, flip-flops remembering, a clock keeping time. The electron drift that opened this course carries kilowatts through the busbars and, in the very same building, carries facts through a billion switches counting in the dark. That was it. That was the whole trick.

Go deeper on video

Reading explains; watching sometimes lands the picture. Full credit to the creators:

"How is the CPU built of transistors" by kimylamp

"How do Smartphone CPUs Work? Inside the System on a Chip" by Branch Education


This is a Silicon Annex extra to Cobler's Electricity Fundamentals course. It follows on from power electronics, where the transistor was a switch for moving power, and shares its memory trick with the self-holding contactor in how to read control wiring diagrams.

Every controller, meter and drive in your plant is a small computer running this loop. CobiNeural reads what they are counting and turns it into energy, demand and power-quality numbers a facility team can act on. If you would rather see your building than trust its black boxes, talk to us.

FAQ

Frequently asked questions

Keep Reading

Related articles