1
Encoder in Digital Logic
An Encoder is a combinational circuit that performs the reverse operation of
[Link] has maximum of 2^n input lines and ‘n’ output lines, hence it
encodes the information from 2^n inputs into an n-bit code. It will produce a
binary code equivalent to the input, which is active High. Therefore, the encoder
encodes 2^n input lines with ‘n’ bits.
4 : 2 Encoder –
The 4 to 2 Encoder consists of four inputs Y3, Y2, Y1 & Y0 and two outputs
A1 & A0. At any time, only one of these 4 inputs can be ‘1’ in order to get the
respective binary code at the output. The figure below shows the logic symbol
of 4 to 2 encoder :
2
logical expression for A1 and A0 :
A1 = Y3 + Y2
A0 = Y3 + Y1
The above two Boolean functions A1 and A0 can be implemented using two
input OR gates :
8 : 3 Encoder (Octal to Binary) –
The 8 to 3 Encoder or octal to Binary encoder consists of 8 inputs : Y7 to Y0
and 3 outputs : A2, A1 & A0. Each input line corresponds to each octal digit
and three outputs generate corresponding binary code.
The figure below shows the logic symbol of octal to binary encoder:
Logical expression for A2, A1 and A0 :
A2 = Y7 + Y6 + Y5 + Y4
3
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y7 + Y5 + Y3 + Y1
The above two Boolean functions A2, A1 and A0 can be implemented using
four input OR gates :
Decimal to BCD Encoder –
The decimal to binary encoder usually consists of 10 input lines and 4 output
lines. Each input line corresponds to the each decimal digit and 4 outputs
correspond to the BCD code. This encoder accepts the decoded decimal data
as an input and encodes it to the BCD output which is available on the output
lines. The figure below shows the logic symbol of decimal to BCD encoder :
4
The truth table for decimal to BCD encoder is as follows:
5
Priority Encoder –
A 4 to 2 priority encoder has 4 inputs : Y3, Y2, Y1 & Y0 and 2 outputs : A1 &
A0. Here, the input, Y3 has the highest priority, whereas the input, Y0 has
the lowest priority. In this case, even if more than one input is ‘1’ at the same
time, the output will be the (binary) code corresponding to the input, which is
having higher priority.
The truth table for priority encoder is as follows :
6
Drawbacks of Normal Encoders –
1. There is an ambiguity, when all outputs of encoder are equal to zero.
2. If more than one input is active High, then the encoder produces an output,
which may not be the correct code.
So, to overcome these difficulties, we should assign priorities to each input of
encoder. Then, the output of encoder will be the ( code corresponding to the
active High inputs, which has higher priority.
Uses of Encoders –
1. Encoders are very common electronic circuits used in all digital systems.
2. Encoders are used to translate the decimal values to the binary in order to
perform the binary functions such as addition, subtraction, multiplication, etc.
3. Other applications especially for Priority Encoders may include detecting
interrupts in microprocessor applications.
7
Decoders
Decoder is a combinational circuit that has ‘n’ input lines and maximum of 2 n output
lines. One of these outputs will be active High based on the combination of inputs
present, when the decoder is enabled. That means decoder detects a particular code.
The outputs of the decoder are nothing but the min terms of ‘n’ input
variables lineslines, when it is enabled.
2 to 4 Decoder
Let 2 to 4 Decoder has two inputs A 1 & A0 and four outputs Y3, Y2, Y1 & Y0. The block
diagram of 2 to 4 decoder is shown in the following figure.
One of these four outputs will be ‘1’ for each combination of inputs when enable, E is
‘1’. The Truth table of 2 to 4 decoder is shown below.
Enable Inputs Outputs
E A1 A0 Y3 Y2 Y1 Y0
0 x x 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
8
From Truth table, we can write the Boolean functions for each output as
Y3=E.A1.A0Y3=E.A1.A0
Y2=E.A1.A0′Y2=E.A1.A0′
Y1=E.A1′.A0Y1=E.A1′.A0
Y0=E.A1′.A0′
Each output is having one product term. So, there are four product terms in total. We
can implement these four product terms by using four AND gates having three inputs
each & two inverters. The circuit diagram of 2 to 4 decoder is shown in the following
figure.
Therefore, the outputs of 2 to 4 decoder are nothing but the min terms of two input
variables A1 & A0, when enable, E is equal to one. If enable, E is zero, then all the
outputs of decoder will be equal to zero.
3 to 8 line decoder:
The 3 to 8 line decoder is also known as Binary to Octal Decoder. In a 3 to
8 line decoder, there is a total of eight outputs, i.e., Y 0, Y1, Y2, Y3, Y4, Y5, Y6,
and Y7 and three outputs, i.e., A 0, A1, and A2. This circuit has an enable input
'E'. Just like 2 to 4 line decoder, when enable 'E' is set to 1, one of these four
outputs will be 1. The block diagram and the truth table of the 3 to 8 line
encoder are given below.
9
Truth Table:
The logical expression of the term Y0, Y1, Y2, Y3, Y4, Y5, Y6, and Y7 is as follows:
Y0=A0'.A1'.A2'
Y1=A0.A1'.A2'
Y2=A0'.A1.A2'
Y3=A0.A1.A2'
Y4=A0'.A1'.A2
Y5=A0.A1'.A2
Y6=A0'.A1.A2
Y7=A0.A1.A2
10
Logical circuit of the above expressions is given below: