Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 10 of 9361. Foundations of Digital Logic and Computer ArchitectureFree lesson

Decoders and Encoders for Data Routing

You will build decoder and encoder circuits to manage data path routing and address space selection within computer architecture systems.

In this lesson, you will learn how decoders and encoders act as the "traffic controllers" of a computer, routing data to the correct destinations and simplifying complex signals.

The Decoder: Selecting the Destination

Think of a decoder as a "one-to-many" switch. It takes an nn-bit binary input (the address) and activates exactly one of its 2n2^n output lines. In computer architecture, we use these to select specific hardware components.

For example, a 2-to-4 decoder translates a binary address into a signal for one of four memory banks. If you input 01, the decoder activates the second output line (Y1), telling the processor, "Send the data here!"

Input (A1, A0) | Outputs (Y3, Y2, Y1, Y0)
------------------------------------------
     00        |     0    0    0    1
     01        |     0    0    1    0
     10        |     0    1    0    0
     11        |     1    0    0    0

The Encoder: Compressing the Signal

An encoder performs the inverse operation: it is a "many-to-one" logic circuit. It takes 2n2^n input lines and produces an nn-bit binary code corresponding to whichever input line is currently active.

Encoders are essential for interrupt handling in embedded systems. If multiple peripheral devices (like a keyboard, a mouse, and a sensor) are vying for the CPU’s attention, an encoder identifies which device triggered the request by converting the active line into a binary address that the CPU can process.

Why They Matter for Data Routing

In an embedded system, you rarely connect every component to the processor’s data bus simultaneously. If you did, signals would crash into each other! Instead, we use decoders to "enable" only the specific memory block or I/O device we want to talk to at a given millisecond. Meanwhile, encoders help the CPU consolidate status signals from many devices into a single, manageable binary ID. Together, they ensure that data flows to the right place without causing electrical contention or logic conflicts.

Key Takeaway: Decoders translate binary addresses into component-specific activation signals, while encoders consolidate multiple inputs into a single binary address, together forming the backbone of digital data routing.