Logic gates are fundamental building blocks of digital circuits, used to perform logical operations on one or more binary inputs to produce a single output. There are seven primary types of logic gates, each corresponding to a specific logical operation. Below is an explanation of each:
### 1. **AND Gate**
- **Operation**: The AND gate outputs **1** only if **all** its inputs are **1**. If any input is **0**, the output will be **0**.
- **Symbol**: A flat-ended shape with two or more inputs on the left and one output on the right.
- **Truth Table**:
| A | B | Output (A AND B) |
|---|---|------------------|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
### 2. **OR Gate**
- **Operation**: The OR gate outputs **1** if **at least one** of its inputs is **1**. It only outputs **0** if all inputs are **0**.
- **Symbol**: A curved shape with two or more inputs on the left and one output on the right.
- **Truth Table**:
| A | B | Output (A OR B) |
|---|---|-----------------|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
### 3. **NOT Gate (Inverter)**
- **Operation**: The NOT gate outputs the **inverse** of the input. If the input is **1**, the output will be **0**, and vice versa.
- **Symbol**: A triangle pointing to the right with a small circle (representing inversion) at the output.
- **Truth Table**:
| A | Output (NOT A) |
|---|----------------|
| 0 | 1 |
| 1 | 0 |
### 4. **NAND Gate**
- **Operation**: The NAND gate is the **inverse** of the AND gate. It outputs **0** only if **all** its inputs are **1**. Otherwise, the output is **1**.
- **Symbol**: Same as the AND gate, but with a small circle at the output.
- **Truth Table**:
| A | B | Output (A NAND B) |
|---|---|-------------------|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
### 5. **NOR Gate**
- **Operation**: The NOR gate is the **inverse** of the OR gate. It outputs **1** only when **all** inputs are **0**. If any input is **1**, the output will be **0**.
- **Symbol**: Same as the OR gate, but with a small circle at the output.
- **Truth Table**:
| A | B | Output (A NOR B) |
|---|---|------------------|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
### 6. **XOR Gate (Exclusive OR)**
- **Operation**: The XOR gate outputs **1** only if **exactly one** of its inputs is **1**. If both inputs are the same (either both **0** or both **1**), the output will be **0**.
- **Symbol**: Same as the OR gate, but with an extra curved line on the input side.
- **Truth Table**:
| A | B | Output (A XOR B) |
|---|---|------------------|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
### 7. **XNOR Gate (Exclusive NOR)**
- **Operation**: The XNOR gate is the **inverse** of the XOR gate. It outputs **1** when its inputs are the same (both **0** or both **1**) and **0** when they are different.
- **Symbol**: Same as the XOR gate, but with a small circle at the output.
- **Truth Table**:
| A | B | Output (A XNOR B) |
|---|---|-------------------|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
### Summary of Logic Gates
- **AND Gate**: Output is 1 only if all inputs are 1.
- **OR Gate**: Output is 1 if at least one input is 1.
- **NOT Gate**: Inverts the input.
- **NAND Gate**: Output is the inverse of AND.
- **NOR Gate**: Output is the inverse of OR.
- **XOR Gate**: Output is 1 if exactly one input is 1.
- **XNOR Gate**: Output is the inverse of XOR.
These gates are essential in building more complex logic circuits and digital systems, enabling computers, calculators, and other electronic devices to perform tasks based on binary logic.