01
Decoder
An n-to-2ⁿ decoder maps a binary code to one-hot output. For 2-to-4: Q0=I̅1I̅0, Q1=I̅1I0, Q2=I1I̅0, Q3=I1I0.
Build it yourself: 2-to-4 decoder · 1-to-2 decoder
02
Encoder
An encoder maps one-hot input to binary code. A basic encoder assumes one active input; a priority encoder chooses a winner if several are active.
Build it yourself: 4-to-2 encoder
03
Multiplexer
A MUX selects one data input. For 2-to-1: Q=S̅I0+SI1. In an ALU a MUX selects an operation result; in a datapath it selects a data source.
Build it yourself: 2-to-1 multiplexer · 4-to-1 multiplexer
04
Demultiplexer
A DEMUX routes one data input to a selected output. It resembles a decoder but has a separate data input that enables the selected line.
Build it yourself: 1-to-2 demultiplexer · 1-to-4 demultiplexer
05
How to distinguish circuits
Many-to-one is a MUX; one-to-many is a DEMUX; binary-to-one-hot is a decoder; one-hot-to-binary is an encoder. Count data and select lines before inspecting gates.
06
Practical uses
A decoder selects a memory word/device, an encoder compresses requests, a MUX builds datapaths and selects ALU output, and a DEMUX distributes a stream across channels.
SELF-CHECK
Check your understanding
2-to-4 input 10?
Q3Q2Q1Q0=0100.
Many-to-one?
Multiplexer.
One-hot-to-code?
Encoder.
Decoder vs DEMUX?
A DEMUX has a data input.