2-to-4 decoder: build and simulate it online

Two inputs select exactly one of four outputs.

Build the 2-to-4 decoder in the free online simulator — it checks your circuit automatically.

What you need

  • 2 logic switches labelled A, B
  • 4 probes labelled D0, D1, D2, D3
  • a decoder (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 A (MSB), B; Probes D0, D1, D2, D3
  2. Decode. The Decoder block, or four ANDs: D0 = ĀB̄, D1 = ĀB, D2 = AB̄, D3 = AB.
  3. Prove it. All four codes. One-hot: exactly one D is 1

Truth table

ABD0D1D2D3
001000
010100
100010
110001

Frequently asked questions

How do you build a 2-to-4 decoder?

Two inputs select exactly one of four outputs. In short: inputs and outputs, then decode, then prove it.

What is the truth table of a 2-to-4 decoder?

It has 2 inputs (A, B) and 4 outputs (D0, D1, D2, D3), so 4 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 2-to-4 decoder?

a decoder (block or gates) — plus logic switches for the inputs and probes for the outputs.

Can I simulate a 2-to-4 decoder 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 23 · Decoders in the free BitForBytes digital system design course.

More combinational builds