Core Lesson Content
Encoding, Routing, and Converting Signals
Lessons 5 and 6 gave you gates and memory. This lesson supplies the traffic system β combinational circuits that move information between forms and destinations. Every device here is built purely from Lesson 5's gates (no storage, no clock needed), yet each solves a problem so common it's sold as its own chip:
- An encoder converts one active input line into a coded output, usually binary or BCD β compressing many wires into a few.
- A decoder performs the reverse, taking an N-bit input and activating one of many output lines.
- A multiplexer selects one of many inputs and sends it to a single output line.
- A demultiplexer takes one input and routes it to one of many outputs.
- An ADC converts an analog signal into a digital code, and a DAC converts a digital code back into an analog signal β the two doors between this course's analog half and its digital half.
Try It Live
Encoders: Many Lines In, a Code Out
What They Are
An encoder is a combinational circuit that converts an active input line into a smaller coded output. A basic encoder assumes only one input is active at a time: press one line, read its binary name. An 8-to-3 encoder watches eight input lines and outputs the 3-bit code of whichever is active.
How They Work
Internally it's just OR gates: each output bit ORs together every input line whose number has a 1 in that bit position. Y0 = I1+I3+I5+I7, Y1 = I2+I3+I6+I7, Y2 = I4+I5+I6+I7 β Lesson 5's place value implemented in gates.
The Priority Encoder
What if two keys are pressed at once? A basic encoder produces garbage (the OR gates merge both codes). A priority encoder resolves the conflict by encoding only the highest-priority active input, and typically adds a valid flag output indicating whether any input is present at all. This is the version real systems use β the 74HC148 in classic TTL, and the interrupt-priority logic inside every microprocessor.
Applications
- Keyboard and keypad interfacing: 10 digit keys β a 4-bit BCD code (decimal-to-BCD encoding), so the processor reads one nibble instead of scanning ten wires.
- Octal-to-binary and other code conversions.
- Input reduction wherever many signals must be compressed into fewer lines β sensor arrays, interrupt controllers, position encoders.
Decoders: A Code In, One Line Out
What They Are
A decoder accepts an N-bit input and activates one of up to 2α΄Ί outputs β essentially the reverse of an encoder. A 2-to-4 decoder maps 2 input bits to 4 outputs; a 3-to-8 maps 3 bits to 8 lines. Many decoders include an enable input that turns the whole device on or off: when disabled, all outputs remain inactive regardless of the input code.
How They Work
For each binary input combination, exactly one output line is selected. Each output is an AND gate decoding its own address: Y5 = A2Β·A1̅Β·A0Β·EN fires only for code 101 with enable high. It's Lesson 5's truth-table thinking in silicon β one AND gate per row.
EN=0: all eight outputs inactive, whatever the code
Applications
- Memory address decoding: the computer's address bus feeds decoders whose outputs are chip-select lines β the decoder decides which memory chip answers each address. Enable inputs let decoders cascade to cover huge address spaces.
- Seven-segment display driving: a BCD-to-seven-segment decoder/driver converts each 4-bit digit into the aβg segment pattern lighting the LEDs (Lesson 2!) of a numeric display.
- Data routing, device selection, and sequencing control β anywhere one-of-many must be chosen by a binary code.
Multiplexers: The Data Selector
What They Are
A multiplexer (MUX) is a data selector: it chooses one input from many and forwards it to one output. The choice is controlled by select lines, and the payoff is that a multiplexer reduces multiple data paths into a single channel.
How They Work
The select code is read as a binary number naming the chosen channel: S1S0 = 10 connects input D2 to the output. Internally, gate networks (or transmission-gate structures in CMOS) route only the chosen input through β each data input is ANDed with its address decode, and the results are ORed into the single output.
Applications
- Data selection in CPUs and digital systems: register-file reads, choosing between ALU sources β a processor is full of MUXes making choices every clock cycle.
- Bus sharing and communication channel reduction: many devices, one set of wires; the MUX decides who transmits.
- Implementing logic functions: a clever classic β wire a truth table's outputs to a MUX's data inputs, drive the select lines with the variables, and the MUX is the function. One 8-to-1 MUX can implement any 3-variable Boolean function from Lesson 5.
Demultiplexers: The Data Distributor
What They Are
A demultiplexer (DEMUX) is the multiplexer's mirror image: it takes one input and distributes it to one of several outputs β a one-to-many data distributor. Like the MUX, it uses select lines to choose the destination.
How They Work
The input signal is passed to only the selected output line; all other outputs remain inactive. Set S1S0 = 11 on a 1-to-4 DEMUX and whatever arrives at the input appears on Y3 alone.
Applications
- Data distribution to multiple destinations: one data source feeding whichever subsystem is addressed.
- Serial-to-parallel style routing: incoming serial data steered into parallel destinations slot by slot.
- Driving devices, memory write-lines, and output selection systems.
MUX + DEMUX: Sharing One Channel
Put the two mirrors face to face and you get one of digital communication's founding ideas. A MUX at the sending end funnels several signals into one shared channel; a DEMUX at the receiving end, driven by synchronized select lines, sorts them back out to their destinations.
Time-Division Multiplexing
Now scan the select lines rapidly β 00, 01, 10, 11, repeat. Each source gets the channel for a slice of time, and the receiver's DEMUX (stepping in lockstep) delivers each slice to the matching output. Four conversations share one wire, invisible to all four:
Select lines scan 00β01β10β11β00β¦ on both ends, synchronized
- Why it matters: wires, connectors, and radio spectrum are expensive; select logic is cheap. Telephone trunks, digital audio interfaces, and sensor networks all ride on this trade.
- The synchronization requirement is the hard part β if the two ends disagree about the select code, every message arrives at the wrong door. Real links send framing/clock information for exactly this reason (and Lesson 6's flip-flop synchronizers help tame it).
- Scaling: the same structure with faster scanning and more channels is how thousands of calls share one fiber.
Analog-to-Digital Converters
Every real-world signal β temperature, sound, light, pressure β arrives as a continuous analog quantity, usually a voltage from one of the sensors and amplifier circuits you built in Lessons 1β4. An ADC converts that continuous voltage into a digital number the logic world can store and compute with. Three steps:
- Sampling: measure the input at regular instants β snapshots of a moving waveform. The sampling rate must be fast enough to capture the signal's changes (at least twice the highest signal frequency), or the reconstruction misrepresents the original.
- Quantizing: round each sample to the nearest of 2βΏ discrete levels. The rounding error is the quantization error β the unavoidable price of going digital.
- Encoding: output each level as its binary code (Lesson 5's numbers, at last, coming from a real signal).
Resolution: The Bit Budget
8-bit ADC, 5 V range: 256 levels, ~19.5 mV steps Β· 12-bit: 4096 levels, ~1.2 mV
The resolution and sampling rate together determine how accurately the signal is represented β each extra bit halves the step size, each doubling of sample rate captures faster changes. Both cost money and power, which is why choosing an ADC is always an engineering trade.
Applications
- Microphones, sensors, and measurement instruments β your multimeter's entire front end is a careful ADC.
- Data acquisition systems logging real-world signals for analysis.
- Embedded controllers and communication systems that need digital processing of real-world signals.
Digital-to-Analog Converters
The DAC performs the reverse operation: it converts a binary value into a proportional analog output β the door back out of the digital world, to speakers, motors, displays, and control actuators.
How They Work
- Weighted conversion networks: each bit contributes a current or voltage proportional to its place value β the MSB contributes half the range, the next bit a quarter, and so on. Practical designs use R-2R ladder voltage dividers (only two resistor values, easy to match) feeding a summing op-amp β the inverting amplifier from Lesson 4 doing the addition.
- The stepped output: the raw output holds each converted value until the next code arrives, producing a staircase waveform.
- Filtering: a low-pass filter smooths the steps into a continuous signal β the final handshake between digital data and the analog world.
Applications
- Audio playback: every digital audio path ends in a DAC β millions of samples per second becoming a voltage that moves a speaker cone.
- Signal generation and waveform synthesis: function generators compute waveforms digitally and DAC them into existence.
- Control systems and actuator interfaces: a controller's computed output becomes the analog drive for valves, heaters, and motor speed references.
The Six Devices, Side by Side
| Device | Input | Output | Main Function | Typical Uses |
|---|---|---|---|---|
| Encoder | Many lines, usually one active | Fewer coded bits | Compress input information | Keypads, code conversion |
| Decoder | N-bit code | Up to 2α΄Ί lines | Expand code to one active line | Memory decoding, displays |
| Multiplexer | Many data inputs | One output | Select one source | Bus routing, logic design |
| Demultiplexer | One input | Many outputs | Send signal to one destination | Data distribution, routing |
| ADC | Analog signal | Digital code | Sample and quantize | Sensors, instruments |
| DAC | Digital code | Analog signal | Reconstruct analog output | Audio, control, waveform generation |
Where They Live Together
- Memory systems: decoders select chips and rows; MUXes route data lines.
- Displays: decoders drive segments; MUXes scan multiple digits over shared wires.
- Communication: MUX/DEMUX pairs share channels; ADC/DAC pairs bookend every digital link that touches the physical world.
- Sensors & audio: an analog MUX lets one ADC serve many sensors in turn; a DAC plus a Lesson 4 filter and amplifier completes the return path.