CHAPTER 046 SECTIONS · 4 CHECKS

Hardware building blocks

Decoders, encoders, MUXes, DEMUXes, their equations, and common uses.

Contents
  1. 1. Decoder
  2. 2. Encoder
  3. 3. Multiplexer
  4. 4. Demultiplexer
  5. 5. How to distinguish circuits
  6. 6. Practical uses

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.

I1I0Q0Q1Q2Q3
A 2-to-4 decoder from AND and NOT (Midterm 2023).

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.

i0i1i2i3q0q1
A 4-to-2 encoder: q0 = i1+i3, q1 = i2+i3.

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.

I0I1SQ
A 2-to-1 MUX.
S1S0I0I1I2I3Q
A 4-to-1 MUX (Lab 5).

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.

ISq0q1
A 1-to-2 DEMUX (Midterm 2025).
IS1S0q0q1q2q3
A 1-to-4 DEMUX (Pre-Final 2022).

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.

ISq0q1aDEMUX 1→2I1I0Q0Q1Q2Q3bDecoder 2→4i0i1i2i3q0q1cEncoder 4→2S1S0I0I1I2I3QdMUX 4→1
The four blocks from Midterm 2024 and the demo paper.

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.