4:2 priority encoder
A priority encoder converts the position of the highest active input line into a binary number.
Open this circuit in LogicLab →
Boolean expressions
- Y1 = I3 + I2
- Y0 = I3 + I2′·I1
- V = I0 + I1 + I2 + I3
Truth table
| I0 | I1 | I2 | I3 | Y1 | Y0 | V |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 0 | 1 | 0 | 1 |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
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