Combinational Blocks
Three classic MSI building blocks side-by-side: a 4-to-1 multiplexer, a 2-to-4 decoder, and a 4-bit magnitude comparator. Toggle inputs and watch the schematic, truth table, and output flags update live.
| S1 | S0 | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Combinational building blocks
Combinational blocks are standard circuits whose output depends only on current inputs — no memory, no feedback. They are the building blocks of data paths, address decoders, bus arbiters, and ALUs.
Multiplexer (MUX)
A 2ⁿ-to-1 MUX selects one of 2ⁿ data inputs using n select lines. Application: any combinational Boolean function can be implemented with a single MUX by connecting the truth-table output values to the data inputs.
Demultiplexer (DEMUX) and Decoder
A DEMUX routes one input to one of 2ⁿ outputs selected by n control lines — the reverse of a MUX. A binary decoder asserts exactly one of its 2ⁿ outputs for each input combination; used in memory address decoding and chip-select generation.
Encoder and priority encoder
An encoder converts 2ⁿ one-hot inputs to an n-bit binary code. A priority encoder resolves multiple simultaneous active inputs by asserting the code for the highest-priority (usually highest-numbered) active input — essential in interrupt controllers.
Worked example — a 4-to-1 MUX from logic
A 4-to-1 multiplexer routes one of four data inputs (D0–D3) to the output Y using two select lines (S1, S0). Its Boolean form is Y = S1′·S0′·D0 + S1′·S0·D1 + S1·S0′·D2 + S1·S0·D3 — one AND term per input, each enabled by a unique select combination, all OR-ed together. With S1S0 = 10, only the third term is active, so Y = D2. This is why a MUX is often called a "data selector," and why any n-variable truth table can be implemented directly with a 2ⁿ-to-1 MUX.
Common questions
- What's the difference between a decoder and a demux?
- They share the same circuit. A decoder treats its inputs as an address and asserts one of its outputs; a demultiplexer adds a data line and routes it to the selected output. A decoder is just a demux with its data input tied to logic 1 (or the enable).
- Why use a priority encoder instead of a plain encoder?
- A plain encoder produces a wrong code if two inputs are active at once. A priority encoder resolves the conflict by outputting the code of the highest-priority active input and adds a "valid" flag — essential for interrupt controllers.
Keep learning
- Combinational Blocks — Learn — how each block is built from gates, and why the select lines are decoded
- Worked example — a MUX and a decoder solved step by step
- Logic Gates — Learn — the AND/OR/NOT layer underneath all three
- Logic Circuit Lab — build one of these blocks yourself from gates and check its truth table
- SOP / POS & K-map — minimise the logic a decoder output needs
Quick experiments
- Count the select lines. An 8-to-1 mux needs 3 select lines, because 2³ = 8. Drop to 4 inputs and 2 selects suffice. Every doubling of inputs costs exactly one more select line.
- Use a mux as a logic generator. Feed A and B into the select lines of a 4-to-1 mux and hard-wire the data inputs to a truth table's outputs. The mux now implements that function with no gates at all.
- See the decoder as the mux in reverse. A 3-to-8 decoder takes a 3-bit code and raises exactly one of 8 outputs. A mux funnels many inputs to one output; a decoder fans one code out to many lines.
- Break a plain encoder. Raise two inputs of a simple encoder at once. The output is the OR of both codes — a value that matches neither input. A priority encoder resolves this by reporting the highest active line.
- Watch the enable line gate everything. Drop the enable on a decoder and every output goes inactive regardless of the input code. This is how one address bus selects between several chips without contention.
Formula reference
- Select lines for a multiplexer
8 inputs need 3 selects; 16 need 4.
- Decoder outputs
A 3-to-8 decoder has 3 inputs and 8 outputs, one active at a time.
- 2-to-1 multiplexer
S picks which data input reaches the output.
- Decoder output line
Exactly one output is active for each input code.
| Symbol | Meaning | Unit |
|---|---|---|
| Number of data inputs or code bits | — | |
| Number of select lines | — | |
| Data input i | — |
Common mistakes
Confusing which way a mux and a decoder point.
A multiplexer has many data inputs and one output; a decoder has few inputs and many outputs. Swapping them in a design leaves signals with nowhere to go.
Giving a multiplexer too few select lines.
n inputs need log2(n) selects. Wiring an 8-to-1 mux with only 2 select lines leaves half the inputs unreachable.
Using a plain encoder where inputs can overlap.
A simple encoder assumes exactly one active input and produces a meaningless OR of codes otherwise. Use a priority encoder whenever two inputs might assert together.
Ignoring the enable input.
Enable is what allows several decoders to share a bus. Tying it permanently active means every decoder drives at once, which is bus contention, not selection.
Expecting a demultiplexer to hold its outputs.
These blocks are combinational — outputs follow inputs and are not stored. If a routed value must persist after the select changes, it needs a latch or register.
Frequently asked questions
What is the difference between a multiplexer and a decoder?
A multiplexer selects one of several inputs and routes it to a single output. A decoder takes an input code and activates exactly one of many outputs. A mux funnels many to one; a decoder fans one to many.
How many select lines does a multiplexer need?
A multiplexer with n data inputs needs log2(n) select lines. Four inputs need 2 selects, eight need 3, and sixteen need 4.
Can a multiplexer implement any logic function?
Yes. Wire the input variables to the select lines and hard-wire each data input to the truth table's output for that combination. A 2-to-1 mux with the right connections can realise any two-variable function.
What does an encoder do that a priority encoder does not?
A plain encoder assumes exactly one input is active and produces undefined output otherwise. A priority encoder resolves the ambiguity by outputting the code for the highest-priority active input, and usually flags whether any input was active.
What is a demultiplexer used for?
A demultiplexer routes one input to one of many outputs, chosen by the select lines. It is the reverse of a multiplexer and is used to distribute a shared signal to one destination, such as selecting which display digit to drive.
Related tools
Static Hazard Analyzer
Watch a static-1 glitch on F = AB + A'C — add the consensus cover to kill it.
Open →Flip-Flop Simulator
D, JK, T, SR, SR active-low — toggle inputs, watch waveforms, see excitation tables.
Open →Timing Analyzer
Adjust setup / hold / propagation delay — watch violations and max-frequency update live.
Open →Register & Shift Register
SISO, SIPO, PISO, PIPO shift modes — clock data through and watch each stage.
Open →Ripple Counter Explorer
MOD-2 to MOD-16 — watch the domino ripple, timing waveforms, and frequency division.
Open →Digital Number Systems Lab
Convert, toggle bits, trace every step — or test yourself in practice mode.
Open →Browse the full circuit toolkit or start a guided lesson in topics.