Encoders and Decoders
Encoders and Decoders
1
Encoders
Numerical data is entered into a computer in
denary (decimal) form. But, inside a computer
internal operations are carried out usually in
binary form. This necessitates the inclusion of
a circuit which will convert a denary input into
a binary form.
Process of converting signals from one type to
another type is called encoding. E.g. decimal
to binary ,hexadecimal to binary etc.
The logic circuit which performs this very job is
called as Encoder.
2
Encoders
2n >=N , where N is total number of digits to be
encoded.
Thus , for Denary to Binary encoder , since ten (0-9)
digits may be entered as inputs for conversions, the
number of outputs for the equivalent binary number
has to be four, as
2 4 >= 10
4 is the least value of n , which ensures that 2n>=10
3
Denary to Binary Encoder
I0
I1
B3
I2
Decimal B2
to
B1
Binary
Encoder
B0
I9
If I5 is High then Output will be 0101 (i.e. B3 will be 0 , B2 will be 1,B1 will
be 0 and B0 will be 1 (Assuming 23,22,21,20 as B3,B2,B1,B0 respectively)
4
Denary to Binary Encoder
Decimal B3 B2 B1 B0
number
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
5
Denary to Binary Encoder
0
1
2
3
4
5
6
7
8
9
6
B3 B2 B1 B0
Denary to Binary Encoder
The above given circuit is capable of converting (0-9)
numbers into binary.
The switches are push button switches which on
pressing provide a high (1) input to attached OR gates.
Output of four OR gates form a 4-bit word which is
binary equivalent of the pressed switch.
7
Denary to Binary Encoder
Now notice, when 6th push button is pressed , then
B2 and B1 OR gates get High (1) inputs, hence
produce High (1) outputs, therefore ,the output is
B3 B2 B1 B0 =0110 = 6
(0110 is the binary equivalent of 6)
Similarly when 4th push button is pressed , then
only B2 gets High (1) input, therefore only B2’s
output is High(1) and ,the output is
B3 B2 B1 B0 =0100 = 4
8
Denary to Binary Encoder
Decimal B3 B2 B1 B0
number
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
From the above table it is evident that B3 B2 B1 B0 are connected to inputs
wherever there are 1’s.
As B0 has value 1 for 1,3,5,7and 9 , therefore it is connected to 1,3,5,7,9 switch.
Similarly B1 has value 1 for 2,3,6 and 7 , thus it is connected to buttons 2,3,6,7.
9
Same for B2 and B3.
Practice
For 8 inputs (0-7), the minimum number of outputs
required are,
23 >= 8
This will be called as 8 to 3 encoder(octal to binary or
3-bit encoder ).
Draw the truth table for 8 to 3 Encoder
Draw the circuit diagram for the same.
10
Practice
Draw the truth table for Hex to Binary Encoder ( 16 to
4 encoder).
Draw the circuit diagram for the same.
11
Decoders
A decoder is a device which does the reverse of an encoder,
undoing the encoding so that the original information can
be retrieved. The same method used to encode is usually
just reversed in order to decode.
For converting numerical data from binary to denary form
we can use decoder.
12
Encoder and decoder
I0 I0
B3
I1 I1
I2 B2
Decimal I2
to B1 4 to 10
Binary Decoder
Encoder B0
I9
I9
13
Decoders
A decoder which can accept 2 input signals is capable
of representing 22 i.e. 4 distinct elements of coded
data. A truth table of 2 by 4 decoder will be as follows:
Inputs Outputs
b1 b0 d0 d1 d2 d3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
d0
d1
Output
d2
d3
15
Practice
Draw the truth table for 3 by 8 decoder.
Draw the circuit diagram for the same.
16
Application of Encoder and Decoder
Encoder
In digital calculators
Conversion from decimal to binary in computers
Decoder
Digital clock
Conversion from binary to decimal in computers
17