Logic Gates and Universal Gates: Complete Beginner's Guide
A logic gate makes one elementary decision: AND outputs 1 only if all inputs are 1, OR if any input is 1, NOT flips its input. With their inverted cousins NAND and NOR and the difference-detectors XOR and XNOR, every digital system on Earth is built. Gates are the atoms; processors are the molecules.
NAND and NOR are "universal": any gate, hence any circuit, can be built from NANDs alone (or NORs alone). Factories exploit this: whole processors are oceans of identical NAND structures, and flash memory is named after the NAND gate.
Key Concepts
- AND / OR / NOT: All, any, flip. The bubble on a symbol always means inversion.
- NAND / NOR: AND/NOR followed by NOT; the universal pair.
- XOR / XNOR: Output 1 when inputs differ / are equal. XOR is the heart of adders.
- Buffer: Output equals input; strengthens weak signals.
- Universal construction: NAND with tied inputs becomes NOT; NAND plus NOT gives AND; NAND of inverted inputs gives OR (De Morgan). NOR mirrors the trick.
- Logic levels: TTL: below 0.8 V is 0, above 2 V is 1. CMOS: roughly bottom/top thirds of supply. Between lies forbidden territory.
- Delay and fan-out: Each gate takes nanoseconds to decide and can drive only limited inputs.
How It Works
- NOT from NAND: Tie both inputs together. NAND(0,0)=1, NAND(1,1)=0. It inverts.
- AND from NAND: Feed a NAND into the NOT-from-NAND above; double inversion leaves AND.
- OR from NAND: A+B = (A'.B')' by De Morgan: invert each input, then NAND.
- XOR from four NANDs: (A NAND (A NAND B)) NAND (B NAND (A NAND B)). With A=1,B=0: inner NAND=1, left=NAND(1,1)=0, right=NAND(0,1)=1, final=NAND(0,1)=1. Correct: 1 xor 0 = 1.
- Proved: NOT, AND, OR, XOR all emerge from NAND alone, so any processor can be built from one repeated gate.
Worked Example
Verify the 4-NAND XOR on all inputs (N = A NAND B). 0,0: N=1, branches NAND(0,1)=1 and 1, out=NAND(1,1)=0. Correct. 0,1: N=1, left=NAND(0,1)=1, right=NAND(1,1)=0, out=NAND(1,0)=1. Correct. 1,0 mirrors to 1. 1,1: N=0, branches both NAND(1,0)=1, out=NAND(1,1)=0. Correct. The full XOR truth table, from NANDs only.
Common Misconceptions
- "NAND is just AND." NAND outputs 0 only for all-ones input, the exact opposite. Mixing them inverts your design.
- "XOR equals OR." They differ when both inputs are 1: OR gives 1, XOR gives 0. That row is why adders use XOR.
- "Floating CMOS input reads 0." It drifts undefined, oscillates, picks up noise and can damage the chip. Tie every unused input to a valid level.
Real-World Applications
- Processors: ALUs and control logic synthesize into NAND/NOR networks.
- NAND flash: SSDs and USB drives store bits in NAND-structured cells.
- Glue logic: 7400-series chips still patch boards together.
- Adders/parity: Full adders are XOR plus AND; parity trees are XOR chains.
Gates are decisions in silicon: AND needs all, OR needs any, NOT flips, XOR spots difference, and NAND/NOR are universal because NOT, AND, OR and XOR all wire up from NANDs alone, as the construction and verified XOR prove. Respect voltage levels, propagation delay and never-floating inputs, and these humble gates scale to the processor you are using now.
Related blogs
- Number Systems and Codes: Complete Beginner's Guide
- Boolean Algebra and Karnaugh Maps: Complete Beginner's Guide
- Combinational Circuits: Multiplexers, Decoders and Encoders
- Sequential Circuits: Flip-Flops and Latches For students.
- Counters and Shift Registers: Complete Beginner's Guide
- Finite State Machines Explained: Complete Beginner's Guide