Circuit Logic: AND, OR, NOT and the Basics of Computing
Three gates that built the digital world
Three gates that built the digital world
A logic gate takes one or two inputs (0 or 1) and produces one output. Click the input switches to toggle them and see how each gate responds. Select different gates to compare.
AND: output is 1 only when BOTH inputs are 1.
A truth table lists every possible combination of inputs and the resulting output. For two inputs, there are only 4 combinations. Click each row to highlight it on the gate diagram above.
Click a row to see that input combination.
Connect gates together and you can compute. A half adder adds two single bits. It uses an XOR gate for the sum and an AND gate for the carry. Click the inputs to add binary numbers.
Click the input switches (A and B) to add two bits.
The same gates you just toggled, manufactured at nanometer scale and connected by the billions, form every digital device on Earth.
A basic calculator is a few hundred gates: adders for math, decoders for the display, and control logic for the buttons. The first pocket calculator (1971) had 5,000 transistors.
A single bit of SRAM uses 6 transistors wired as two cross-coupled inverters. Your computer's cache holds millions of these tiny circuits, each remembering one bit.
Apple's M3 chip has 25 billion transistors. Each one is a switch about 3 nanometers wide (15 atoms). Together they execute billions of logic operations per second.
A GPU is thousands of small processors running in parallel. Perfect for applying the same logic to millions of pixels or neural network weights simultaneously.
Claude Shannon proved in 1937 that any mathematical operation can be built from combinations of AND, OR, and NOT gates. He was 21 years old. This insight is the foundation of all digital computing.
You've built computation from the ground up. AND, OR, and NOT gates, combined in layers, create everything from calculators to supercomputers. Every app, game, and AI is logic gates switching on and off billions of times per second.
Computers only understand two states: on (1) and off (0). Every number, letter, image, and sound is encoded as a sequence of 1s and 0s.
AND (both inputs must be 1), OR (either input can be 1), NOT (flips the value). These three gates are functionally complete: any computation is possible.
Connect gate outputs to other gate inputs and you get circuits. A half-adder (adds two bits) is just an AND gate and an XOR gate.
A modern processor has billions of transistors, each acting as a tiny switch. Layers of logic gates process instructions millions of times per second.
Put your new knowledge into practice!