4-to-2 priority encoder: build and simulate it online
The number of the highest input that is 1, in binary, plus V (valid).
Build the 4-to-2 priority encoder in the free online simulator — it checks your circuit automatically.
What you need
- 4 logic switches labelled D3, D2, D1, D0
- 3 probes labelled A1, A0, V
- an encoder (block or gates)
Step by step
- Inputs and outputs. From the Logic section of the library, drop digital inputs (0/1 boxes) or logic switches for the inputs, and digital outputs or probes for the outputs; give each its label in the inspector (the checker finds them by label). Switches D3, D2, D1, D0; Probes A1, A0, V
- Encode. The Priority encoder block, or gates: A1 = D3 + D2, A0 = D3 + D̄2·D1, V = any input.
- Prove it. All 16 input patterns: the highest 1 wins.
Truth table
| D3 | D2 | D1 | D0 | A1 | A0 | V |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Frequently asked questions
How do you build a 4-to-2 priority encoder?
The number of the highest input that is 1, in binary, plus V (valid). In short: inputs and outputs, then encode, then prove it.
What is the truth table of a 4-to-2 priority encoder?
It has 4 inputs (D3, D2, D1, D0) and 3 outputs (A1, A0, V), so 16 rows. The full table is on this page; the Embedded Lab checks all of them against your circuit.
What parts do you need for a 4-to-2 priority encoder?
an encoder (block or gates) — plus logic switches for the inputs and probes for the outputs.
Can I simulate a 4-to-2 priority encoder online for free?
Yes. Open it in the BitForBytes Embedded Lab, a free browser-based circuit and logic simulator: drag in the gates, wire them, and press "Check my circuit" — every input combination is simulated and marked for you. No download or sign-up needed.
Part of DSD 24 · Encoders in the free BitForBytes digital system design course.