Binary to one-hot
Figure: A schematic-style diagram showing 2 binary input lines labelled A1, A0 feeding into a decoder block
A decoder takes a binary address and activates exactly one output line, the one matching that address. Every other output stays 0.
- A 2-to-4 decoder: 2 address bits, 4 outputs.
- A 3-to-8 decoder: 3 address bits, 8 outputs.
- An -to- decoder in general.
One-hot outputs
A 2-to-4 decoder with address bits a and b:
| a | b | | | | |
|---|
| 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 |
Exactly one output is 1 in every row. This pattern is called one-hot: one line hot, the rest cold.
One AND gate per output
Each output is a single AND gate that fires for exactly one input pattern. To detect , invert both inputs and AND them: , which is 1 only when both are 0.