# Priority Encoder

## Priority Encoder

An encoder essentially performs the reverse of a decoder function in a combinational logic circuit. The process of converting from symbols or numbers to coded format is called encoding. A priority encoder has a priority function which allows it to produce an output corresponding to the highest-order input.

A priority encoder is, in a sense, the dual (or opposite) of the decoder circuit‚ it receives N inputs (where N is typically 4, 8 or 16), and asserts an output binary code of M=log2N bits (so the M-bit binary code is typically 2, 3, or 4 bits). The M-bit binary code indicates which input was asserted (i.e., in a 4:2 binary encoder, binary code 00 would be output if the 0th input line was asserted, binary code 01 would be output of the 1st input line was asserted, etc.). Since more than one input line to the encoder might be asserted at any given time, the priority encoder asserts an output code corresponding to the highest numbered input that is asserted (i.e., if both input line 0 and input line 2 were asserted in a 4:2 encoder, then binary code 10 would be output indicating that input line 2 is the highest line number‚ or highest priority input‚ currently asserted). Figure 1 below shows a priority encoder block.

At first thought, a four-input encoder circuit should require just two outputs. In such a circuit, asserting the 3rd input signal would cause an “11” output, asserting the 2nd input signal would output a “10”, asserting the 1st input signal would output a “01”, and asserting the 0th input would output “00”. But what if no inputs are asserted? Again, a “00” would be appropriate. To avoid creating an ambiguous “00” output, encoders typically use an “Enable In” (EIN) signal and an “Enable Output” (EOUT) signal.