Electrical Engineering › Section T · Combinational logic › Topic T.4

Multiplexers, demultiplexers, and parity

Digital systems constantly route data: many sources share one wire, one wire feeds many destinations, and every transfer risks a flipped bit. Multiplexers, demultiplexers and parity circuits handle all three.

The multiplexer: a digital selector switch

A multiplexer (mux), or data selector, connects one of several data inputs to a single output. Select inputs choose which: n select lines pick one of \(2^n\) data inputs. Picture a rotary switch whose position is set by a binary number instead of a knob. For a 4-input mux with data \(D_0\) to \(D_3\) and selects \(S_1S_0\), each data input is ANDed with the select code that chooses it:

\begin{aligned} Y = {} & D_0\overline{S_1}\,\overline{S_0} + D_1\overline{S_1}S_0 \\ & + D_2S_1\overline{S_0} + D_3S_1S_0 \end{aligned}

With \(S_1S_0 = 10\), only the third term can be 1, so Y follows \(D_2\).

Multiplexer chips and expansion

Two common parts are the 74HC153, which holds two 4-input multiplexers sharing one pair of select lines, and the 74HC151, an 8-input multiplexer with three select lines, an active-LOW enable and both true and complemented outputs. While disabled, the 74HC151 holds its true output LOW whatever the data. Enables make expansion easy. To build a 16-input selector from two 8-input chips, send the three low select bits to both, and use the fourth select bit to enable one chip when it is 0 and the other when it is 1; an OR gate then combines their outputs.

The multiplexer as a function generator

A mux can produce any logic function without designing gates. Put the function's variables on the select lines, and tie each data input to 0 or 1 to match that row of the truth table. An 8-input mux therefore implements any function of three variables. A neater trick halves the size: put all but one variable on the selects, and feed each data input with 0, 1, the last variable or its complement. A 4-input mux can then make any 3-variable function, and an 8-input mux any 4-variable function. The design is read straight from the truth table, and changing the function means changing only the data connections.

Worked example: a vote circuit from a 4-input mux

Make the majority function of A, B and C, which is 1 when at least two inputs are 1, with a 4-input mux. 1. Put A on \(S_1\) and B on \(S_0\). 2. For \(AB = 00\), the output is 1 only if two inputs are 1, impossible with one left, so \(D_0 = 0\). 3. For \(AB = 01\), the output is 1 only if C is 1, so \(D_1 = C\). 4. For \(AB = 10\), likewise \(D_2 = C\). 5. For \(AB = 11\), the output is 1 whatever C is, so \(D_3 = 1\). 6. Check all eight rows: they match \(AB + BC + AC\), with no gates beyond the mux.

Demultiplexers

A demultiplexer (demux) does the reverse: one data input is routed to whichever of \(2^n\) outputs the select code names, and the other outputs stay inactive. It needs no new chip. A decoder with an enable input already works as a demux: apply the select code to the decoder inputs and the data to the enable. The chosen output then follows the data and the rest stay at their inactive level. A 4-line-to-16-line decoder such as the 74HC154 serves as a 1-line-to-16-line demux this way. A mux and demux with matching select codes let several signals take turns on one line, the idea behind time-division multiplexing in "Transmission modes, modulation, and multiplexing".

Parity

Parity, met in "Hexadecimal, octal, BCD, and error codes", adds one bit to a group so that the total number of 1s is even (even parity) or odd (odd parity). The circuit for it is a chain or tree of XOR gates, because XOR is 1 exactly when an odd number of its inputs are 1. XOR all the data bits and the result is the even-parity bit; invert it for odd parity. A tree is faster than a chain: 8 bits need 7 XOR gates either way, but a tree has only 3 gate delays instead of 7. The 74HC280 is a 9-bit parity generator and checker with "sum even" and "sum odd" outputs.

Worked example: generating and checking parity

Seven data bits 1011011 are sent with even parity. 1. Count the 1s: there are 5. 2. Five is odd, so the even-parity bit is 1, making six 1s in the 8-bit word 1011011 1. 3. The receiver XORs all eight bits; a result of 0 means the count is even and no error is detected. 4. Suppose noise flips one bit, giving 1001011 1. Now there are five 1s, the XOR gives 1 and the error is flagged. 5. Suppose two bits flip, giving 1001111 1. There are six 1s again, the XOR gives 0 and the error goes unnoticed. Parity detects any odd number of bit errors but no even number, and it never says which bit is wrong.

Glitches and strobing

A decoder can briefly select the wrong output. When its inputs change from 01 to 10, both bits are meant to change at once, but one always arrives a few nanoseconds first. If the high bit changes first the inputs pass through 11; if the low bit does, they pass through 00. Either way a third output pulses for a moment: a glitch. If that output clocks a register or triggers a load, the error is real. The cure is strobing: hold the decoder disabled while its inputs change, and enable it only after they have settled. A strobe pulse timed to the middle of each input interval does exactly that.

Common mistakes to avoid

First, mixing up mux and demux: a mux has many inputs and one output; a demux has one input and many outputs. Second, counting data inputs as \(2n\) instead of \(2^n\): 3 select lines choose among 8 inputs, not 6. Third, forgetting the enable: a disabled mux ignores its data. Fourth, believing parity corrects errors, or catches every error; it only detects an odd number of flipped bits. Fifth, blaming a faulty chip for decoder glitches that come from unequal input delays; strobing, not replacement, is the fix.

Key takeaways

A multiplexer uses n select lines to pass one of \(2^n\) data inputs to its output. Enables let multiplexers expand, and a mux can generate any function: an 8-input mux makes any 3-variable function directly, or any 4-variable function using a variable on the data inputs. A demultiplexer routes one input to one of \(2^n\) outputs, and an enabled decoder does this job. XOR gates generate and check parity, which detects any odd number of bit errors. Decoder glitches from unequal input delays are removed by strobing.

Flashcards

Flashcard

Multiplexer

Selects one of 2ⁿ data inputs for one output

Also called a data selector.

Test your understanding

Question 1 of 5

How many select lines does a multiplexer with 16 data inputs need?

Question 2 of 5

A 4-input mux has A on S₁ and B on S₀, with D₀ = 0, D₁ = C, D₂ = C and D₃ = 1. What is the output when A = 1, B = 0 and C = 1?

Question 3 of 5

Seven data bits 1100101 are sent with odd parity. What is the parity bit?

Question 4 of 5

A word is received with two bits flipped by noise. What does an even-parity checker report?

Question 5 of 5

A decoder output briefly pulses when its inputs change from 01 to 10. What is the standard cure?

← Previous topicNext topic →