A decoder's output code normally has more bits than its input code. If the device's output code has fewer bits than the input code, the device is usually called an encoder. So an encoder performs the function opposite to that of a decoder. It encodes the given information into a more compact form. The most commonly used encoders are binary encoders and priority encoders.
7.7.1 Binary Encoder
A binary encoder encodes information from 2N inputs into an N-bit code. Exactly one of the input signals should have a value of 1, and the outputs present the binary number that identifies which input is equal to 1. A binary encoder converts only one input at a time into a binary code. The general structure of a binary encoder circuit is shown in Figure 7.20. A 4: 2 binary encoder, which has four inputs and two outputs, is illustrated in Figure 7.21. The modified truth table is shown in Figure 7.21. Notice that only one input isset at any time. All other states with multiple inputs, which are set, are considered don't-care states and are not shown in the truth table. Consequently, the logic circuit implementation of the 4 : 2 binary encoder has only two OR gates. Notice also that x1 does not have any effect on either output y1 or y2.
7.7.2 Priority Encoder
A priority encoder is an encoder where more than one input can be activated ...