5 Decoders And Encoders

Digital Logic ยท Unit 5

Decoders and Encoders

Exam-focused notes for Decoders and Encoders (Digital Logic, BIT103): what the TU syllabus asks and how it has actually been tested, with 8 solved past questions from this unit.

Decoders and Encoders in short

Decoders and encoders convert information from one code to another. A decoder turns a binary code into a single active output line. An encoder does the opposite. Both are used in memory addressing, displays and code conversion.

Decoders and Encoders: notes

Decoder design and operation

An $n$-to-$2^n$ decoder has $n$ input lines and up to $2^n$ output lines. For each input combination exactly one output is active. Each output is one minterm of the inputs.

2-to-4 decoder with inputs $A_1A_0$ and an enable input $E$:

EA1A0Y0Y1Y2Y3
0xx0000
1001000
1010100
1100010
1110001

$$Y_0 = E A_1'A_0', \quad Y_1 = E A_1'A_0, \quad Y_2 = E A_1A_0', \quad Y_3 = E A_1A_0$$

The circuit uses four AND gates and two inverters. When $E=0$, all outputs are 0. Some decoders (such as the NAND type) have active-low outputs.

Larger decoders from smaller ones. A 3-to-8 decoder can be made from two 2-to-4 decoders. The third input $A_2$ goes to the enable of both: it is connected directly to one decoder and through an inverter to the other. When $A_2=0$ the first decoder works (outputs $Y_0$ to $Y_3$), and when $A_2=1$ the second works (outputs $Y_4$ to $Y_7$).

Implementing functions. A decoder gives all minterms, so any function can be built by adding an OR gate. For a full adder with inputs $x, y, z$, use a 3-to-8 decoder:

$$S = \Sigma m(1,2,4,7), \qquad C = \Sigma m(3,5,6,7)$$

Connect outputs $Y_1, Y_2, Y_4, Y_7$ to one OR gate for the sum. Connect $Y_3, Y_5, Y_6, Y_7$ to another OR gate for the carry.

What this unit covers

  • Decoder design and operation
  • BCD to decimal decoder
  • BCD to seven-segment decoder
  • BCD to excess-3 code converter
  • Encoder circuits

BCD to excess-3 code converter

2080 ยท 10 marks

Define BCD code. Design BCD to Excess-3 Code converter with truth table and logic diagram.[10]

Show solved answer

BCD to Excess-3 Code Converter

Definition of BCD Code

BCD (Binary Coded Decimal) is a binary encoding of decimal digits where each decimal digit (0-9) is represented by its 4-bit binary equivalent. Only 10 out of 16 possible 4-bit combinations (0000 to 1001) are valid; the remaining six (1010 to 1111) are invalid/don't-care states.

DecimalBCD (8-4-2-1)
00000
10001
......
91001

Definition of Excess-3 Code

Excess-3 (XS-3) is a non-weighted, self-complementing code obtained by adding 3 (0011) to each BCD digit.


Truth Table: BCD to Excess-3

Let BCD inputs be A, B, C, D (A = MSB, D = LSB) Let Excess-3 outputs be W, X, Y, Z (W = MSB, Z = LSB)

DecimalABCDWXYZ
000000011
100010100
200100101
300110110
401000111
501011000
601101001
701111010
810001011
910011100
10-15----XXXX

