The 2-to-4 decoder
A decoder turns a binary number into “which one”. A 2-to-4 decoder has two inputs, S1 and S0, that form a number from 0 to 3, and four outputs Y0 to Y3. Exactly one output is 1: the one whose number is on the inputs.
Truth table
| 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 |
Try it Click the inputs to change them.
Y01Y10Y20Y30
How it works
Each output recognises one combination. Y2 must be 1 only for S1 = 1 and S0 = 0, so Y2 = S1 AND NOT S0. The other outputs follow the same pattern: each one is an AND of S1 or its opposite with S0 or its opposite. Two NOT gates provide the opposites for all four.
Decoders pick things out by number: which memory chip answers an address, which digit of a display is lit, which instruction a processor is running.
Hints and solution
Try on your own first. Each hint gives away a little more.
- Y2 should be 1 for S1 = 1, S0 = 0.
- Each output is an AND of S1 or NOT S1 with S0 or NOT S0.