LogicLab

4:2 priority encoder

A priority encoder converts the position of the highest active input line into a binary number.

Circuit diagram of the 4:2 priority encoder

Open this circuit in LogicLab →

Boolean expressions

Truth table

I0I1I2I3Y1Y0V
0000000
0001111
0010101
0011111
0100011
0101111
0110101
0111111
1000001
1001111
1010101
1011111
1100011
1101111
1110101
1111111

How it works

If several inputs are 1 at once, the highest-numbered one wins. Y1 is 1 when I3 or I2 is active, Y0 is 1 for I3 or for I1 when I2 is not active, and the valid output V shows that at least one input is active.

Try it yourself

Encodes the highest-numbered active input into a 2-bit code and flags when any input is active. Open the circuit, click the switches to change the inputs, and watch the LEDs and the waveform panel respond. You can edit the circuit, convert it to NAND-only or NOR-only gates, and save or export your version.

Related circuits

Reference: en.wikipedia.org/wiki/Priority_encoder