Logic Gates and Truth Tables
1. Introduction
Logic gates are the basic building blocks of digital electronics. They are electronic circuits that perform logical operations on binary inputs and produce a binary output.
A logic gate works with two binary values:
- 0 (LOW): Usually represents a low voltage level.
- 1 (HIGH): Usually represents a high voltage level.
The exact voltage represented by 0 or 1 depends on the digital logic family and circuit design.
Logic gates are used in computers, calculators, microcontrollers, memory systems, control circuits, and other digital devices.
2. What Is a Truth Table?
A truth table is a table that shows the output of a logic gate for every possible combination of its inputs.
For example, a gate with one input has two possible input combinations: 0 and 1. A gate with two inputs has four combinations.
For binary inputs, the number of possible input combinations is:
For two inputs, and , the four combinations are 00, 01, 10, and 11.
| Input A | Input B |
|---|---|
| 0 | 0 |
| 0 | 1 |
| 1 | 0 |
| 1 | 1 |
A truth table helps us understand, design, and test digital circuits.
3. AND Gate
Sum of Product - Electronics-Lab
The AND gate produces an output of 1 only when all inputs are 1. If any input is 0, the output is 0.
Boolean expression
Here, and are inputs, and is the output.
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Explanation: The AND gate behaves like a system that requires two conditions to be true simultaneously. For example, a machine may operate only when both its safety switch and start switch are ON.
4. OR Gate
The OR gate produces an output of 1 when at least one input is 1. Its output is 0 only when all inputs are 0.
Boolean expression
In Boolean algebra, the plus sign represents the OR operation, not ordinary arithmetic addition.
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Explanation: An alarm could be activated when either a smoke sensor or a temperature sensor detects a dangerous condition.
5. NOT Gate
Not Gate - 1200x500 PNG Download - PNGkit
The NOT gate, also called an inverter, has one input and produces the opposite value at its output.
- Input
0produces output1. - Input
1produces output0.
Boolean expression
The bar over represents logical NOT.
Truth table
| A | Output |
|---|---|
| 0 | 1 |
| 1 | 0 |
Explanation: If a signal indicates that a condition is false, a NOT gate can reverse that signal to represent the opposite condition.
6. NAND Gate
The NAND gate is the opposite of an AND gate. Its name comes from “NOT AND.”
It produces 0 only when all inputs are 1. In every other case, the output is 1.
Boolean expression
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Explanation: A NAND gate combines an AND operation with an inversion at the output.
NAND is called a universal gate because any basic logic operation, including AND, OR, and NOT, can be constructed using only NAND gates.
7. NOR Gate
File:Nor-gate-en.svg - Wikimedia Commons
The NOR gate is the opposite of an OR gate. Its name comes from “NOT OR.”
It produces 1 only when all inputs are 0. If any input is 1, the output is 0.
Boolean expression
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Explanation: A NOR gate first performs an OR operation and then inverts its result.
NOR is also a universal gate, meaning complete digital logic circuits can be built using only NOR gates.
8. XOR Gate (Exclusive OR)
The XOR gate produces 1 when its two inputs are different. When both inputs are the same, the output is 0.
XOR stands for Exclusive OR.
Boolean expression
It can also be expressed as:
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Explanation: XOR detects whether two binary inputs differ. It is used in binary adders, parity generators, and error-detection circuits.
For example, in a half adder, the XOR gate produces the Sum output.
9. XNOR Gate (Exclusive NOR)
XNOR Gate: Circuit Diagram, Truth Table, Symbol, Boolean Expression
The XNOR gate is the opposite of an XOR gate. It produces 1 when its inputs are equal and 0 when they are different.
Boolean expression
Another expression is:
Truth table
| A | B | Output |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Explanation: XNOR is useful for checking whether two binary bits are equal. It is used in digital comparators and equality-detection circuits.
10. Comparison of All Basic Logic Gates
| Logic gate | Boolean expression | Output is 1 when… |
|---|---|---|
| AND | Both inputs are 1 | |
| OR | At least one input is 1 | |
| NOT | Input is 0 | |
| NAND | At least one input is 0 | |
| NOR | Both inputs are 0 | |
| XOR | Inputs are different | |
| XNOR | Inputs are equal |
11. Combined Truth Table
The following table compares all seven basic logic gates for every possible combination of two inputs, and . For the NOT gate, the output shown is the inversion of input .
| A | B | AND | OR | NAND | NOR | XOR | XNOR | NOT A |
|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
12. Applications of Logic Gates
Logic gates are used in many digital electronic systems.
- Computers and processors: Perform arithmetic, logical operations, and data processing.
- Calculators: Perform binary calculations using digital circuits.
- Memory circuits: Store and control digital information.
- Security systems: Combine sensor signals to control alarms and access systems.
- IoT devices: Process signals from sensors and control outputs such as LEDs, buzzers, and relays.
- Communication systems: Support encoding, decoding, and error detection.
- Digital comparators: Compare binary values to determine whether they are equal or different.
13. Summary
Logic gates perform basic Boolean operations on binary inputs. Truth tables describe their outputs for all possible input combinations.
The seven basic gates are AND, OR, NOT, NAND, NOR, XOR, and XNOR. Among them, NAND and NOR are universal gates because either one can be used alone to construct any Boolean logic function.
These gates form the foundation of digital electronics and are combined to build adders, subtractors, multiplexers, counters, processors, and other digital circuits.