(X = don't care)


K-Map Simplification

Output W (minterms: 5,6,7,8,9 + don't cares 10-15)

        CD
AB    00  01  11  10
00  |  0 | 0 | 0 | 0 |
01  |  0 | 1 | 1 | 1 |
11  |  X | X | X | X |
10  |  1 | 1 | X | X |

W = A + BC + BD


Output X (minterms: 1,2,3,4,9 + don't cares 10-15)

        CD
AB    00  01  11  10
00  |  0 | 1 | 1 | 1 |
01  |  1 | 0 | 0 | 0 |
11  |  X | X | X | X |
10  |  0 | 1 | X | X |

X = B'C + B'D + BC'D'

(Simplified: X = BC'D' + B'C + B'D)


Output Y (minterms: 0,3,4,7,8 + don't cares 10-15)

        CD
AB    00  01  11  10
00  |  1 | 0 | 1 | 0 |
01  |  1 | 0 | 1 | 0 |
11  |  X | X | X | X |
10  |  1 | 0 | X | X |

Y = 1 at minterms 0, 3, 4, 7 and 8. On the map those cells fill the columns CD = 00 and CD = 11 for every value of AB, so the two groups are C'D' and CD, and the don't-care row AB = 11 is absorbed into them.

Y = CD + C'D'

(Y = C XNOR D = CD + C'D')


Output Z (minterms: 0,2,4,6,8 + don't cares 10-15)

        CD
AB    00  01  11  10
00  |  1 | 0 | 0 | 1 |
01  |  1 | 0 | 0 | 1 |
11  |  X | X | X | X |
10  |  1 | 0 | X | X |

Z = D'


Simplified Boolean Expressions

OutputExpression
WA + BC + BD
XB'C + B'D + BC'D'
YCD + C'D'
ZD'

Logic Diagram

Inputs: A, B, C, D, with inverters supplying B', C' and D'

W = A + BC + BD
  B ---+--[AND]--- BC ---+
  C ---+                 |
  B ---+--[AND]--- BD ---+--[OR]--- W
  D ---+                 |
  A ---------------------+

X = B'C + B'D + BC'D'
  B' --+--[AND]--- B'C ---+
  C ---+                  |
  B' --+--[AND]--- B'D ---+--[OR]--- X
  D ---+                  |
  B ---+                  |
  C' --+--[AND]-- BC'D' --+
  D' --+

Y = CD + C'D'
  C ---+--[AND]--- CD ----+
  D ---+                  +--[OR]--- Y
  C' --+--[AND]--- C'D' --+
  D' --+

Z = D'
  D -------[NOT]--------- Z

Only two-level AND-OR logic is needed for each output, and the inverters that produce B', C' and D' are shared across all four output networks. Y is the XNOR of C and D, so a single XNOR gate can replace its two AND gates and the OR gate.

Open this answer on its own page โ†’

2081.2 ยท 10 marks

Design a combinational circuit that generates 9โ€™s complement of a BCD number.[10]

  • Input: a single BCD digit, 4 bits $B3 B2 B1 B0$, valid range decimal 0 to 9. - Output: 4 bits $X3 X2 X1 X0$ representing $9 - N$. - Inputs 10 to 15 are invalid BCD โ†’ treated as don't cares (X). Dec $B3B2B1B0$ $9-N$ $X3X2X1X0$ -------------------------------------------- 0 0000 9 1001 1 0001 8 1...
Open this answer on its own page โ†’

BCD to seven-segment decoder

2079 ยท 10 marks

Design a BCD-to Seven-segment decoder to display decimal numbers 1, 2 and 4.[10]

A BCD (Binary Coded Decimal) to Seven-Segment Decoder takes a 4-bit BCD input and drives the seven segments (a, b, c, d, e, f, g) of a display to show the corresponding decimal digit. --- Segment Position ------------------- a Top horizontal b Top-right vertical c Bottom-right vertical d Bottom h...

Open this answer on its own page โ†’

Decoder design and operation

2078 ยท 5 marks

Implement the following function: F = ฮฃ\Sigmaฮฃ(0,1,3,4,5,8,9,10,15) using i) Decoder ii) Multiplexer iii) PLA[5]

Show solved answer

Implementation of F = ฮฃ(0,1,3,4,5,8,9,10,15)

Given

  • Function: $F(A,B,C,D) = \Sigma m(0,1,3,4,5,8,9,10,15)$
  • 4 variables: A (MSB), B, C, D (LSB)
  • Minterms where F = 1: {0, 1, 3, 4, 5, 8, 9, 10, 15}
  • Minterms where F = 0: {2, 6, 7, 11, 12, 13, 14}

Truth Table

mABCDF
000001
100011
200100
300111
401001
501011
601100
701110
810001
910011
1010101
1110110
1211000
1311010
1411100
1511111

Solution

i) Using Decoder (4-to-16 Decoder)

A 4-to-16 decoder produces all 16 minterms on its outputs $D_0 \ldots D_{15}$. Feed the minterm outputs where F = 1 into an OR gate.

$$F = D_0 + D_1 + D_3 + D_4 + D_5 + D_8 + D_9 + D_{10} + D_{15}$$

A,B,C,D --> [4-to-16 Decoder]
              outputs D0,D1,D3,D4,D5,D8,D9,D10,D15
              --> [9-input OR gate] --> F

(If active-low decoder outputs are used, a 9-input NAND gate is used instead.)


ii) Using Multiplexer (8-to-1 MUX)

Use A, B, C as select lines ($S_2=A,,S_1=B,,S_0=C$) and D as data variable.

