How Logic Gates Work
A logic gate never decides anything: it is two teams of transistor switches wired so exactly one team is always closed. Four of them make a NAND, and NAND alone can build every computer.
Step 01 of 08
1 · A gate is a part you can hold
This black 14-pin chip is a 74HC00. Inside are four logic gates, and each one answers a yes-or-no question with voltage. Pin 14 sits at +5 V and pin 7 at 0 V. Watch the glowing pins: when both inputs are high, the output pin drops low.
Step 02 of 08
2 · The atom of logic is a switch that nobody flips
Here is one transistor. Put a voltage on its gate plate and an electric field closes the channel beside it, so current flows to the lamp. Take the voltage away and the channel opens. The plate never touches the channel: a voltage is doing the pressing.
Step 03 of 08
3 · Two switches in a row make AND
Wire two of them one after the other and current only reaches the lamp when the first one and the second one are closed. That is AND: both inputs must be 1 before the output is 1. Every other combination leaves the path broken somewhere.
Step 04 of 08
4 · Two switches side by side make OR
Now give the current two routes. Close either switch, or both, and the lamp lights. That is OR. Series and parallel are the only two ways to join switches, so every gate you will ever meet is some mix of these two shapes.
Step 05 of 08
5 · Two teams, and one is always closed
Real gates use two teams. The top team of P-type switches sits in parallel and connects the output up to +VDD. The bottom team of N-type switches sits in series and connects it down to ground. The same inputs drive both, so whenever one team is closed the other is open, and the output is never left floating.
Step 06 of 08
6 · Try every input and write down the answers
Step through all four input pairs and the output traces out the NAND truth table. It answers 1 every time except when both inputs are 1, then it answers 0. The gate does not compare or compute anything. Whichever team closes wins the output.
Step 07 of 08
7 · One gate is enough to build all the others
Tie a NAND's two inputs together and it flips whatever you feed it: that is NOT. Follow a NAND with that NOT and you get AND. NAND alone can rebuild every other gate, which is why a chip maker can lay down billions of the same four-switch cell and get a computer.
Step 08 of 08
8 · Four switches. Multiply by billions.
Sealed back up, it is the same chip: pins flickering between +5 V and 0 V as inputs come and go. A modern processor holds tens of billions of these switches, and each one has only two ways to be.