Logic Gates
Fundamental building blocks of digital circuits: AND, OR, NOT, XOR gates and their truth tables.
Logic Gates Playground
Drag gates, connect them, and observe outputs.
The Building Blocks of the Digital World
At the heart of every digital device-from the simplest calculator to the most powerful supercomputer-lie millions or even billions of tiny electronic switches called logic gates. These are the fundamental building blocks of digital circuits. A logic gate is a device that performs a basic logical function based on . It takes one or more binary inputs (0s and 1s) and produces a single binary output based on a specific rule.
Understanding logic gates is understanding the very language of computers. By combining these simple gates in various ways, engineers can build complex circuits that perform arithmetic, store data, and make decisions.
Fundamental Logic Gates
There are three primary logic gates from which all others can be derived. Let's explore them one by one.
1. The AND Gate
The AND gate is a logical multiplier. Its output is '1' (True) only if all of its inputs are '1'. If any input is '0', the output is '0'. Think of it as a series circuit with two switches: the light bulb only turns on if both switches are closed.
ANSI Symbol for AND gate
Truth Table (A AND B)
| Input A | Input B | Output Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Logical Expression: or
2. The OR Gate
The OR gate is a logical adder. Its output is '1' (True) if any of its inputs are '1'. The output is '0' only when all inputs are '0'. Think of it as a parallel circuit: the light bulb turns on if either switch (or both) is closed.
ANSI Symbol for OR gate
Truth Table (A OR B)
| Input A | Input B | Output Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Logical Expression:
3. The NOT Gate (Inverter)
The NOT gate is the simplest gate. It has only one input and one output. Its function is to invert the input signal. If the input is '1', the output is '0', and if the input is '0', the output is '1'. It simply flips the state.
ANSI Symbol for NOT gate
Truth Table (NOT A)
| Input A | Output Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
Logical Expression: or
Universal Gates: NAND and NOR
While AND, OR, and NOT are fundamental, there are two other gates called "universal gates" because any other logical function can be created by combining only NAND gates, or only NOR gates.
4. The NAND Gate (NOT-AND)
The NAND gate is simply an AND gate followed by a NOT gate. Its output is '0' only if all of its inputs are '1'. Otherwise, the output is '1'.
ANSI Symbol for NAND gate
Truth Table (A NAND B)
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Logical Expression:
5. The NOR Gate (NOT-OR)
The NOR gate is an OR gate followed by a NOT gate. Its output is '1' only when all inputs are '0'. If any input is '1', the output is '0'.
ANSI Symbol for NOR gate
Truth Table (A NOR B)
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Logical Expression:
Exclusive Gates: XOR and XNOR
These gates perform more specialized logical functions, commonly used in circuits that perform arithmetic and data checking.
6. The XOR Gate (Exclusive OR)
The XOR gate's output is '1' only if the inputs are different. If the inputs are the same (both '0' or both '1'), the output is '0'. It's a key component in adders and parity checkers.
ANSI Symbol for XOR gate
Truth Table (A XOR B)
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Logical Expression:
7. The XNOR Gate (Exclusive NOR)
The XNOR gate is an XOR gate followed by a NOT gate. Its output is '1' only if the inputs are the same. It functions as a logical equality checker.
ANSI Symbol for XNOR gate
Truth Table (A XNOR B)
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Logical Expression: