Topic 6 of 13
Decoders, Encoders & Data Selectors
Circuits that route and select data: decoders, encoders, multiplexers and demultiplexers.
← → move between slides · F full screen · M slide list
Before we start
Why this matters
How does one skinny TV cable smuggle in a hundred channels at once, and how does your remote pick exactly one without opening the wall to check?
The cable is basically shouting every channel at the same time; a multiplexer inside the TV politely tells 99 of them to be quiet and listens to just one. Your remote does the reverse trick, squashing “channel 214” into a couple of button presses. Decoders, encoders and multiplexers are the bouncers of digital design — today you build the velvet rope.
Outline
Topics in this chapter
Select a topic to jump to the slide that explains it.
Concept 1 of 4
Decoders
An n-to-2n decoder turns an n-bit code into one active output line. Each output is a minterm of the inputs. For a 2-to-4 decoder: Y0 = A′B′, Y1 = A′B, Y2 = AB′, Y3 = AB.
Concept 1 of 4
Decoders (cont.)
An enable input switches the whole decoder on or off. Enable lets you build big decoders from small ones: a 3-to-8 decoder is two 2-to-4 decoders, with the third input bit driving the enables. Since a decoder makes every minterm, any function is an OR of its output lines. A full adder needs one 3-to-8 decoder and two OR gates. Decoders also drive memory address selection and displays.
OR-ing minterms isn’t always the cheapest option. If a function F has k minterms and k is more than half of 2n, its complement F′ has only 2n − k minterms — fewer decoder lines to combine. Since F = (F′)′, a single NOR gate fed by F′’s minterm lines produces F directly, which is cheaper than an OR gate with more inputs.
F = NOR(those Di lines) — cheaper than OR(F’s own k minterms) when k > 2n/2
Concept 1 of 4
Decoders (cont.)
2-to-4 decoder with enable
| E | A | B | Y0 | Y1 | Y2 | Y3 |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Interactive circuit
2-to-4 decoder
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Concept 2 of 4
Encoders
An encoder does the reverse: one active input becomes a binary code. A 4-to-2 encoder has A = D2 + D3 and B = D1 + D3. An octal-to-binary encoder has A2 = D4+D5+D6+D7, A1 = D2+D3+D6+D7, A0 = D1+D3+D5+D7.
A basic encoder assumes only one input is active. A priority encoder allows several and outputs the code of the highest-priority one, plus a valid flag V that says whether any input is active.
Concept 2 of 4
Encoders (cont.)
A basic encoder has a blind spot even when its one-active-input rule is obeyed: with no valid flag, “D0 is the only active input” and “no input is active” both produce the same code 00 — the circuit can’t tell them apart. It can also misbehave if the one-active-input rule is broken: if D3 and D6 were both 1 at once, a 4-to-2 encoder would output 11 (from A) and 1 (mis-OR’d elsewhere), and an octal encoder would output 111, which is neither 3 nor 6. A priority encoder’s V bit and priority logic resolve both problems at once.
4-to-2 encoder (one input active)
| D3 | D2 | D1 | D0 | A | B |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
4-input priority encoder
| D3 | D2 | D1 | D0 | A | B | V |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | X | X | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | X | 0 | 1 | 1 |
| 0 | 1 | X | X | 1 | 0 | 1 |
| 1 | X | X | X | 1 | 1 | 1 |
X means don’t care. The highest-priority active input wins.
Interactive circuit
4-to-2 priority encoder
D3 has the highest priority. A1 = D3+D2, A0 = D3+D2′D1, and V = D0+D1+D2+D3. Click the switches — try turning on more than one input and see which one wins.
Concept 3 of 4
Multiplexers
A multiplexer (MUX) is a data selector: 2n data inputs, n select lines and one output.
Concept 3 of 4
Multiplexers (cont.)
4-to-1: Y = S1′S0′I0 + S1′S0 I1 + S1 S0′ I2 + S1 S0 I3
A MUX can generate any function. Feed n−1 of the variables to the select lines and connect each data input to 0, 1, the last variable, or its complement.
Several 1-bit MUXes can share one set of select lines to switch a whole bus at once. A quadruple 2-to-1 MUX is four 2-to-1 MUXes with a common select S: S=0 makes every Yi = Ai, S=1 makes every Yi = Bi, so a single control line swaps an entire 4-bit bus A for a 4-bit bus B. A shared enable E overrides S and forces every Yi to 0 when the circuit is disabled.
Concept 3 of 4
Multiplexers (cont.)
2-to-1 multiplexer
| S | I0 | I1 | Y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |
4-to-1 multiplexer
| S1 | S0 | Y |
|---|---|---|
| 0 | 0 | I0 |
| 0 | 1 | I1 |
| 1 | 0 | I2 |
| 1 | 1 | I3 |
Quadruple 2-to-1 MUX (function table)
| E | S | Output Y |
|---|---|---|
| 1 | X | all 0’s |
| 0 | 0 | select A |
| 0 | 1 | select B |
Interactive circuit
2-to-1 multiplexer
Click the switches to change the inputs and watch the LEDs. Use “Show truth table” when it appears.
Concept 4 of 4
Demultiplexers
A demultiplexer (DEMUX) sends one input to one of 2n outputs chosen by the select lines. A decoder with an enable input works as a DEMUX: use the enable as the data input. A 1×8 DEMUX can be built from a 1×2 DEMUX in front of two 1×4 DEMUXes, with the top select bit choosing which 1×4 receives the data.
Concept 4 of 4
Demultiplexers (cont.)
Y3 = S1 S0 I Y2 = S1 S0′ I Y1 = S1′ S0 I Y0 = S1′ S0′ I
| Decoder | Encoder | MUX | DEMUX |
|---|---|---|---|
| Code → one line | One line → code | Many inputs → one output | One input → many outputs |
1×4 demultiplexer
| S1 | S0 | Y0 | Y1 | Y2 | Y3 |
|---|---|---|---|---|---|
| 0 | 0 | D | 0 | 0 | 0 |
| 0 | 1 | 0 | D | 0 | 0 |
| 1 | 0 | 0 | 0 | D | 0 |
| 1 | 1 | 0 | 0 | 0 | D |
Interactive
Demo: decoder, encoder, MUX and DEMUX
Worked example 1 of 4
Worked example 1
Show the solution
- AB = 00: F = 0 when C = 0 and 1 when C = 1, so I0 = C.
- AB = 01: F = 1 when C = 0 and 0 when C = 1, so I1 = C′.
- AB = 10: F = 0 for both, so I2 = 0.
- AB = 11: F = 1 for both, so I3 = 1.
Worked example 2 of 4
Worked example 2
Show the solution
- Connect B and C to both decoders’ inputs.
- Drive the enable of the first with A′ (outputs Y0–Y3) and of the second with A (outputs Y4–Y7).
Worked example 3 of 4
Worked example 3
Show the solution
- G has k = 7 minterms out of 2³ = 8, and 7 > 8/2, so building G directly means OR-ing 7 decoder output lines.
- G′ has 2³ − 7 = 1 minterm: only m7 (D7 = xyz) is missing from G.
- Since G = (G′)′ and G′ = D7, a single NOR of one line — which is just an inverter on D7 — gives G directly: G = D7′.
Worked example 4 of 4
Worked example 4
Show the solution
- Feed I into the 1-to-2 demux, selected by s2; its two outputs become the data inputs of the two 1-to-4 demuxes.
- Give both 1-to-4 demuxes the same select lines s1 and s0.
- When s2 = 0, only the lower 1-to-4 demux is fed I, and it routes I to one of Y0–Y3 based on s1 s0 (the upper one outputs all 0s).
- When s2 = 1, only the upper 1-to-4 demux is fed I, routing it to one of Y4–Y7 based on s1 s0.
Practice
Practice (1 of 2)
Try each one on paper first, then check your answer.
Show the answer
Show the answer
Show the answer
Practice
Practice (2 of 2)
Try each one on paper first, then check your answer.
Show the answer
Show the answer
Build a 2-to-4 decoder and a 4-to-1 multiplexer, then run the Truth table tester on them.
Gate ForgeA free circuit simulator — place and wire gates, generate truth tables and timing diagrams, and work through 90+ guided problems.Check yourself
Quiz
Summary
Summary
- A decoder makes all minterms of its inputs.
- An encoder is the reverse. Priority encoders resolve multiple active inputs.
- A MUX is a data selector. 2-to-1: Y = S′I0 + S·I1.
- Any function fits a MUX with data inputs from {0, 1, X, X′}.
- A decoder with enable is a DEMUX.