Encoder - eclubiitk/EClub-Handbook GitHub Wiki
An Encoder is a combinational circuit that performs the reverse operation of Decoder. It has maximum of 2^n input lines and ānā output lines. It will produce a binary code equivalent to the input, which is active High.
Therefore it 'encodes' a 2^n long binary string to a n long binary string. A combination of 4 ones and zeroes is encoded to a combination of 2 ones and zeroes. This will become apparent as you read on. It is optional to represent the enable signal in encoders.
A normal Encoder has a few drawbacks. They are solved by modifying the normal encoders to make a priority encoder.
Since this is a pretty long tutorial, the contents are as follow:
Octal to Binary Encoder
Octal to binary Encoder has eight inputs, Y7 to Y0 and three outputs A2, A1 & A0. Octal to binary encoder is nothing but 8 to 3 encoder. The block diagram of octal to binary Encoder is shown in the following figure.
From Truth table, we can write the Boolean functions for each output as
We can implement the above Boolean functions by using four input OR gates. The circuit diagram of octal to binary encoder is shown in the following figure.
The above circuit diagram contains three 4-input OR gates. These OR gates encode the eight inputs with three bits.
Drawback
If more than one input is active High, then the encoder produces an output, which may not be the correct code. For example, if both Y3 and Y6 are ā1ā, then the encoder produces 111 at the output. This is neither equivalent code corresponding to Y3, when it is ā1ā nor the equivalent code corresponding to Y6, when it is ā1ā.
So, to overcome these difficulties, we should assign priorities to each input of encoder. Then, the output of encoder will be the binary code corresponding to that active HIGH inputs which has higher priority. This encoder is called as priority encoder.
Priority Encoder
A 4 to 2 priority encoder has four inputs Y3, Y2, Y1 & Y0 and two 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.
We considered one more output V in order to know whether the code available at outputs is valid or not. If all the inputs are LOW, V is LOW. If at least one input is HIGH, V is HIGH.
The Truth table of 4 to 2 priority encoder is shown below.
The boolean expression for the truth table above is
We can implement the above Boolean functions using logic gates. The circuit diagram of 4 to 2 priority encoder is shown in the following figure.
The above circuit diagram contains two 2-input OR gates, one 4-input OR gate, one 2input AND gate & an inverter. Here AND gate & inverter combination are used for producing a valid code at the outputs, even when multiple inputs are equal to ā1ā at the same time. Hence, this circuit encodes the four inputs with two bits based on the priority assigned to each input.
IC 74148
IC 74148 is a 8 to 3 priority encoder. The input pins (0,1,2,...,7) give us the information to be encoded. The output pins are A0,A1,A2. The pin diagram is given below.
Here E1 is the active LOW enable pin that activates the encoder. An active LOW device takes a LOW input to turn itself ON and outputs 0 if its working. It basically reverses all input and output values.
The E0 is active LOW output that works in place of the output V previously mentioned. It only accounts for the input pins, not for the enable pin E1. GS is a more complete form of output V tht takes care of everything. The truth table should make it fairly clear.
The internal logic circuit is given below
The datasheet is available here