Combinational logic is digital electronics without memory. The output depends solely on the current state of the inputs: there is no past, no history, only what is happening right now matters.
So far we have seen individual logic gates (AND, OR, NOT…). But when we start combining many of these gates to perform more useful tasks, we enter this domain.
The main characteristic of these circuits is that they have no memory. The output depends exclusively on the current state of the inputs. If you remove the inputs, the output disappears or changes instantaneously.
Today we will meet the two most important traffic controllers in digital electronics: the multiplexer (which selects paths) and the decoder (which identifies addresses).
| Component | Function | Analogy | Main Use |
|---|---|---|---|
| Multiplexer (MUX) | Many | TV input selector | Expanding inputs (reading many sensors). |
| Decoder | Binary | Mail sorter | Selecting chips (chip select), driving displays. |
| Demultiplexer | One | Train switch | Distributing one signal to multiple destinations. |
The Multiplexer (MUX): The Selector
Imagine you have only one analog input on your microcontroller, but you want to read 8 different sensors. How do you do it?
You need a digital “rotary switch”. That is a multiplexer.
A MUX is a device that has multiple data inputs and a single output. Using control pins (selectors), we decide which input is connected to the output.
Operation
The relationship is very simple: with n control pins we can select between
- Data inputs:
(8 inputs). - Selectors:
(3 pins, because ). - Output:
.
If we apply the binary 000 (0 decimal) to the selectors, the output 101 (5 decimal), the output
The king of MUX: 74HC4051 / CD4051 is the most famous chip in the world of microcontrollers for expanding inputs.
It is an 8-channel analog/digital multiplexer. With only 3 digital pins and 1 analog pin, we can read 8 potentiometers!
The Decoder
The decoder does the inverse work of an encoder. Its main function is to translate a binary code into a single active output.
Imagine your processor wants to talk to one of its 8 memory chips. The processor sends the address “5” in binary (101). The decoder receives this code and activates only output number 5, keeping all others off.
In most commercial decoders (like the 74HC series), the outputs are active low (they go to 0V when activated and to 5V when idle). This is because most chip select pins work this way.
Operation (One-Hot Encoding)
- Inputs: Binary code (e.g., 3 bits).
- Outputs:
lines (e.g., 8 lines). - Behavior: Only ONE output is active at a time.
The king of decoder: 74HC138, a 3-to-8 line decoder.
- You feed it a number from 0 to 7 in binary on its A, B, C pins.
- It sets the corresponding output (Y0 to Y7) to LOW.
The Demultiplexer (DEMUX): The Distributor
You will often see the term demultiplexer. In reality, it is the same hardware as the decoder, but used in a different way.
While the MUX is “many to one”, the DEMUX is “one to many”.
- It has a common data input.
- It has multiple outputs.
- It has selectors.
Depending on the number we set on the selectors, the data from the input is sent to the chosen output. It is like a train switch.
Most decoder chips can act as demultiplexers if we use their enable pin as a data input.
Practical Application: Controlling an LED Matrix
The classic example where MUX and decoders work together is an LED display (like the ones on bus signs).
Imagine an 8x8 LED matrix (64 LEDs).
- We don’t connect 64 wires.
- We connect the 8 rows to a decoder.
- We connect the 8 columns to a driver (or shift registers).
To light a pixel, the decoder activates row 1, and we send current through column 1. Then we quickly move to row 2. This allows us to control 64 points using very few pins.