What is a logic gate?

A logic gate is an electronic component that takes one or more binary inputs and produces a single binary output based on a fixed logical rule. In real hardware, these are built from transistors โ€” but you don't need to understand transistors to reason about logic. You only need to understand the rule each gate follows.

Key idea: Gates don't store information โ€” they transform it. Given inputs, they instantly produce an output. Combine millions of them and you get a processor.

Interactive Gate Explorer

Select a gate and toggle the inputs to see the output in real time.

0
0
โ†’
๐Ÿ’ก
0

All Seven Gates

โˆง

AND Gate

Y = A ยท B

Output is 1 only when all inputs are 1. Like two switches in series โ€” both must be closed.

ABY
000
010
100
111
โˆจ

OR Gate

Y = A + B

Output is 1 when at least one input is 1. Like two switches in parallel.

ABY
000
011
101
111
ยฌ

NOT Gate

Y = ฤ€

Inverts a single input. If input is 1, output is 0 โ€” and vice versa. Also called an inverter.

AY
01
10
โŠ•

XOR Gate

Y = A โŠ• B

Output is 1 when inputs are different. The workhorse of arithmetic circuits and error detection.

ABY
000
011
101
110
โ†‘

NAND Gate

Y = ยฌ(A ยท B)

NOT + AND. Output is 0 only when both inputs are 1. Universal gate โ€” any circuit can be built from NANDs alone.

ABY
001
011
101
110
โ†“

NOR Gate

Y = ยฌ(A + B)

NOT + OR. Output is 1 only when both inputs are 0. Also a universal gate.

ABY
001
010
100
110
โŠ™

XNOR Gate

Y = ยฌ(A โŠ• B)

Output is 1 when inputs are the same. Used for equality comparison โ€” is A equal to B?

ABY
001
010
100
111

Universal Gates

NAND and NOR are called universal gates because any Boolean function โ€” and therefore any digital circuit โ€” can be implemented using only one of them. This matters enormously in chip manufacturing, because producing just one type of gate simplifies fabrication.

Building AND from NAND:

Connect two inputs to a NAND gate, then invert the output with another NAND (used as a NOT): NOT(NOT(A ยท B)) = A ยท B

Combining Gates

Real circuits are built by chaining gates together. The output of one gate feeds the input of another. Consider this expression: Y = (A AND B) OR (NOT C)

Logitosaur tip: Always trace gates left-to-right, inputs to output. Never skip a step when building or reading a circuit diagram.