Menu Close

How a Multiplexer Works: How Digital Circuits Choose Between Inputs

Posted in Digital Logic

How does a CPU choose which value to send into a calculation? How can a digital circuit select one source of data from several available sources?

How does a multiplexer work, and how does your CPU choose which data to use?

One of the fundamental building blocks behind these decisions is the multiplexer, usually shortened to MUX.

A multiplexer is a circuit that selects one of several data inputs and makes the selected value available at its output. Separate inputs called select signals determine which data input is selected.

Its basic job is simple:

Several possible inputs. One selected output.

In this tutorial, we will build that idea step by step, from a basic two-input multiplexer to the larger selections that happen inside a processor.

1. Digital Circuits Work with Binary Values

Digital logic describes how circuits operate on discrete values, usually represented as zero and one. These values allow hardware to represent information and carry out decisions.

A bit, short for binary digit, is a single value that can be either zero or one. Binary is a number system that uses only these two digits.

Inside an electronic circuit, zero and one are represented by different voltage ranges. A voltage is an electrical potential difference; digital hardware interprets specified ranges as valid logic values.

A signal is a physical quantity that carries information. In the circuits discussed here, a signal’s voltage represents a binary value.

An input brings a signal into a circuit. An output carries the result from that circuit.

A multiplexer receives several data signals, but only the selected input determines its output value.

2. The Simplest Multiplexer: Two Inputs, One Output

A 2-to-1 multiplexer has two data inputs and one data output. It also has one select input that chooses between the two data inputs.

Let us call the data inputs D0 and D1, the select input S, and the output Y.

The letters are simply labels. D0 means “data input zero,” and D1 means “data input one.”

The selection rule is:

Select input S Output Y
0 Value of D0
1 Value of D1

When S is zero, Y follows D0. When S is one, Y follows D1.

Think of a railway junction with two incoming tracks and one outgoing track. The position of the switch determines which incoming track connects to the outgoing route.

A multiplexer performs an electronic version of that selection. It does not need a moving mechanical switch.

3. The Select Signal Chooses the Source, Not the Value

The distinction between data and selection is essential.

A data signal carries the information we want to use. A control signal determines what a circuit does with that information.

The select input of a multiplexer is a control signal.

Suppose D0 is one and D1 is zero.

When S is zero, the multiplexer selects D0, so Y becomes one. When S is one, it selects D1, so Y becomes zero.

Notice that setting S to one does not mean “make the output one.” It means “select input D1.”

If D1 contains zero, the output will be zero.

Likewise, if both data inputs contain one, the output will be one regardless of which input is selected.

The select signal identifies the source. The selected source supplies the value.

4. A Multiplexer Selects Data; It Does Not Store It

A multiplexer is an example of a combinational circuit. This is a circuit whose output is determined by its current inputs, after the circuit has had time to respond.

A basic multiplexer does not remember a previously selected value.

If S remains zero and D0 changes, Y follows that change. Meanwhile, changes to the unselected input D1 do not affect the output in the ideal logical model.

A storage element is a circuit designed to retain a value. A multiplexer needs a separate storage element if the selected value must be saved for later.

A basic multiplexer also does not need a clock signal to perform its selection. A clock signal is a repeating timing signal used to coordinate updates in many digital systems.

Registers connected to a multiplexer may use a clock, but the multiplexer itself responds to changes in its data and select inputs.

5. Building a Multiplexer from Logic Gates

A logic gate is a small circuit that performs a basic operation on binary inputs.

We can describe a 2-to-1 multiplexer using three types of gates: NOT, AND, and OR.

A NOT gate, also called an inverter, reverses a binary value. An input of zero produces one, and an input of one produces zero.

An AND gate produces one only when all its inputs are one. If any input is zero, its output is zero.

An OR gate produces one when at least one input is one. It produces zero only when all its inputs are zero.

To build our multiplexer, we use a NOT gate to create the opposite of S.

One AND gate combines D0 with NOT S. A second AND gate combines D1 with S.

An OR gate then combines the outputs of those two AND gates.

This arrangement allows the selected data value to reach Y while forcing the unselected branch to zero.

It is one way to implement the multiplexer’s function. Actual chips can use other circuit arrangements to achieve the same selection behavior.

6. Understanding the Logic Expression

A Boolean expression describes an operation on values that can be zero or one. It is named after Boolean algebra, a mathematical system used to reason about logic.

For our 2-to-1 multiplexer, the expression is:

Y = (D0 AND NOT S) OR (D1 AND S)

The parentheses group the operations.

Let us examine both possible values of S.

When S is zero, NOT S becomes one.

The first branch becomes D0 AND one, which equals D0. The second branch becomes D1 AND zero, which equals zero.

The final OR operation therefore produces D0.

When S is one, NOT S becomes zero.

The first branch becomes D0 AND zero, which equals zero. The second branch becomes D1 AND one, which equals D1.

The final OR operation therefore produces D1.

The expression captures the entire selection rule: one branch passes its data value, while the other contributes zero.

7. Selecting Among Four Inputs

A 4-to-1 multiplexer selects one of four data inputs.

We will label those inputs D0, D1, D2, and D3.

One select bit cannot identify four different choices because it has only two possible values. We therefore need two select bits, which we will call S1 and S0.

Together, two bits provide four possible combinations:

