目录 ← 首页
CS61C

Data Multiplexors

Learning Outcomes

  • Draw an n-bit wide, k-to-1 mux circuit.
  • Explain how the mux uses its control signal to select its output from a set of data inputs.

Last time we saw how to represent and design combinational logic blocks. In this section we will study a few special logic blocks; data multiplexors, a adder/subtractor circuit, and an arithmetic/logic unit.

The Mux

A data multiplexor, commonly called a mux or a selector, is a circuit that selects its output value from a set of input values. Below are two mux circuits.

:::::{grid} 2

1-bit 2-to-1 multiplexer symbol with data inputs a and b, select input s, and output y.

A 1-bit wide, 2-to-1 MUX.

n-bit 2-to-1 multiplexer symbol with n-bit inputs A and B, 1-bit select s, and n-bit output Y.

An n-bit wide, 2-to-1 MUX.

Both of these muxes have two data inputs and one output. Additionally, each mux has a special control signal labeled s, for select. The s signal is also input, but it is used to control which of the two input values is directed to the output.

#fig-mux-2 shows a 1-bit wide, 2-to-1 mux circuit:

  • 2-to-1 because it takes two data inputs a and b and outputs one of them.
  • It is 1-bit wide because all data signals (a and b) are 1-bit in width.
  • Notice, however, that the s signal is a single bit wide. This is because it must choose between the 2 inputs.

#fig-mux-n shows an n-bit wide, 2-to-1 mux circuit:

  • 2-to-1 because it takes two data inputs A and B and outputs one of them.
  • It is 1-bit wide because all data signals (A and B) are 1-bit in width.
  • The s signal is still a single bit wide because it must choose between the 2 inputs.

The function of, say, the 1-bit wide 2-to-1 mux can be described with two rules:

y={awhen s=0bwhen s=1\texttt{y} = \begin{cases} \texttt{a} & \text{when } \texttt{s} = 0 \\ \texttt{b} & \text{when } \texttt{s} = 1 \\ \end{cases}

To remind us of which value of s corresponds to which input, within the mux symbol we commonly label each input with its corresponding s value.

Muxes find common use within the design of microprocessors, e.g., those that implement RISC-V.

MUX: Implementation

In most applications, you will have access to a mux; you will not need to build your own from scratch. Nevertheless, it is good to remember that like all combinational logic blocks, the function of muxes can be described using a truth table and thereby implemented as a logic gate circuit.

1-bit wide, 2-to-1 MUX

How do we implement the mux in #fig-mux-2, discussed above?

This circuit can be expressed in Boolean algebra:

y=sa+sby = \overline{s} a + s b

Expand the dropdown items below to show the gate circuit and derive the above expression.

1-bit wide 4-to-1 mux

Often times we find the need to extend the number of data inputs of a multiplexor. For instance consider a 4-to-1 multiplexor in #fig-mux-4-bits:

1-bit 4-to-1 mux symbol with inputs a through d, select bits s1 s0, and 1-bit output e.

A 1-bit wide 4-to-1 MUX.

#fig-mux-4-block shows how this larger mux can be formed by wiring together smaller MUXes.

4-to-1 mux built from three 2-to-1 muxes. Initially, two 2-to-1 muxes are selected with select bit s0, and the outputs feed the third 2-to-1 mux that uses select bit s1 to get the final resulting output e.

4-to-1 multiplexor (MUX) circuit diagram.

This circuit design leverages the hierarchical nature of multiplexing. The first layer of muxes uses the s0s_0 input to narrow the four inputs down to two, then the second layer uses s1s_1 to choose the final output.