Skip to main content
Logo image

Section 4.4 Encoders

A one-hot decoder, Figure 4.2.1, activates one of its outputs based on the input binary code. An encoder outputs a binary code to indicate which of several inputs has been asserted. You might, for example, have four pushbutton switches labelled 0 through 3, and you would like to display the binary code "10" when button 2 is presseed.
The potential problem, of course, is that more than one button could be pressed at the same time. Or, if you had four peripheral devices, each with data to communicate to you, more than one could be vying for your attention. The solution is for the encoder to prioritize its inputs, e.g., lower numbered inputs have higher priority: if inputs 1 and 3 are asserted at the same time, the output is "01". This device is called a priority encoder.
described in detail following the image
Figure 4.4.1. An encoder assigns a binary output code indicating which of its inputs is asserted. Input x0 may be omitted so that output "00" indicates no inputs are asserted.

Checkpoint 4.4.2.

  1. Write the truth table for a four-input, two-output, priority encoder. Input 0 has highest priority.
  2. A potential problem is what to output when no inputs are asserted. One solution would be to have only three inputs, 1 through 3, and assign the output code "00" when none of the three inputs is asserted. Modify your truth table accordingly.
  3. Write logic equations for the encoder

Checkpoint 4.4.3.

Repeat the previous exercise, truth table and logic equations, with priority reversed, so that input 3 has highest priority. Instead of sacrificing one input so that "00" can indicate that nothing has been asserted, add an addtional output bit that is ’1’ if at least one of four inputs is asserted, and ’0’ if no inputs are asserted.
(Spoiler alert) Please attempt the preceding exercises before watching this video.