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

  1. 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
  2. Encode. The Priority encoder block, or gates: A1 = D3 + D2, A0 = D3 + D̄2·D1, V = any input.
  3. Prove it. All 16 input patterns: the highest 1 wins.

Truth table

D3D2D1D0A1A0V
0000000
0001001
0010011
0011011
0100101
0101101
0110101
0111101
1000111
1001111
1010111
1011111
1100111
1101111
1110111
1111111

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.

More combinational builds