Priority encoder

Three input, two output priority encoder. Input priority increases top to bottom. The output is a binary number of the currently active input with highest priority, binary zero (00) if none is active.

Priority encoder is a multi-input device which tells the binary number of the input, having the highest priority. They are used to control interrupt requests by acting on the request that has the highest priority assigned. If multiple inputs are given at the same time, the input having the highest priority takes precedence. For instance, if the printer notifies that it ready to print more data and at the same time the user presses a key on the keyboard, it is better to service the keystroke first; the printer can wait for several seconds. In some devices timer interrupt may happen as often as every millisecond and must be serviced within that millisecod as otherwise the internal clock will start to lag.

At typical these days interrupt controller is also capable of shifting priorities if programmed to do so (the most recently serviced interrupt takes lowest priority). After interrupt happens, CPU normally only enables following interrupts of the same or lower priority after the current interrupt has already been serviced.

The "got something" input

In some sources like [1] the encoder has an "imaginary" input (x0) that has no effect on the output. It likely means "if there is nothing else to serve, serve this, even it it does not require attention at the momemt", or maybe that the controller is used together with other circuits that help to distinguish between "some interrupt" and "no interrupt" states. It is usually understood as the "lowest priority" input, x0. This input is not pictured in the first diagram.

Other authors picture a separate "got something" output of the encoder that is active when any input is active[2] (can be called "idle" if inverted). This allows to use the all-zero output combination to indicate an interrupt as well. This "got something" (or "group select") input, often marked as GS, is also important in cascading multiple encoders.

The truth table of the four input device with GS output would look like

The discussed encoder outputs the number of the device to serve in a binary form (00,01,10,11). If required, a binary decoder can convert this output to a set of bits each for one of the actual devices (0, 1, 2 or 3).

Four input, two output priority encoder that uses "got something" signal to notify about the happening interrupt. The output combination 00 now can serve one more interrupt capable device.


Recent computer may have tens of possible interrupts. When cascading, the "got something" signals of the second rank encoders are connected as inputs of the first (higher) rank encoder. The output of the first rank encoder now contains the number of the second rank device which output should be cared about. Additional circuits are necessary to pick the lower digits from actually "attended" second rank device. To simplify these circuits, the encoder may have additional "enable output" input that disables (forces to zero or low impedance) all signals apart the "got something".


  1. 1 Priority encoder
  2. 2 Lectureon priority encoder