A B Cm(D=0) / m(D=1)F,FInput
000m0=1, m1=11,11
001m2=0, m3=10,1D
010m4=1, m5=11,11
011m6=0, m7=00,00
100m8=1, m9=11,11
101m10=1, m11=01,0D'
110m12=0,m13=00,00
111m14=0,m15=10,1D

MUX input connections:

$$I_0=1,; I_1=D,; I_2=1,; I_3=0,; I_4=1,; I_5=D',; I_6=0,; I_7=D$$


iii) Using PLA

Minimize using K-map.

          CD
AB     00   01   11   10
00 |    1    1    1    0
01 |    1    1    0    0
11 |    0    0    1    0
10 |    1    1    0    1

Grouping SOP terms:

  • P1: $A'C'$ โ†’ cells 00-00,00-01,01-00,01-01 = m0,m1,m4,m5 โœ“
  • P2: $B'C'$ โ†’ m0,m1,m8,m9 (00-00,00-01,10-00,10-01) โœ“
  • P3: $A'B'D$ โ†’ m1,m3 (00-01,00-11) โœ“
  • P4: $B'C D'$ โ†’ m10 (10-10); pair with m8? m8=10-00 no. Use $A B' C D'$... check m10 alone. Pair m10 with m2(=0) not allowed. So $m10 = AB'CD'$ (single cell).
  • P5: $ABCD$ โ†’ m15 (single cell)

Verify coverage:

  • P1 covers 0,1,4,5
  • P2 covers 0,1,8,9
  • P3 covers 1,3
  • P4 covers 10
  • P5 covers 15

Union = {0,1,3,4,5,8,9,10,15} โœ“ all minterms covered, no extra.

$$\boxed{F = A'C' + B'C' + A'B'D + AB'CD' + ABCD}$$

PLA Programming Table (5 product terms, inputs A,B,C,D, one output F):

ProductABCDF
$A'C'$0-0-1
$B'C'$-00-1
$A'B'D$00-11
$AB'CD'$10101
$ABCD$11111

(AND array programs the 5 product terms; OR array connects all 5 to output F.)

Common mistake: grouping the PLA K-map carelessly, for example placing $m_{10}$ in an $AB'$ pair that covers 10. The minimized expression above is the correct grouping. The MUX and decoder parts are straightforward by comparison.

Open this answer on its own page โ†’

2081.2 ยท 5 marks

Explain the concept of decoder with an example. [5]

A decoder is a combinational logic circuit that converts binary coded input into a set of outputs, where exactly one output is active (HIGH) for each unique combination of inputs. - It has n input lines and 2^n output lines - It "decodes" a binary code by activating the corresponding output line ...

Open this answer on its own page โ†’

0

Design of Full Adder Circuit Using 3-to-8 Decoder

A Full Adder is a combinational circuit that adds three input bits (A, B, Cin) and produces two outputs: Sum (S) and Carry (Cout). It can be implemented using a 3-to-8 decoder and OR gates.

A Full Adder is a combinational circuit that accepts three input bits (A, B, Cin) and produces two outputs: Sum (S) and Carry (Cout). Any combinational logic function can be implemented using a decoder and OR gates, because a decoder generates all minterms of the input variables, and any Boolean ...

Open this answer on its own page โ†’

0 ยท 5 marks

Design a decoder with three input lines but with only six output lines. If the value of the input corresponds to 6 or 7, then all output line should be asserted to signal an error. [5]

Design a decoder with: - 3 input lines: Aโ‚‚, Aโ‚, Aโ‚€ - 6 output lines: Dโ‚€ through Dโ‚… - Error condition: If input = 6 (110) or input = 7 (111), ALL output lines are asserted (set to 1) --- Aโ‚‚ Aโ‚ Aโ‚€ Dโ‚€ Dโ‚ Dโ‚‚ Dโ‚ƒ Dโ‚„ Dโ‚… Condition ----------------------------------------------- 0 0 0 1 0 0 0 0 0 Normal 0...

Open this answer on its own page โ†’

BCD to decimal decoder

2077 ยท 10 marks

What is Decoder? Design BCD to Decimal Decoder with Truth Table and Logic Diagram [10]

A decoder is a combinational logic circuit that converts an n-bit binary input code into a maximum of 2โฟ unique output lines, where only one output is active (HIGH) at a time for each valid input combination. - It is essentially a minterm generator - For n input lines, there can be at most 2โฟ out...

Open this answer on its own page โ†’