### **Decoder:**
A **decoder** is a combinational logic circuit that converts binary input into a specific output. It takes an encoded binary input signal and produces a unique output signal corresponding to the input. It is widely used in digital electronics for translating encoded data into a readable or usable format.
#### **Key Features:**
- **Inputs:** Typically \( n \) input lines.
- **Outputs:** \( 2^n \) output lines.
- **Functionality:** Each input combination activates one and only one output.
- **Applications:**
- **Address Decoding:** Used in memory systems to select specific memory locations.
- **Data Display:** Driving seven-segment displays.
- **Control Signals:** Generating specific control lines in a processor.
#### **Example:**
A 2-to-4 line decoder has 2 input lines and 4 output lines. It maps the binary input to a single high (logic 1) output:
- Input \( 00 \) → Output \( O_0 \)
- Input \( 01 \) → Output \( O_1 \)
- Input \( 10 \) → Output \( O_2 \)
- Input \( 11 \) → Output \( O_3 \)
#### **Truth Table for a 2-to-4 Decoder:**
| Input \( A \) | Input \( B \) | \( O_0 \) | \( O_1 \) | \( O_2 \) | \( O_3 \) |
|---------------|---------------|-----------|-----------|-----------|-----------|
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
---
### **Demultiplexer (Demux):**
A **demultiplexer** is a combinational circuit that takes a single input and channels it to one of many outputs based on control signals. It is often referred to as the inverse of a multiplexer.
#### **Key Features:**
- **Input:** One data input.
- **Outputs:** \( n \) outputs.
- **Control Lines:** \( \log_2(n) \) control lines to select the output.
- **Functionality:** Routes the input data to one of the outputs as determined by the control signals.
- **Applications:**
- **Data Distribution:** Splitting data streams in communication systems.
- **Memory Selection:** Used in circuits where a specific memory chip needs to be activated.
- **Digital Signal Routing:** Steering signals to specific paths.
#### **Example:**
A 1-to-4 demultiplexer has 1 data input, 2 control lines, and 4 outputs. The control signals determine which output receives the input.
#### **Truth Table for a 1-to-4 Demultiplexer:**
| Control \( A \) | Control \( B \) | \( I \) (Input) | \( O_0 \) | \( O_1 \) | \( O_2 \) | \( O_3 \) |
|------------------|------------------|-----------------|-----------|-----------|-----------|-----------|
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 1 |
---
### **Comparison Between Decoder and Demultiplexer:**
| Feature | **Decoder** | **Demultiplexer** |
|-------------------|---------------------------------------------|---------------------------------------------|
| **Purpose** | Converts binary input to a unique output. | Directs a single input to one of many outputs. |
| **Input** | \( n \) binary inputs. | One data input and control lines. |
| **Output** | \( 2^n \) unique outputs. | Multiple outputs (based on control signals).|
| **Control Signals**| Not used. | Required to select the output. |
| **Applications** | Address decoding, display systems. | Data distribution, routing in networks. |
In summary, a **decoder** is primarily used for translating binary inputs into specific outputs, while a **demultiplexer** is used for distributing one input signal to multiple output lines.