Skip to content
Tactiverge

School/△ Builder/Week 16

Multiplexers and decoders: choosing and pointing

A robot has eight sensors but only one analog-to-digital converter. How does it read them all through one input?

About 30 min · 3 goals · Checked by automated tests

1.Why should I care?

Multiplexers and decoders are the traffic police of a computer: they choose which data goes where. Every processor uses them to pick registers, select memory and route results.

  • ◇ Describe a multiplexer as a logic-controlled selector and write Y = ¬S·A + S·B.
  • ◇ Describe a decoder as turning a binary number into one active output line.
  • ◇ Relate the number of select lines to the number of inputs or outputs (2ⁿ).

2.Discover

Open the '2:1 multiplexer' challenge in the logic lab. Build Y = ¬S·A + S·B from AND, OR and NOT gates. Test all eight rows: confirm that S = 0 passes A through and S = 1 passes B, whatever the other input does.

Explorer 05 — Digital logic

Build answers out of ones and zeros

Every digital chip is built from a handful of simple gates. Flip the inputs to watch signals travel through a circuit, then wire your own gates to meet a target truth table.

ONE GATE · 1 GATE DEEP0A0BAND= 0G10Y
  • 1 (high)
  • 0 (low)
  • Unknown
  • Inverting output
Mode
Starting circuit

A single two-input gate. Change its type and watch the truth table change.

Inputs

Gates (1 of 8)

  1. G1 = 0

Add a gate

Outputs

Gates
1
Depth
1
Longest chain of gates a signal passes through
Rows
4
2^2 input combinations
Check
—
Truth table
Set inputsABY
000
010
100
111

State

Inputs A = 0, B = 0. Outputs Y = 0.

Inputs A = 0, B = 0. Outputs Y = 0.

How to read this

Signals flow left to right. Circles on the left are the inputs, boxes are gates and squares on the right are outputs. A thick bright wire carries a 1, a thin grey wire carries a 0, and each gate shows the value it outputs. A small circle on a gate's output means it inverts (NOT, NAND, NOR, XNOR).

The truth table lists every possible input combination and what the circuit outputs for each, so it describes the circuit completely. Two circuits with the same truth table are equivalent, however differently they are built. That is why NAND alone can make any other gate. Choose a row to set the inputs to it.

Assumptions & limitations
  • Ideal logic: every wire is exactly 0 or 1. Real gates use voltage ranges (for example near 0 V and near 3.3 V or 5 V) and an input between them is undefined.
  • Gates switch instantly here. Real gates take nanoseconds each, so a deeper circuit is slower, and outputs can glitch briefly while signals race through different paths.
  • Only combinational circuits are allowed: no output may feed back into its own input. Feedback is how memory (latches and flip-flops) works, but it needs timing this model does not simulate, so loops are reported as an error.
  • Gates here have one input (NOT) or two inputs. Real chips also have three- and four-input gates, and limits on how many inputs one output can drive (fan-out).
  • Gate counts are a simple measure of size; real designs also weigh speed, power and the number of transistors per gate.
Can't use the interactive? Read a description instead

In the logic lab's 2:1 multiplexer challenge, the circuit Y = NOT S AND A, OR S AND B is checked on all eight rows of S, A and B. When S is 0 the output always equals A; when S is 1 it always equals B.

3.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

In a 2:1 multiplexer Y = ¬S·A + S·B, what does S = 0 do?

Practice 2

How many select lines does a multiplexer need to choose one of 16 inputs?

lines

4.Predict

A multiplexer chooses one of several inputs using binary select lines. How many inputs can 3 select lines choose between?

Guess first. Being wrong here is how the surprise works.

5.Understand

Multiplexer: a selector

A 2:1 multiplexer has data inputs A and B and a select input S. If S = 0 the output copies A; if S = 1 it copies B: Y = ¬S·A + S·B. A 4:1 mux uses two select bits; an 8:1 mux uses three.

Decoder: a pointer

A decoder takes an n-bit number and switches on exactly one of 2ⁿ outputs. A 2-to-4 decoder with inputs A1 A0 has outputs D0 = ¬A1·¬A0, D1 = ¬A1·A0, D2 = A1·¬A0, D3 = A1·A0. Give it 10 and only D2 lights.

Where machines use them

A microcontroller uses a mux to connect one of its many analog pins to its single converter. Memory uses decoders to switch on one row out of thousands. A processor uses muxes to choose which register feeds the adder.

Explain it another way

A multiplexer is a railway junction: the select lever decides which track reaches the station. A decoder is a lift panel lighting exactly one floor number.

Worked example 1

A 2:1 mux has A = 0, B = 1, S = 1. What is Y?

Y = ¬S·A + S·B = 0·0 + 1·1 = 1: S = 1 selects B.

Common mix-ups

  • A multiplexer mixes its inputs together.
    ✓ It passes exactly one input through, chosen by the select lines.

6.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 3

How many outputs does a 3-to-8 decoder switch between, and how many are active at once? Give the number of outputs.

outputs

Practice 4 · a fresh version every time

With A = 1, B = 0 and C = 0, what is Y = (C ⊕ B) ⊕ A? Answer 0 or 1.

Practice 5

A 2-to-4 decoder receives A1 A0 = 10. Which output is active?

7.Apply it

A robot has four distance sensors and one converter. Draw the 4:1 multiplexer, label the select lines, and write the sequence of select values its program should cycle through to read every sensor once.

8.Reflect

Concepts: Logic gates and Boolean algebra · Inside a microcontroller