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.
All Seven Gates
AND Gate
Output is 1 only when all inputs are 1. Like two switches in series โ both must be closed.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR Gate
Output is 1 when at least one input is 1. Like two switches in parallel.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT Gate
Inverts a single input. If input is 1, output is 0 โ and vice versa. Also called an inverter.
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
XOR Gate
Output is 1 when inputs are different. The workhorse of arithmetic circuits and error detection.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NAND Gate
NOT + AND. Output is 0 only when both inputs are 1. Universal gate โ any circuit can be built from NANDs alone.
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR Gate
NOT + OR. Output is 1 only when both inputs are 0. Also a universal gate.
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
XNOR Gate
Output is 1 when inputs are the same. Used for equality comparison โ is A equal to B?
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
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)
- First, an AND gate takes A and B โ produces intermediate signal P
- A NOT gate takes C โ produces Q
- An OR gate takes P and Q โ produces final output Y
Logitosaur tip: Always trace gates left-to-right, inputs to output. Never skip a step when building or reading a circuit diagram.