Select bits S1 S0 Output Y
00 Value of D0
01 Value of D1
10 Value of D2
11 Value of D3

Here, S1 is the left-hand bit and S0 is the right-hand bit.

The general relationship is straightforward: n select bits can identify up to 2ⁿ inputs. The expression 2ⁿ means two multiplied by itself n times.

Three select bits provide eight combinations, so they can control an 8-to-1 multiplexer. Four select bits provide sixteen combinations, enough for a 16-to-1 multiplexer.

A circuit can also have a number of inputs that is not a power of two. In that case, some select combinations may be unused, and the design must define how to handle them.

8. Building a Larger Multiplexer from Smaller Ones

We can build a 4-to-1 multiplexer using three 2-to-1 multiplexers.

This creates a multiplexer tree: an arrangement in which smaller multiplexers feed later multiplexers to make a larger selection.

In the first stage, one multiplexer chooses between D0 and D1. Another chooses between D2 and D3.

Both first-stage multiplexers use S0 as their select signal.

In the second stage, a third multiplexer chooses between the two first-stage outputs. It uses S1 as its select signal.

Suppose S1 S0 is 10.

Because S0 is zero, the first stage selects D0 from the first pair and D2 from the second pair. Because S1 is one, the second stage selects the result from the second pair.

The final output is therefore D2.

A stage is one level of processing in a circuit. Building a selection across several stages makes larger multiplexers possible, but it also adds time for changes to travel through the circuit.

9. Selecting a Whole Group of Bits

So far, each data input has carried only one bit.

Processors usually need to select values containing many bits at once.

A bus is a group of signal lines used together to carry related information. In this example, an eight-bit data bus carries eight bits in parallel, meaning at the same time on separate lines.

The width of a bus is the number of bits it carries in parallel.

To choose between two eight-bit values, we can place eight one-bit 2-to-1 multiplexers side by side.

Each multiplexer selects one corresponding bit position. All eight multiplexers share the same select signal.

When S is zero, every output bit comes from the first input bus. When S is one, every output bit comes from the second input bus.

Together, they form an eight-bit-wide 2-to-1 multiplexer.

These numbers describe different properties. “2-to-1” tells us how many sources we can choose between; “eight-bit-wide” tells us how much data each source carries.

10. How a CPU Uses Multiplexers

A CPU, or central processing unit, is the processor that executes program instructions. An instruction is an encoded command telling the processor to perform an operation.

Inside a CPU, data often has several possible destinations or sources.

A register is a small, fast storage location inside a processor. Registers hold values that the processor is currently working with.

An ALU, or arithmetic logic unit, is a circuit that performs operations such as addition, subtraction, and bitwise logic. A bitwise operation applies a logical rule separately to corresponding bits.

Before the ALU can perform an operation, the CPU must supply its inputs. A value used by an operation is called an operand.

Consider two instructions: one adds two register values, while another adds a register value and a constant encoded in the instruction.

An immediate value is a constant included in the instruction itself.

A multiplexer can choose whether an ALU input comes from a register or from the prepared immediate value.

The CPU’s control logic generates signals that coordinate its internal operations. It sets the multiplexer’s select signal according to the instruction being executed.

Another multiplexer might choose which result is written into a register: an ALU result or data read from memory.

These selections form part of the CPU’s datapath, the collection of circuits and connections through which data moves and is processed.

Multiplexers let different instructions share computing hardware while supplying the appropriate data.

11. Real Multiplexers Take Time to Respond

The logical rules describe what the output should become. They do not mean that the output changes instantly.

Propagation delay is the time between an input change and the resulting output response.

If a selected data input changes, the output needs a short time to reflect the new value. Changing the select signal also takes time to affect the output.

If signals change close together, the output may briefly pass through an unintended value before settling. Such a short unwanted transition is called a glitch.

This matters when a multiplexer feeds a register.

The circuit must allow enough time for the selected value to become stable before the register captures it. Hardware designers account for the delays through multiplexers and other circuits when setting the system’s timing.

A deeper multiplexer tree generally introduces more stages of delay. The actual delay depends on the circuit implementation and its electrical loading.

The key lesson is that correct logical selection and correct timing are both necessary.

12. Multiplexer vs. Demultiplexer

A demultiplexer, often shortened to DEMUX, directs one data input toward one of several outputs. Select signals determine which output receives the input value.

A multiplexer chooses which source to read. A demultiplexer chooses which destination to drive.

For example, a 4-to-1 multiplexer selects one of four inputs for a single output. A 1-to-4 demultiplexer directs a single input to one selected output.

In a basic digital demultiplexer, the unselected outputs are held at zero.

The names sound similar because both circuits perform controlled routing, but the direction of selection is different.

13. Conclusion

A multiplexer answers a simple question: which input should supply the output right now?

Data inputs carry the candidate values. Select signals identify the input to use. The output follows that selected input after the circuit’s propagation delay.

A basic multiplexer does not store data or perform arithmetic. It selects the data that other circuits will use.

The same idea scales from choosing between two individual bits to selecting entire buses inside a processor.

Whenever a CPU chooses an ALU operand, selects a result to write into a register, or routes data through a shared path, multiplexers may be doing the selection.

Understanding the multiplexer reveals an essential part of how computers work: hardware must not only calculate and store values—it must also choose where those values come from.

Leave a Reply

Your email address will not be published. Required fields are marked *