---
title: "Encoder vs decoder; 8-to-3 encoder"
subject: "Digital Logic"
chapter: 4
key: "semester_3/digital_logic:encoder-decoder-8to3"
source: https://www.bctengineer.com/q/semester_3/digital_logic/encoder-decoder-8to3
site: BCT Engineering
---

# Encoder vs decoder; 8-to-3 encoder

Digital Logic · Chapter 4: Data Processing Circuits

- Asked in: 2081 Baisakh, 2+5 marks
- Video: [Encoder in Digital Electronics | Working, Application and Logic Circuit of Encoder](https://www.youtube.com/watch?v=NWiPVMDh7GE) — ALL ABOUT ELECTRONICS
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_3/digital_logic/encoder-decoder-8to3
- Whole chapter: https://www.bctengineer.com/md/semester_3/digital_logic/chapter-4

## Question

Differentiate between encoder and decoder. Design an 8 to 3 encoder with diagrams.

## Short answer

An encoder has 2^n inputs and n outputs, converting one active input to binary using OR gates; a decoder does the reverse. An 8-to-3 encoder uses OR gates: Y2=D4+D5+D6+D7, Y1=D2+D3+D6+D7, Y0=D1+D3+D5+D7. D0 inactive gives 000.

## Answer

#### Encoder vs decoder

| Point | Encoder | Decoder |
|---|---|---|
| Function | Converts one active line to a binary code | Converts a binary code to one active line |
| Inputs / outputs | $2^n$ inputs, $n$ outputs | $n$ inputs, $2^n$ outputs |
| Main gates | OR gates | AND gates |
| Example | 8-to-3 (octal to binary) | 3-to-8 (74138) |
| Use | Keyboards, interrupt encoding | Address decoding, display driving |

#### 8-to-3 encoder

An **8-to-3 (octal-to-binary) encoder** has eight inputs $D_0$–$D_7$ and three outputs $Y_2Y_1Y_0$. When one input $D_k$ is 1, the output is the binary code of $k$. Only one input is assumed active at a time.

**Truth table**

| $D_7$ | $D_6$ | $D_5$ | $D_4$ | $D_3$ | $D_2$ | $D_1$ | $D_0$ | $Y_2$ | $Y_1$ | $Y_0$ |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |

**Output equations.** Each output is 1 for the inputs whose code has a 1 in that bit:

$$
\begin{aligned} Y_2 &= D_4 + D_5 + D_6 + D_7 \\ Y_1 &= D_2 + D_3 + D_6 + D_7 \\ Y_0 &= D_1 + D_3 + D_5 + D_7 \end{aligned}
$$

**Logic diagram**

```text
 D4, D5, D6, D7 ---[OR 4]---> Y2
 D2, D3, D6, D7 ---[OR 4]---> Y1
 D1, D3, D5, D7 ---[OR 4]---> Y0
 (D0 not connected: it gives 000)
```

**Example:** $D_6 = 1$ → $Y_2 = 1$, $Y_1 = 1$, $Y_0 = 0$, output $110 = 6$.

**Limitations:** $D_0 = 1$ and "no input active" both give 000, and two active inputs give a wrong code (e.g. $D_3$ and $D_4$ give 111). A valid-output bit and a priority encoder (74148) remove these problems.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How do encoder and decoder inputs and outputs differ?
   A. Encoder has n inputs and 2^n outputs
   B. Encoder has 2^n inputs and n outputs; decoder has n inputs and 2^n outputs
   C. Both have equal numbers
   D. Encoder has one input and many outputs
   Answer: B. An encoder converts one active line into a binary code; a decoder does the reverse. (Key point: Encoder vs decoder)

2. Which is the correct equation for Y2 of the 8-to-3 encoder?
   A. Y2 = D1 + D3 + D5 + D7
   B. Y2 = D2 + D3 + D6 + D7
   C. Y2 = D4 + D5 + D6 + D7
   D. Y2 = D0 + D1 + D2 + D3
   Answer: C. Y2 is the MSB of the code, which is 1 for inputs 4 to 7. (Key point: Output equation)

3. If only D6 = 1, what is the output Y2Y1Y0?
   A. 011
   B. 101
   C. 111
   D. 110
   Answer: D. 6 in binary is 110. (Key point: Example)

4. Which is a limitation of the simple 8-to-3 encoder?
   A. D0 = 1 and no input active both give 000, and two active inputs give a wrong code
   B. It cannot encode D7
   C. It needs a clock
   D. It gives a different code for each input twice
   Answer: A. A priority encoder with a valid bit fixes both problems. (Key point: Limitations)

## Related in Digital Logic

- [Encoder; 4×16 decoder from 2×4 decoders](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aencoder-4x16-decoder) — Digital Logic, chapter 4
- [Combinational vs sequential; BCD-to-decimal decoder](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Abcd-to-decimal-decoder) — Digital Logic, chapter 4
- [DEMUX vs decoder; 4×16 decoder from 2×4](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Adecoder-4x16-from-2x4) — Digital Logic, chapter 4
- [Octal priority encoder design](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aoctal-priority-encoder-design) — Digital Logic, chapter 4, asked 3×
- [DEMUX vs decoder; seven-segment "b" segment](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Ademux-decoder-b-segment) — Digital Logic, chapter 4
- [Priority encoder; "e" and "f" segments](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Apriority-encoder-e-f-segments) — Digital Logic, chapter 4

## Related in other subjects

- [Delta modulation encoder/decoder; PCM vs DM](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Adm-encoder-decoder-pcm-vs-dm) — Communication Systems, chapter 4
- [Stereo FM encoder and decoder](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Astereo-fm-encoder-decoder) — Communication Systems, chapter 3, asked 2×
- [Stereo FM encoder and decoder block diagram](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Astereo-fm-encoder-decoder-blocks) — Communication Systems, chapter 3
- [Error detection vs correction; rate ½ convolutional encoder](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aerror-detect-correct-conv-half-rate) — Communication Systems, chapter 8
