Module 1: Foundations of Digital Logic · 1.5 Combinational Logic Building Blocks

Decoders and Demultiplexers

In the previous article, we examined multiplexers that select one signal from multiple data inputs. This article examines the complementary operations performed by binary decoders and demultiplexers. Every memory access in a microprocessor requires address decoding logic to select a target memory bank or peripheral register. Instruction decoders translate operation codes into control signals for arithmetic units. Decoders and demultiplexers provide essential routing and selection functions in digital systems.

Definition of Binary Decoders

A binary decoder converts an $n$-bit coded binary input into a maximum of $2^n$ unique output lines. Under normal operation, exactly one output line is active for each input combination. All other output lines remain inactive. Output $Y_i$ asserts active when the numerical value of the binary input pattern equals $i$.

The 2-to-4 Binary Decoder

A 2-to-4 decoder accepts two input bits ($A_1, A_0$) and produces four output lines ($Y_0, Y_1, Y_2, Y_3$). Each output represents one fundamental minterm of the inputs:

$$Y_0 = \overline{A_1},\overline{A_0} = m_0$$

$$Y_1 = \overline{A_1}A_0 = m_1$$

$$Y_2 = A_1\overline{A_0} = m_2$$

$$Y_3 = A_1A_0 = m_3$$

Table 1 lists the functional truth table:

$A_1$ $A_0$ $Y_3$ $Y_2$ $Y_1$ $Y_0$
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0

Figure 1 shows the internal gate-level schematic. The circuit uses two inverters and four 2-input AND gates.

2-to-4 decoder
Figure 1: Gate-level schematic of a 2-to-4 decoder

Because each output represents an individual minterm, a decoder functions as a hardware minterm generator.

Enable Input Control

Commercial decoders include an enable input line ($EN$). When $EN = 0$, all outputs are disabled and driven to logic 0, regardless of the address inputs. When $EN = 1$, the decoder operates normally (Table 2):

$EN$ $A_1$ $A_0$ $Y_3$ $Y_2$ $Y_1$ $Y_0$
0 X X 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0

Each output equation incorporates the enable signal:

$$Y_i = EN \cdot m_i$$

In physical memory devices, chip-select ($\overline{CS}$) or chip-enable ($\overline{CE}$) lines often use active-low logic. In an active-low decoder, NAND gates replace AND gates, and the selected output drops to logic 0.

Logic Function Generation Using Decoders

Because an $n$-to-$2^n$ decoder generates all $2^n$ minterms, you can implement any arbitrary Boolean function by combining selected decoder outputs with an OR gate.

For example, consider two functions implemented with a single 2-to-4 decoder and two OR gates:

$$f_1(A_1, A_0) = \sum m(0, 3) = Y_0 + Y_3$$

$$f_2(A_1, A_0) = \sum m(1, 2) = Y_1 + Y_2$$

This architecture forms the historical foundation of Read-Only Memories (ROMs). A ROM contains an address decoder coupled to a programmable OR diode or transistor matrix.

Cascading Decoders to Expand Address Space

You can connect smaller decoders in parallel to decode wider binary addresses. The enable pin controls which subordinate decoder activates.

To build a 3-to-8 decoder from two 2-to-4 decoders:

  1. Connect address bits $A_1$ and $A_0$ to both decoders in parallel.
  2. Connect address bit $A_2$ directly to the enable input of the upper decoder (outputs $Y_4 \dots Y_7$).
  3. Connect inverted address bit $\overline{A_2}$ to the enable input of the lower decoder (outputs $Y_0 \dots Y_3$).

Figure 2 illustrates the cascaded configuration:

3-to-8 from two 2-to-4
Figure 2: 3-to-8 decoder constructed from two 2-to-4 decoders

When $A_2 = 0$, only the lower decoder is enabled. When $A_2 = 1$, only the upper decoder is enabled. This modular hierarchy scales directly to 4-to-16 and 5-to-32 decoder networks.

The Demultiplexer (DEMUX)

A demultiplexer (DEMUX) receives a single input data line ($D$) and routes it to one of $2^n$ output lines. The output path is selected by $n$ binary select lines.

A binary decoder with an enable input functions identically to a demultiplexer. If we connect the input data line $D$ to the decoder enable pin ($EN$):

