Professional Documents
Culture Documents
6 ChapterSix (1)
6 ChapterSix (1)
6 ChapterSix (1)
ENCODER, DECODER
& CODE CONVERSION
Objectives
Priority Encoder
Display decoder
Application of decoder
88
789
456
123 Enkoder Pemproses Dekoder
0
6.2 Encoder
encoder may have one active input and produces a unique output.
The diagram show below is a truth table for a 10:4 encoder, with active-
high inputs. The inputs are normally low. If a decimal input 4 is activated
(active high), the output is 0100.
Input Output
0 1 2 3 4 5 6 7 8 9 A B C D
1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0 0 0 0 1 0 0
0 0 0 0 0 1 0 0 0 0 0 1 0 1
0 0 0 0 0 0 1 0 0 0 0 1 1 0
0 0 0 0 0 0 0 1 0 0 0 1 1 1
0 0 0 0 0 0 0 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 1 0 0 1
We can write the output expressions and obtained the logic circuit as
shown below.
A =8+9 1 2 3 4 5 6 7 8 9
B = 4+5+6+7
A
C = 2+3+ 6+ 7
D = 1+ 3 + 5 + 7 + 9
B
D
90
Example 1:
Design a 4:2 encoder, where only one input is active at any one time.
0 Input Output
1 A 0 1 2 3 A B
2 B
3 1 0 0 0 0 0
0 1 0 0 0 1
0 0 1 0 1 0
0 0 0 1 1 1
The 4:2 encoder truth table can be written in full as follows. We may
consider an output X, for inputs other than 0000, 0100, 0010 and 0001.
Input Output
0 1 2 3 A B
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 0 1 0
0 0 1 1 X X
0 1 0 0 0 1
0 1 0 1 X X
0 1 1 0 X X
0 1 1 1 X X
1 0 0 0 0 0
1 0 0 1 X X
1 0 1 0 X X
1 0 1 1 X X
1 1 0 0 X X
1 1 0 1 X X
1 1 1 0 X X
1 1 1 1 X X
A = 2+3
A
B = 1+ 3
B
91
The simple 10:4 encoder in 6.2 identifies a drawback when more than one
input is activated. If the input 3 and 5 are activated simultaneously, the
output is 0111 (7), which is not a correct.
Input Output
0 1 2 3 4 5 6 7 8 9 A B C D
X 0 0 0 0 0 0 0 0 0 0 0 0 0
X 1 0 0 0 0 0 0 0 0 0 0 0 1
X X 1 0 0 0 0 0 0 0 0 0 1 0
X X X 1 0 0 0 0 0 0 0 0 1 1
X X X X 1 0 0 0 0 0 0 1 0 0
X X X X X 1 0 0 0 0 0 1 0 1
X X X X X X 1 0 0 0 0 1 1 0
X X X X X X X 1 0 0 0 1 1 1
X X X X X X X X 1 0 1 0 0 0
X X X X X X X X X 1 1 0 0 1
92
that represent
0 1 2 3 4 5 6 7 8 9 A B C D
0 0 1 0 0 0 0 0 0 0 0 0 1 0
0 1 1 0 0 0 0 0 0 0 0 0 1 0
1 0 1 0 0 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 0 0 1 0
The output expressions for 10:4 priority encoder can be written as:
A = 8.9 + 9
B = 4.5.6.7.8.9 + 5.6.7.8.9 + 6.7.8.9 + 7.8.9
C = 2.3.4.5.6.7.8.9 + 3.4.5.6.7.8.9 + 6.7.8.9 + 7.8.9
D = 1.2.3.4.5.6.7.8.9 + 3.4.5.6.7.8.9 + 5.6.7.8.9 + 7.8.9 + 9
A =8+9
B = 4.8.9 + 5.8.9 + 6.8.9 + 7.8.9
C = 2.4.5.8.9 + 3.4.5.8.9 + 6.8.9 + 7.8.9
D = 1.2.4.6.8 + 3.4.6.8. + 5.6.8 + 7.8 + 9
93
Example 2:
Input Output
0
1 A 0 1 2 3 A B
2 B
X 0 0 0 0 0
3
X 1 0 0 0 1
X X 1 0 1 0
X X X 1 1 1
A = 2.3 + 3
= (2 + 3)(3 + 3)
= 2+3
B = 1.2.3 + 3
= (1.2 + 3)(3 + 3)
= 1.2 + 3
94
The 4:2 priority encoder truth table can be written in full as follows.
Input Output
0 1 2 3 A B
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 0 1 0
0 0 1 1 1 1
0 1 0 0 0 1
0 1 0 1 1 1
0 1 1 0 1 0
0 1 1 1 1 1
1 0 0 0 0 0
1 0 0 1 1 1
1 0 1 0 1 0
1 0 1 1 1 1
1 1 0 0 0 1
1 1 0 1 1 1
1 1 1 0 1 0
1 1 1 1 1 1
A = 2+3
B = 1.2 + 3
The 74147 and 74148 are two common IC encoders. The 74147 is a 10:4
priority encoder that performs the code conversion from decimal to BCD.
The 74147 has active-low inputs and active-low outputs. Although the
74147 is classified as 10:4 encoder, the IC itself has only 9 inputs for
values 1 to 9. The 0 input is assumed when no other keys are pressed.
The 74148 is an 8:3 priority encoder for performing the code conversion
from octal to binary. It has 8 input for values 0-7 and 3 outputs A0,A1
and A2. Both the inputs and outputs are active-low.
74147 74148
I9 EI GS
I8
I7 A3 I7
I6 A2 I6 A2
I5 A1 I5 A1
I4 A0 I4 A0
I3 I3
I2 I2
I1 I1
I0 EO
95
6.4 Decoder
1 0 0 0 0 1 0 0 0 0 0 0 0 0 0
2
A
B 4:10
3
4
0 0 0 1 0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0 0 0 0 0 0 0
C Decoder 5
D 6
7
8
9
0 0 1 1 0 0 0 1 0 0 0 0 0 0
0 1 0 0 0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 1 0 0 0 0
0 1 1 0 0 0 0 0 0 0 1 0 0 0
0 1 1 1 0 0 0 0 0 0 0 1 0 0
A B C D
1 0 0 0 0 0 0 0 0 0 0 0 1 0
A' 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1
B'
C' 1
D'
2
0 = A.B.C.D
3
1 = A.B.C.D
4 2 = A.B.C.D
3 = A.B.C.D
5 4 = A.B.C.D
5 = A.B.C.D
6
6 = A.B.C.D
7 = A.B.C.D
7
8 = A.B.C.D
8 9 = A.B.C.D
9
96
Example 1:
0
A 1 Input Output
B 2 A B 0 1 2 3
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
2 = A.B B'
1
3 = A.B
74LS42
9
8
7
6
5
4
A3 3
A2 2
A1 1
A B C D A0 0
0V 0V 5V 5V
0 1 2 3 4 5 6 7 8 9
3 A.B
Input Output
A B C D a b c d e f g
0 0 0 0 1 1 1 1 1 1 0
0 0 0 1 0 1 1 0 0 0 0
0 0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 1 1 1 0 0 1
0 1 0 0 0 1 1 0 0 1 1
0 1 0 1 1 0 1 1 0 1 1
0 1 1 0 1 0 1 1 1 1 1
0 1 1 1 1 1 1 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
Each segment contains a light emitting diode (LED). The LEDs can be
connected either common-cathode or common-anode. In the common-
cathode display, all the cathodes of the LEDs are connected together. The
cathodes are then connected to 0 volt or ground.
99
Exercises
Input Output
0 1 2 3 A B
0
1 A 1 0 0 0 0 0
2 B
3 0 1 0 0 0 1
0 0 1 0 1 0
0 0 0 1 1 1
Input Output
0 1 2 3 A B
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 0 1 0
0 0 1 1 X X
0 1 0 0 0 1
0 1 0 1 X X
0 1 1 0 X X
0 1 1 1 X X
1 0 0 0 0 0
1 0 0 1 X X
1 0 1 0 X X
1 0 1 1 X X
1 1 0 0 X X
1 1 0 1 X X
1 1 1 0 X X
1 1 1 1 X X
101
0 Input Output
1 A
2 B
0 1 2 3 A B
3 X 0 0 0 0 0
X 1 0 0 0 1
X X 1 0 1 0
X X X 1 1 1
Input Output
0 1 2 3 A B
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 0 1 0
0 0 1 1 1 1
0 1 0 0 0 1
0 1 0 1 1 1
0 1 1 0 1 0
0 1 1 1 1 1
1 0 0 0 0 0
1 0 0 1 1 1
1 0 1 0 1 0
1 0 1 1 1 1
1 1 0 0 0 1
1 1 0 1 1 1
1 1 1 0 1 0
1 1 1 1 1 1
102
0
1
A 2
B 3
C 4
5
6
7
a. Y = A.B + B( A + C)
b. Y = A.B.C.D + A.B.C.D + A.B.C.D + A.D