Skip to content
BetterDL

Priority encoder

Also called: priority encoders, 4-to-2 priority encoder, 8-to-3 priority encoder

An encoder that outputs the index of the highest-priority active input when several are active, plus a valid bit V that shows whether any input is active.

A priority encoder is an encoder with a rule for crowds. When several inputs are 1 at once, it reports only the one with the highest priority and ignores the rest. Usually the highest-numbered input wins, but a design can rank them any way.

It also has a valid bit V = 1 whenever at least one input is active. Without V, "only D0 active" and "nothing active" would both output 00.

For a 4-to-2 priority encoder with D3 highest:

  • Y1 =
  • Y0 =
  • V =

The in Y0 is the priority at work: D1 may only set Y0 when D2 isn't active, because D2 outranks it.

Filling its truth table is quickest in blocks, from the top priority down. Every row with D3 = 1 outputs 11, whatever the other bits are. Then every row with D3 = 0 and D2 = 1 outputs 10, and so on.

Where it shows up: interrupt controllers (several devices ask the CPU for attention; the most urgent is served first) and keyboards (several keys pressed together).

D2D1D0Y1Y0V

Worked examples

Example

An 8-to-3 priority encoder

D7 has the highest priority. Inputs D7…D0 = 00101001.

  1. 1.

    Active inputs: D5, D3 and D0.

  2. 2.

    Scan from D7 down: D7 = 0, D6 = 0, D5 = 1. Stop.

  3. 3.

    D5 wins: Y2 Y1 Y0 = 101, V = 1. D3 and D0 are ignored.

Example

Lowest index wins

Some designs give D0 the highest priority. Same inputs, 00101001.

  1. 1.

    Scan from D0 up: D0 = 1. Stop.

  2. 2.

    Output 000 with V = 1.

  3. 3.

    V is what tells this apart from "no input active", which also outputs 000 but with V = 0.

Common mistakes

  • Reading the input string in the wrong order. D7…D0 = 00101001 lists D7 first, so the leftmost 1 is D5, not D2.

  • Leaving out V. Without it, the encoder can't distinguish its lowest-priority input from no input at all.

  • Writing Y0 = for the priority version. That's the plain encoder's equation; it gives 11 for D2 and D1 together.

Practice Priority encoder

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Priority encoder is taught in Combinational Logic.