**Encoder Definition**

An encoder is a digital combinational circuit that converts binary information of maximum 2n input lines into n output lines. The correspondent input binary value generates the output lines.

**Encoder Circuit**

**Example of an encoder:**

**Octal to Binary Encoder**

It has inputs for each of the octal digits that is a total of eight in number. It has three output lines (according to the rule that the 2n input line encoder will have n output line). The outputs represent the numbers in binary.

The encoder can be implemented using OR gates. Output C is equal to 1 if the octal digit’s value is 1, 3, 5, 7. The output B will be one if the octal number has a value of 2, 3, 6, 7. The output AS will be one if the input octal digits’ value is 4, 5, 6, 7. The following Boolean expressions represent the outputs.

A = O_{4} + O_{5} + O_{6} + O_{7}

B = O_{2} + O_{3 }+ O_{4} + O_{7}

C = O_{1} + O_{3} + O_{6} + O_{7}

O_{0} | O_{1} | O_{2} | O_{3} | O_{4} | O_{5} | O_{6} | O_{7} | A | B | C |

1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |

0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |

0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |

0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 |

0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |

0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |

The encoder implemented at the table has the only limitation. That is, only one input can be in active mode at any given time. That is why if two inputs are made active, then the output lines produce undefined outputs.

Let us take an example if the input O3 is in an active state as well as input O6 is also in an active state, then the encoder produces output as 111. The result neither represent O6 nor O3. So, there is a mess.

To solve this problem, new encoders are designed with an input priority to make sure that only one input gets enabled at a time. If priority is set high for higher digits in this new system, then for enabled O3 and O6, the output will be 110, representing 6 in binary. This happens as O6 has a higher priority than O3.

**Priority Encoder**

A priority encoder is a particular type of encoder circuit which has a priority function for the inputs. The priority function works in the real world. For example, if there is a queue and you have a high priority, you go first! If there is an operation where both the input values are 1, then the 1 with the highest priority will take precedence.

O0 | O1 | O2 | O3 | A | B | Y |

0 | 0 | 0 | 0 | X | X | 0 |

1 | 0 | 0 | 0 | 0 | 0 | 1 |

X | 1 | 0 | 0 | 0 | 1 | 1 |

X | X | 1 | 0 | 1 | 0 | 1 |

X | X | X | 1 | 1 | 1 | 1 |

As we can see from the truth table of the priority encoder, it has three outputs. Two are general outputs; another one, Y, is a valid bit indicator.

The right bit indicator is set to 1 when one or more than one input has a value of 1. If there are such conditions, where all inputs are set to 0 or the information is not valid, then Y also becomes 0. There is no checking of other outputs if the Y term is 0.

Then, they are specified as don’t-care terms. Truth tables use don’t-care words to represent 0 or 1 rather than listing up 16 terms for variables. For example, 100X means either 1000 or 1001.

As mentioned earlier, the higher the subscript number, the priority of the number gets high. From the truth table, we can see that input O3 has the highest priority as the input. That is why whatever the values for other input digits when the O3 value is 1, the output becomes 11. Similarly, O2 has a priority lower than O3 and higher than O1 and O0. When the input of O2 is 1, the result will be 10. In the same way, for O1, the output is 01, and for O0, the outcome will be 00.

The Boolean function for the priority encoder will be:

A = D2 + D3

B = D3 + D1 D2’

Y = D0 + D1 + D2 + D3

**How does a priority encoder circuit differ from multiplexer? Read Here!**

**DECODERS**

**Definition and Overview**

A decoder is a combinational circuit that does the opposite operation of an encoder circuit. It decodes or simplifies the encoded information from n input lines to a maximum of 2n output lines.

**Decoder Circuit**

Binary codes represent information of distinct quantities. An n bit binary code can represent a maximum of 2n different elements of encoded data. A decoder decodes that information and provides the output.

Decoders are specified as numbers of input to numbers of output line decoders. If the number of input lines is n, then there will be a maximum of 2n output. Every single input combination produces a distinct output value.

To illustrate the working of a decoder, let us take the example of a 3:8 decoder. The specification suggests that the circuit will decode the three input lines into eight outputs of every single output represents the min-terms. The connected NOT gates inverts the input data lines whenever necessary. The AND gates (total eight in number) produces the min-terms (each for one output).

A | B | C | O_{0} | O_{1} | O_{2} | O_{3} | O_{4} | O_{5} | O_{6} | O_{7} |

0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |

0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |

0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |

1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |

1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |

1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |

1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

From the truth table, we can observe that seven outputs have a value of 0 and one output, which have a value of 1. The outcome, which has a value of 1, represents the actual input value or the min-term.

There are decoders that are constructed with universal basic gates like NAND and NOR. Using a NAND gate is economical as well as efficient to build a decoder. Decoders also need to enable inputs like encoders. The decoder gets enabled when the enable input pin has a value of 0. Only one output may have a value of 0 at a time, and the rest of the outputs will be equal to 1. The truth table below simplifies the operation.

Enable | A | B | O0 | O1 | O2 | O3 |

1 | X | X | 1 | 1 | 1 | 1 |

0 | 0 | 0 | 0 | 1 | 1 | 1 |

0 | 0 | 1 | 1 | 0 | 1 | 1 |

0 | 1 | 0 | 1 | 1 | 0 | 1 |

0 | 1 | 1 | 1 | 1 | 1 | 1 |

The circuits get disabled if the E value is set to 1. Like the encoder circuit, if the E value is set to 1, there will be no checking of other inputs. In the disabled state of the decoder, no outputs have the value 0, and no min-term is elected. Many decoders have more than one enables pin. They need to abide by the logical operations to perform as a decoder.

A demultiplexer can be made using a decoder if the decoder is added with enable inputs. Parallelly corresponding decoders can make large decoders.

**Implementation of logic using decoders**

A decoder has 2n input data lines and n output lines. 2n represents the minterms, and n represents the number of variables using which the minterms are formed. As mentioned earlier, for each combination of inputs, there are different outputs.

A decoder can be used to implement logic gates as Boolean functions are nothing but the sum of minterms. An OR gate connected with a decoder can implement the logic of a Boolean function.

**Applications of Encoders and Decoders**

Encoder circuit and decoder circuit have applications in smart digital devices as they are significant for today’s’ digital era.

Some of the significant applications are –

- Speed Control of modern motors.
- Night vision cameras
- Metal detectors
- encoder circuit has applications in Robotic vehicles
- Automation system – especially the home automation system.
- Automatic Monitoring systems has different types of encoder circuits.
- Encoder circuit has utilized in encrypted communications system.