Skip to main content

Encoder vs decoder; 8-to-3 encoder

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.

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

Encoder vs decoder

PointEncoderDecoder
FunctionConverts one active line to a binary codeConverts a binary code to one active line
Inputs / outputs2n2^n inputs, nn outputsnn inputs, 2n2^n outputs
Main gatesOR gatesAND gates
Example8-to-3 (octal to binary)3-to-8 (74138)
UseKeyboards, interrupt encodingAddress decoding, display driving

8-to-3 encoder

An 8-to-3 (octal-to-binary) encoder has eight inputs D0D_0–D7D_7 and three outputs Y2Y1Y0Y_2Y_1Y_0. When one input DkD_k is 1, the output is the binary code of kk. Only one input is assumed active at a time.

Truth table

D7D_7D6D_6D5D_5D4D_4D3D_3D2D_2D1D_1D0D_0Y2Y_2Y1Y_1Y0Y_0
00000001000
00000010001
00000100010
00001000011
00010000100
00100000101
01000000110
10000000111

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

Y2=D4+D5+D6+D7Y1=D2+D3+D6+D7Y0=D1+D3+D5+D7\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

 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: D6=1D_6 = 1 → Y2=1Y_2 = 1, Y1=1Y_1 = 1, Y0=0Y_0 = 0, output 110=6110 = 6.

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

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 4 questions →