Logic gates are fundamental building blocks in digital circuits, used to perform logical operations on one or more binary inputs to produce a single output. The basic logic gates are:
### 1. **AND Gate**
- **Operation**: The AND gate gives an output of **1** only if **all inputs are 1**. If any of the inputs is **0**, the output will be **0**.
- **Symbol**: The symbol for the AND gate is a flat-ended shape with a "D"-like form, with two or more inputs on the left and one output on the right.
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
- **Example**: For an AND gate with inputs A and B:
- If A = 1 and B = 1, the output is 1.
- If A = 1 and B = 0, the output is 0.
### 2. **OR Gate**
- **Operation**: The OR gate outputs a **1** if **at least one input is 1**. If both inputs are **0**, the output will be **0**.
- **Symbol**: The symbol for the OR gate is similar to the AND gate but with a curved shape, resembling the letter "D."
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
- **Example**: For an OR gate with inputs A and B:
- If A = 0 and B = 1, the output is 1.
- If A = 1 and B = 1, the output is 1.
### 3. **NOT Gate (Inverter)**
- **Operation**: The NOT gate is a **unary** gate, meaning it has only one input. It **inverts** or **reverses** the input: if the input is **0**, the output will be **1**, and if the input is **1**, the output will be **0**.
- **Symbol**: The symbol for the NOT gate is a triangle pointing to the right with a small circle at the output end.
- **Truth Table**:
| Input | Output |
|:-----:|:------:|
| 0 | 1 |
| 1 | 0 |
- **Example**: For a NOT gate with input A:
- If A = 0, the output is 1.
- If A = 1, the output is 0.
### 4. **NAND Gate**
- **Operation**: The NAND gate is the **inverse** of the AND gate. It outputs a **0** only when **all inputs are 1**. In all other cases, the output will be **1**.
- **Symbol**: The NAND gate looks like an AND gate but with a small circle (representing inversion) at the output.
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
- **Example**: For a NAND gate with inputs A and B:
- If A = 1 and B = 1, the output is 0.
- If A = 0 and B = 1, the output is 1.
### 5. **NOR Gate**
- **Operation**: The NOR gate is the **inverse** of the OR gate. It outputs a **1** only when **both inputs are 0**. For any other combination of inputs, the output will be **0**.
- **Symbol**: The NOR gate symbol is like the OR gate but with a small circle at the output end, indicating inversion.
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
- **Example**: For a NOR gate with inputs A and B:
- If A = 0 and B = 0, the output is 1.
- If A = 1 and B = 0, the output is 0.
### 6. **XOR Gate (Exclusive OR)**
- **Operation**: The XOR gate outputs a **1** only when **exactly one input is 1**. If both inputs are the same (either both 0 or both 1), the output will be **0**.
- **Symbol**: The XOR gate symbol is similar to the OR gate but with an extra curved line on the input side.
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
- **Example**: For a XOR gate with inputs A and B:
- If A = 1 and B = 0, the output is 1.
- If A = 1 and B = 1, the output is 0.
### 7. **XNOR Gate (Exclusive NOR)**
- **Operation**: The XNOR gate is the **inverse** of the XOR gate. It outputs a **1** when both inputs are the same (either both 0 or both 1). It gives a **0** when the inputs are different.
- **Symbol**: The XNOR gate symbol is like the XOR gate but with a small circle (indicating inversion) at the output end.
- **Truth Table**:
| Input A | Input B | Output |
|:-------:|:-------:|:------:|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
- **Example**: For a XNOR gate with inputs A and B:
- If A = 1 and B = 1, the output is 1.
- If A = 0 and B = 1, the output is 0.
### Summary
- **AND Gate**: Outputs 1 when all inputs are 1.
- **OR Gate**: Outputs 1 when at least one input is 1.
- **NOT Gate**: Inverts the input.
- **NAND Gate**: Outputs 1 unless all inputs are 1.
- **NOR Gate**: Outputs 1 only when all inputs are 0.
- **XOR Gate**: Outputs 1 when the inputs are different.
- **XNOR Gate**: Outputs 1 when the inputs are the same.
These gates form the foundation for constructing digital circuits and are used in everything from simple logic functions to complex computer processors.