
Digital Logic Gates
The basic building blocks: each gate computes one Boolean operation on its inputs.
Description
Physical circuits that each implement one Boolean function of their inputs. They are the atomic primitives every larger digital circuit is assembled from. Transistors switch to pull the output high or low according to the gate's truth table.
- AND: output 1 only if all inputs are 1.
- OR: output 1 if any input is 1.
- NOT: inverts a single input.
- NAND / NOR: AND/OR followed by inversion — each is universal on its own.
- XOR: 1 when inputs differ (odd parity); XNOR is its inverse.
- Any Boolean function can be built from NAND gates alone (or NOR alone).
- This is why standard-cell libraries lean heavily on NAND/NOR.
- What: Physical circuits that each implement one Boolean function of their inputs.
- Why: They are the atomic primitives every larger digital circuit is assembled from.
- How: Transistors switch to pull the output high or low according to the gate's truth table.
At a glance
What
Physical circuits that each implement one Boolean function of their inputs.
Why
They are the atomic primitives every larger digital circuit is assembled from.
How
Transistors switch to pull the output high or low according to the gate's truth table.
Where
Standard-cell libraries, FPGAs, and every combinational and sequential block.
When
At the lowest design level — gate-level netlists and schematic capture.
Think of it like…
Gates are the LEGO bricks of logic. AND/OR/NOT are special-shaped bricks, but NAND is the one brick you can clip together to rebuild every other shape.
The seven gates
- AND: output 1 only if all inputs are 1.
- OR: output 1 if any input is 1.
- NOT: inverts a single input.
- NAND / NOR: AND/OR followed by inversion — each is universal on its own.
- XOR: 1 when inputs differ (odd parity); XNOR is its inverse.
Universality
- Any Boolean function can be built from NAND gates alone (or NOR alone).
- This is why standard-cell libraries lean heavily on NAND/NOR.
Gate reference
| Gate | Boolean | 2-input output = 1 when | Universal? |
|---|---|---|---|
| AND | A · B | both inputs 1 | no |
| OR | A + B | any input 1 | no |
| NOT | A′ | input is 0 | no |
| NAND | (A · B)′ | not both 1 | yes |
| NOR | (A + B)′ | both 0 | yes |
| XOR | A ⊕ B | inputs differ | no |
| XNOR | (A ⊕ B)′ | inputs equal | no |
Black-box view
Inputs on the left → outputs on the right · particles show signal direction
Logic diagram
Click inputs to toggle · glowing wires carry 1 · particles show signal direction
gate · truth table
▶ live simulatorClick a terminal (A/B) to toggle it · glowing wires carry a logic 1 · the lamp is output Y
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
HDL — Verilog · VHDL · SystemVerilog
module gates(input a, b,
output y_and, y_or, y_xor, y_nand);
assign y_and = a & b;
assign y_or = a | b;
assign y_xor = a ^ b;
assign y_nand = ~(a & b);
endmoduleThe basic gates as continuous-assignment dataflow in all three HDLs.
Real-world applications
The 5 Whys
- 1
Why do we need logic gates? To physically realize Boolean functions.
- 2
Why realize them physically? So computation runs in hardware, not just on paper.
- 3
Why standardize on a few gate types? Reusable cells simplify design and fabrication.
- 4
Why favor NAND/NOR? Each alone is universal, so libraries optimize them heavily.
- 5
Root cause: a small universal gate set lets any logic be built, verified, and mass-produced.
Cheat sheet
Working principle
- Transistors switch to pull the output high or low according to the gate's truth table.
- Physical circuits that each implement one Boolean function of their inputs.
Formulas & Boolean expressions
- AND: Y = A·B
- OR: Y = A + B
- NOT: Y = A′
- NAND: Y = (A·B)′
- NOR: Y = (A + B)′
- XOR: Y = A⊕B = A′B + AB′
- XNOR: Y = (A⊕B)′
Key facts
- AND: output 1 only if all inputs are 1.
- Any Boolean function can be built from NAND gates alone (or NOR alone).
Why it exists
- Root cause: a small universal gate set lets any logic be built, verified, and mass-produced.