$$Y_i = D \cdot m_i(\text{select lines})$$

When $D = 1$, the selected output line asserts high. When $D = 0$, all output lines remain low. Therefore, the circuit routes input data $D$ to the selected output line.

Memory Address Decoding Architecture

Address decoding assigns physical memory chips to discrete ranges within a unified microprocessor memory space. Consider a 64 KB address space ($2^{16}$ bytes, address lines $A_{15} \dots A_0$) divided into four 16 KB regions (Table 3):

Memory Bank Address Range Binary Range ($A_{15} A_{14}$)
Chip 0 0x0000 to 0x3FFF 00
Chip 1 0x4000 to 0x7FFF 01
Chip 2 0x8000 to 0xBFFF 10
Chip 3 0xC000 to 0xFFFF 11

Address lines $A_{15}$ and $A_{14}$ connect to the input lines of a 2-to-4 decoder. The four decoder outputs connect to the chip-select pins of memory chips 0 through 3. The remaining 14 address lines ($A_{13} \dots A_0$) connect to all memory chips in parallel to address individual 16 KB byte locations. Figure 3 illustrates this memory decoding system.

Memory address decoding
Figure 3: Memory address decoding using upper address bits

Worked Example: 4-to-16 Decoder Expansion

Construct a 4-to-16 decoder using two 3-to-8 decoders with enable inputs ($EN$) and one inverter. The input address lines are $A_3, A_2, A_1, A_0$.

  • Connect the lower three address lines ($A_2, A_1, A_0$) to the inputs of both 3-to-8 decoders.
  • Connect $A_3$ directly to the enable input of the upper decoder.
  • Connect $\overline{A_3}$ through an inverter to the enable input of the lower decoder.

Table 4 lists selected input conditions and active outputs:

$A_3$ $A_2$ $A_1$ $A_0$ Active Decoder Active Output
0 0 0 0 Lower $Y_0$
0 1 1 0 Lower $Y_6$
1 0 0 1 Upper $Y_9$
1 1 1 1 Upper $Y_{15}$

The circuit decodes all sixteen combinations using two standard decoder units and one inverter.

Practice Exercises

Problem 1: Using a single 2-to-4 decoder and two OR gates, implement an XOR function ($f_1 = A \oplus B$) and an XNOR function ($f_2 = A \odot B$) simultaneously.

View Solution

The 2-to-4 decoder inputs are $A$ and $B$.

  • The XOR function equals 1 for minterms $m_1$ and $m_2$: $f_1 = Y_1 + Y_2$.
  • The XNOR function equals 1 for minterms $m_0$ and $m_3$: $f_2 = Y_0 + Y_3$.

Connect decoder outputs $Y_1$ and $Y_2$ to the first OR gate. Connect decoder outputs $Y_0$ and $Y_3$ to the second OR gate.

Problem 2: A 32 KB microprocessor memory space is partitioned into eight 4 KB blocks. Determine the total number of address bits, the number of block-selection bits, and the required decoder configuration.

View Solution
  • Total address space: $32\text{ KB} = 32{,}768\text{ bytes} = 2^{15}\text{ bytes}$. The system requires 15 address lines ($A_{14} \dots A_0$).
  • Block size: $4\text{ KB} = 4{,}096\text{ bytes} = 2^{12}\text{ bytes}$. Each block requires 12 internal address lines ($A_{11} \dots A_0$).
  • Block selection: $15 - 12 = 3$ bits ($A_{14}, A_{13}, A_{12}$).
  • The system requires one 3-to-8 decoder to generate eight chip-select signals.

Problem 3: A multiplexer transmits serial data across a single physical wire. A demultiplexer receives the data. A synchronized binary counter drives the select lines of both units. Describe the operational principle of this system.

View Solution

The multiplexer sequentially samples $N$ parallel input channels and transmits each bit onto the serial channel. The demultiplexer distributes each bit in the same sequence to its corresponding output line. This communication architecture implements Time-Division Multiplexing (TDM), allowing multiple independent data streams to share a single physical communication channel.

In the next article, we examine encoders and priority encoders that convert active status lines into compact binary codes.

← Multiplexers Encoders and Priority Encoders →