1. What Is a Logic Gate?
Every digital device — your phone, a calculator, a laptop processor — makes decisions using tiny circuits called logic gates. A logic gate is an electronic switch built from a few transistors. It looks at its input signals, applies a simple rule such as "are both inputs high?", and sets its output high or low accordingly.
Billions of these gates, wired together in patterns, can add numbers, store data, compare values and run programs. Understanding gates is therefore the first step in digital electronics and in computer architecture.
Three Things to Know About Any Gate
1. Symbol — the standard drawing used in circuit diagrams. 2. Truth table — a table listing the output for every possible input combination. 3. Boolean expression — the algebraic equation describing the gate, such as Y = A·B.
Figure 1: A logic gate takes binary inputs and produces one binary output according to a fixed rule.
2. Binary Logic and Boolean Algebra
Logic gates work with binary values — just two states. In positive logic, logic 1 (TRUE / HIGH) is the higher voltage (for example about 5 V or 3.3 V) and logic 0 (FALSE / LOW) is the lower voltage (close to 0 V). Everything a computer stores, including text, is encoded as patterns of 0s and 1s — for example the ASCII code for the letter "A" is 65, which is 01000001 in binary.
| Logic Level | Boolean Value | Voltage (typical) | Also Called |
|---|---|---|---|
| Logic 1 | TRUE | High (≈ 3.3 V – 5 V) | HIGH, ON |
| Logic 0 | FALSE | Low (≈ 0 V) | LOW, OFF |
Who Was George Boole?
The mathematics behind logic gates is Boolean algebra, named after the English mathematician George Boole (1815–1864). In his 1854 book An Investigation of the Laws of Thought he showed that logical reasoning could be written as algebra using only two values. In 1937, Claude Shannon demonstrated in his master's thesis that Boolean algebra could describe electrical switching circuits — the idea that turned Boole's mathematics into modern digital electronics.
Boolean Operators and Notation
| Operation | Symbol | Written As | Read As |
|---|---|---|---|
| AND | · (dot) | A·B or AB | "A and B" |
| OR | + (plus) | A + B | "A or B" |
| NOT | ′ (prime) or bar | A′ or A | "not A" |
| XOR | ⊕ | A ⊕ B | "A exclusive-or B" (the XOR symbol) |
| XNOR | ⊙ | A ⊙ B | "A xnor B" |
3. Basic Logic Gates: AND, OR, NOT
The three basic logic gates are AND, OR and NOT. Every other gate, and every digital circuit, can be built from these three.
AND Gate
Output is 1 only if all inputs are 1.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR Gate
Output is 1 if at least one input is 1.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT Gate (Inverter)
Output is the opposite of the single input.
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
Think of AND as Series Switches
Two switches in series: the lamp lights only when switch A and switch B are both closed.
Think of OR as Parallel Switches
Two switches in parallel: the lamp lights when switch A or switch B (or both) is closed.
Think of NOT as a Flip
A NOT gate flips the signal. It is the only common gate with a single input.
4. NAND, NOR, XOR and XNOR Gates
The remaining four gates are the NAND and NOR gates (an AND or OR followed by a NOT, which makes them universal) and the XOR and XNOR gates (the "exclusive" gates, which detect whether inputs differ or match). The small circle (bubble) on a symbol's output means inversion.
NAND Gate
NOT-AND. Output is 0 only if all inputs are 1.
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR Gate
NOT-OR. Output is 1 only if all inputs are 0.
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
XOR Gate
Exclusive-OR. Output is 1 when the inputs are different.
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XNOR Gate
Exclusive-NOR. Output is 1 when the inputs are the same.
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
XOR as a Difference Detector
An XOR gate answers the question "are these two bits different?". That is why it is the heart of binary adders (the sum bit of 1 + 0 is 1, but 1 + 1 gives sum 0 with a carry) and of parity checkers and comparators. The XNOR gate is simply XOR followed by a NOT.
5. All Logic Gates Table (Quick Reference)
This cheat-sheet puts every gate's symbol type, Boolean expression and output pattern in one place. The output column lists Y for inputs AB = 00, 01, 10, 11 in that order.
| Gate | Type | Boolean Expression | Output Y for AB = 00, 01, 10, 11 | Output is 1 when… |
|---|---|---|---|---|
| AND | Basic | A · B | 0, 0, 0, 1 | all inputs are 1 |
| OR | Basic | A + B | 0, 1, 1, 1 | any input is 1 |
| NOT | Basic | A′ | (one input) 0→1, 1→0 | the input is 0 |
| NAND | Universal | (A · B)′ | 1, 1, 1, 0 | not all inputs are 1 |
| NOR | Universal | (A + B)′ | 1, 0, 0, 0 | all inputs are 0 |
| XOR | Exclusive | A ⊕ B | 0, 1, 1, 0 | inputs differ |
| XNOR | Exclusive | (A ⊕ B)′ | 1, 0, 0, 1 | inputs are the same |
Figure 2: The seven logic gate symbols (ANSI/IEEE distinctive shapes) grouped by type.
6. How Many Logic Gates Are There?
The standard answer is seven: AND, OR, NOT, NAND, NOR, XOR and XNOR. Some textbooks also include the buffer (a gate whose output equals its input, used to strengthen a signal) as an eighth.
3 Basic Gates
AND, OR, NOT — the fundamental operations of Boolean algebra.
2 Universal Gates
NAND, NOR — either one alone can build every other gate.
2 Exclusive Gates
XOR, XNOR — detect whether inputs differ or match.
Why Are There "Only" 7?
A gate with two inputs has four possible input combinations (00, 01, 10, 11). Each can give output 0 or 1, so there are 2⁴ = 16 possible two-input Boolean functions. Most of them are not useful as standalone gates (for example "always 0" or "always 1"), and the others can be built from the seven standard gates. Gates can also have more than two inputs, such as a 3-input AND or a 4-input NAND.
7. Logic Gates Calculator (Interactive Truth Table)
Use this tool to test any gate. Choose a gate, switch the inputs between 0 and 1, and watch the output and the highlighted row of the truth table update.
Logic Gate Calculator
Click the A and B buttons to toggle each input between 0 and 1.
8. Universal Gates: NAND and NOR
Universal gates are gates that can be combined to build any other gate or Boolean function. NAND and NOR are universal. Because a factory can then make a chip from just one type of gate, NAND and NOR dominate real integrated circuits (flash memory is even named after the NAND structure).
Figure 3: NOT, AND and OR gates built using only NAND gates (in each circuit, a NAND with its inputs tied together acts as an inverter).
| Gate Wanted | Built from NAND Only | Built from NOR Only |
|---|---|---|
| NOT | Tie both NAND inputs together | Tie both NOR inputs together |
| AND | NAND followed by a NAND-inverter (2 gates) | Invert both inputs with NORs, then NOR them (3 gates) |
| OR | Invert both inputs with NANDs, then NAND them (3 gates) | NOR followed by a NOR-inverter (2 gates) |
9. De Morgan's Theorem
De Morgan's theorem, named after the British mathematician Augustus De Morgan, gives two rules that let you convert between AND-type and OR-type expressions by moving a NOT across the operation. They explain why NAND and NOR gates work.
De Morgan's Laws
"Break the bar, change the sign": break the overline, then swap AND with OR (or OR with AND)
| A | B | (A·B)′ (NAND) | A′ + B′ | (A+B)′ (NOR) | A′ · B′ |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 |
What the Table Proves
Columns 3 and 4 are identical, and columns 5 and 6 are identical, which verifies both laws for every input combination. In circuit terms: a NAND gate equals an OR gate with inverted inputs, and a NOR gate equals an AND gate with inverted inputs.
Useful Boolean Identities
| Law | AND Form | OR Form |
|---|---|---|
| Identity | A · 1 = A | A + 0 = A |
| Null (Domination) | A · 0 = 0 | A + 1 = 1 |
| Idempotent | A · A = A | A + A = A |
| Complement | A · A′ = 0 | A + A′ = 1 |
| Commutative | A · B = B · A | A + B = B + A |
| Distributive | A · (B + C) = AB + AC | A + BC = (A + B)(A + C) |
| Double negation | (A′)′ = A | |
10. Logic Circuits: Half Adder, Full Adder and Multiplexer
Joining gates together gives a combinational logic circuit, whose output depends only on its present inputs. Three classic examples are the half adder, full adder and multiplexer.
10.1 Half Adder (Binary Adder)
A half adder adds two single bits, A and B, and gives a Sum and a Carry. It needs one XOR gate (for the sum) and one AND gate (for the carry).
Half Adder Equations
Figure 4: A half adder uses an XOR gate for the sum bit and an AND gate for the carry bit.
| A | B | Sum (S) | Carry (C) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
10.2 Full Adder
A half adder cannot accept a carry from a previous stage. A full adder adds three bits — A, B and a carry-in (Cin) — and produces a sum and a carry-out. It can be built from two half adders and an OR gate. Chaining full adders adds multi-bit binary numbers.
Full Adder Equations
Figure 5: Full adder block diagram. Half adder 1 adds A and B; half adder 2 adds the carry-in; an OR gate combines the two carry outputs into the final carry-out.
| A | B | Cin | Sum (S) | Carry-out (Cout) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
10.3 Multiplexer (Data Selector)
A multiplexer (MUX) selects one of several data inputs and forwards it to a single output, under the control of select lines. A 2-to-1 multiplexer has two data inputs (I₀, I₁), one select line (S) and one output Y.
2-to-1 Multiplexer
If S = 0, Y = I₀. If S = 1, Y = I₁. It is built from two AND gates, one NOT gate and one OR gate.
| Select S | Output Y |
|---|---|
| 0 | I₀ |
| 1 | I₁ |
11. Simplifying with a Karnaugh Map
Real circuits use as few gates as possible. A Karnaugh map (K-map) is a grid that lays out a truth table so that adjacent cells differ in only one variable. Grouping the 1s into rectangles of size 1, 2, 4, 8… (powers of two) lets you read off a simplified Boolean expression without algebra.
Figure 6: Two groups of two 1s: the blue group (B column) simplifies to B and the red group (A row) simplifies to A, so F = A + B.
K-Map Rules in One Glance
Groups must be rectangles of 1, 2, 4, 8 or 16 cells; make groups as large as possible; groups may overlap; and the map wraps around its edges. Within a group, keep the variables that do not change and drop the ones that do.
12. Logic Gate ICs and Simulators
Logic Gate ICs
Gates are sold as integrated circuits (ICs) that contain several identical gates in one package. The two common families are the TTL 74xx series and the CMOS 4000 series.
| Gate | TTL IC | CMOS IC | Gates per Chip |
|---|---|---|---|
| AND | 7408 | CD4081 | 4 × 2-input |
| OR | 7432 | CD4071 | 4 × 2-input |
| NOT | 7404 | CD4069 | 6 inverters |
| NAND | 7400 | CD4011 | 4 × 2-input |
| NOR | 7402 | CD4001 | 4 × 2-input |
| XOR | 7486 | CD4070 | 4 × 2-input |
| XNOR | 74266 (open-collector) | CD4077 | 4 × 2-input |
Logic Gate Simulators
You do not need hardware to explore gates. A logic gate simulator or logic circuit simulator lets you drag gates onto a canvas, wire them and toggle inputs while watching outputs. Options include:
- Browser-based gate simulators — quick drag-and-drop circuits with live outputs, ideal for homework and practice.
- Logisim — free desktop software for designing and testing digital logic, up to full processors.
- Proteus — professional circuit design and simulation software that models real gate ICs such as the 7400 series.
- Minecraft logic gates — in Minecraft, redstone circuits implement real gates: a redstone torch acts as a NOT gate, and torches and dust combine to give OR, AND, NAND and more.
13. Applications of Logic Gates
Microprocessors & ALUs
The arithmetic logic unit adds, subtracts and compares using adders and gate networks.
Memory
Latches and flip-flops built from NAND or NOR gates store one bit each; millions form RAM.
Arithmetic Circuits
Half adders, full adders, comparators and multipliers are all gate combinations.
Data Selection
Multiplexers and decoders route data and select memory locations.
Security & Alarms
An alarm can be an AND of "door open" and "system armed"; digital locks compare entered and stored codes with XNOR gates.
Control Systems
Traffic-light controllers, washing-machine logic and industrial interlocks apply gate logic to sensor signals.
Logic Gates in 8 Points
- A logic gate turns binary inputs into one binary output by a fixed rule
- 7 standard gates: AND, OR, NOT, NAND, NOR, XOR, XNOR
- AND = all 1s; OR = any 1; NOT = invert; XOR = inputs differ
- NAND and NOR are universal: each can build every other gate
- De Morgan: (A·B)′ = A′ + B′ and (A+B)′ = A′·B′
- Half adder: S = A ⊕ B, C = A·B
- Full adder: S = A ⊕ B ⊕ Cin, built from two half adders and an OR gate
- K-maps simplify Boolean expressions by grouping 1s
Frequently Asked Questions (FAQ)
A logic gate is a basic building block of digital circuits that takes one or more binary inputs (0 or 1) and produces a single binary output according to a fixed logical rule. Logic gates are built from transistors and are the foundation of every digital device, from calculators to computer processors.
There are 7 standard logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR. AND, OR and NOT are the three basic gates; NAND and NOR are the universal gates; XOR and XNOR are the exclusive gates. Some textbooks also count the buffer as an eighth gate. In theory, a gate with two inputs can implement 16 different Boolean functions.
The basic logic gates are AND, OR and NOT. An AND gate outputs 1 only when all inputs are 1. An OR gate outputs 1 when at least one input is 1. A NOT gate (inverter) outputs the opposite of its single input. Every other gate can be built by combining these three.
Universal gates are gates from which any other logic gate or Boolean function can be built. NAND and NOR are universal because each can be combined to form NOT, AND and OR gates. For example, joining both inputs of a NAND gate together makes a NOT gate, and a NAND gate followed by that NOT gate makes an AND gate. Because of this, whole digital systems can be built from a single type of gate.
An XOR (exclusive OR) gate outputs 1 only when its two inputs are different. The truth table is: 0,0 gives 0; 0,1 gives 1; 1,0 gives 1; 1,1 gives 0. The Boolean expression is Y = A ⊕ B = A′B + AB′. The XNOR gate is its complement and outputs 1 when the inputs are the same.
De Morgan's theorem gives two rules for complementing logical expressions: the complement of a product equals the sum of the complements, (A·B)′ = A′ + B′, and the complement of a sum equals the product of the complements, (A+B)′ = A′·B′. In circuit terms, a NAND gate is equivalent to an OR gate with inverted inputs, and a NOR gate is equivalent to an AND gate with inverted inputs.
A half adder adds two single bits and produces a sum and a carry; it uses one XOR gate and one AND gate. A full adder adds three bits (two inputs plus a carry-in from a previous stage) and produces a sum and a carry-out; it can be built from two half adders and an OR gate. Full adders are chained together to add multi-bit binary numbers.
Boolean logic is named after George Boole (1815–1864), an English mathematician who described an algebra of true and false values in his 1854 book An Investigation of the Laws of Thought. In 1937 Claude Shannon showed in his master's thesis that Boolean algebra could be used to design switching circuits, which became the basis of digital electronics.
Logic gates are used in virtually every digital system: the arithmetic logic unit and control logic of microprocessors, memory cells, adders and comparators, multiplexers and decoders, digital locks and alarms, traffic light controllers, and counters and timers in everyday electronics.