2-to-4 decoder

Two input bits, four output lines — exactly one fires at a time. A ready-made routing circuit you can open in the TorchAnvil simulator.

Turning a number into a chosen line

A decoder converts a compact binary number into a one-hot signal: a set of output lines where exactly one is high and the rest are low. Two input bits S1 S0 name one of four outputs Y0..Y3, and the decoder lights up that specific one.

How it works

Each output is a unique AND of the selector bits or their negations:

Every row of the truth table hits exactly one AND, because the four conditions partition every possible (S1, S0) combination.

S1 S0 Y0 Y1 Y2 Y3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1

Why it matters

Address decoders are how a CPU picks which memory cell to talk to. A 16-bit address runs into a 16-to-65536 decoder, and exactly one word line fires. The same idea drives instruction decoders, 7-segment displays, and chip-select logic on every motherboard. Scale the bits up, the pattern stays the same: n input bits fan out to 2^n outputs, with one-hot as the rule.

Try this