## Encoder:

An encoder in digital electronics is a combinational circuit that has 2 to the power n inputs and n outputs. The encoder produces a #binary code equivalent to the given input. The #encoder encodes information from 2^n inputs to n outputs.

### Types of Encoders:

4 to 2 line encoder:

4 can be written as 2^2 so the inputs are 4 and the outputs are 2. Let the outputs be A1 and A0 and the inputs be Y3, Y2, Y1, Y0. At any time any one of the inputs will be 1 and the respective Binary code will be the output.

The following is the truth table of 4 to 2 encoder

```
The logical expressions for A1 and A0 are
A1 = Y3 + Y2
A0 = Y3 + Y1
```

8 to 3 line encoder:

8 to 3 line encoder has 8 inputs and 3 outputs. It is also known as #octal to Binary encoder.

Let the inputs be Y7, Y6, Y5, Y4, Y3, Y2, Y1, Y0, and the inputs be A2, A1, and A0. One of the 8 inputs is set to 1 to get the respective Binary code as output.

The following is the truth table of 8 to 3 encoder

```
The logical expressions for A1, A2 and A0 are
A2 = Y7 + Y6 + Y5 + Y4
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y7 + Y5 + Y3 + Y1
```

Decimal to BCD Encoder:

BCD is a Binary Coded Decimal. The decimal to #BCD encoder has ten(10) input lines and four(4) output lines. Each decimal digit is each input to ten input lines and the output at the four output lines is the BCD code. Decoded decimal data is given as input to this encoder and it encodes the given input to BCD output, the output is available at the output lines.

The following is the truth table of the Decimal to BCD encoder

```
The logical expressions for A3, A2, A1 and A0 are
A3 = Y9 + Y8
A2 = Y7 + Y6 + Y5 + Y4
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y9 + Y7 + + Y5 + Y3 + Y1
```

In the normal encoder circuits, there are certain drawbacks. They are

When the output is zero, there is the ambiguity that whether it corresponds to one input as zero or all inputs as zeroes.

The encoder may produce incorrect output when the two inputs are high.

To overcome the above drawbacks, priority encoders are used, in which the output will be based on the priority of the inputs.

Priority Encoder:

The output of Priority Encoder is the currently active input that has the highest priority among the given inputs. Let us understand the priority encoder by taking an example of a 4 to 2 priority encoder.

The number of inputs and outputs in a 4 to 2 priority encoder are 4 and 2 respectively. Let the outputs be A1 and A0 and the inputs be Y3, Y2, Y1, Y0. The input Y3 has the highest priority and the input Y0 has the lowest priority. The binary code which has the highest priority will be the output.

The following is the truth table of the priority encoder

The above Boolean functions can be implemented using logic gates as follows

### Applications of Encoder:

Encoders are used in calculators to encode decimal values in binary to perform certain binary functions.

Digital #signals can be generated by using an encoder.

The number of connections and wires can be reduced by using a priority encoder in some electronic circuits and in some applications with multiple inputs. They are also used to detect interrupts in microprocessor applications.

They are used in Printed Circuit boards (#PCB).

Encoders are also used in magnetic positional control for positioning #robotic arms and ship #navigation.

## Decoder:

A #decoder in digital electronics is a combinational circuit that has n inputs and 2 to the power of n outputs. The output of the decoder is a maximum of 2^n unique output lines. The binary information from n input lines is converted to a maximum of 2^n unique output lines in the decoder. The operation of decoder is reverse to that of encoder.

### Types of Decoders:

2 to 4 decoder:

The 2 to 4 decoder has 2 input and 4 output lines. Let the inputs be A1 and A0 and the outputs be Y3, Y2, Y1, Y0. The following is the block diagram of 2 to 4 decoder

When the enable pin is set i.e., when E=1, for each input combination given at input lines one of the outputs will be high.

The following is the truth table of 2 to 4 decoder

The Boolean expressions for each output can be written from the above truth table as follows

```
Y3 = E.A1.A0
Y2 = E.A1.(A0)'
Y1 = E.(A1 )'.A0
Y0 = E.(A1 )'.(A0)'
```

The above Boolean functions can be implemented using logic gates as follows

3 to 8 Decoder:

The 3 to 8 Decoder has 3 input and 8 output lines. Lower order decoders can be used to implement higher decoders. So, 3 to 8 decoder can be implemented with 2 to 4 decoders. Let the inputs of 3 to 8 decoder be A2, A1, and A0 and the outputs be Y7, Y6, Y5, Y4, Y3, Y2, Y1, Y0.

If the number of outputs of the lower-order decoder is 'm1' and if the number of outputs of the higher-order decoder is 'm2' then the number of lower-order decoders required to implement higher-order decoders is given as (m2/m1).

3 to 8 decoder can be implemented using 2 to 4 decoders as follows

Here, the value of m1 is 4 and the value of m2 is 8.

Therefore, (m2/m1) is (8/4) = 2

The number of 2 to 4 decoders required to implement a 3 to 8 decoder are two.

The block diagram of 8 to 3 decoder using 2 to 4 decoder is shown below

The inputs A1 and A0 are applied to each of the 2 to 4 decoders. The input pin A2 is given at the Enable pin of the decoder. When A2 is high, the output will be from pins Y7 to Y4 and when A2 is low, the outputs will be from Y3 to Y0 i.e., one of the two decoders will be enabled at a time.

4 to 16 Decoder:

The 4 to 16 Decoder has 4 input and 16 output lines. Let the inputs of 4 to 16 decoder be A3, A2, A1, and A0 and the outputs be Y15,Y14,Y13,Y12,Y11,Y10,Y9,Y8,Y7, Y6, Y5, Y4, Y3, Y2, Y1, Y0.

4 to 16 decoder can be implemented using 3 to 8 decoders as follows

Here, the value of m1 is 8 and the value of m2 is 16.

Therefore, (m2/m1) is (16/8) = 2

The number of 3 to 8 decoders required to implement a 4 to 16 decoder are two.

The block diagram of 4 to 16 decoder using 8 to 3 decoder is shown below

The inputs A2, A1 and A0 are applied to each of the 3 to 8 decoders. The input pin A3 is given at the Enable pin of the decoder. When A3 is high, the output will be from pins Y15 to Y8 and when A3 is low, the outputs will be from Y7 to Y0 i.e., one of the two decoders will be enabled at a time.

### Applications of Decoder:

Decoders are used in code conversions.

They are used in demultiplexing.

They are used in half adder and full adder circuits.

In Central Processing Unit (CPU) ,decoders are used as instruction decoder.

They are used in storage devices.

See Also:

Follow us -

Please do follow us i.e #learnelectronicsindia to get daily updates about new blogs, videos, courses, quizzes, and contests.

Author -

Written By: Nagapuri Swathi