Chapter 4: Combinational Logic Circuits
Source files used: ELEC205 Week 3 slides (slides 40-46), Week 5 slides (slides 16-44), Week 6 slides; textbook Chapter 4 as support. No worked examples are included.
1. Big Picture
Chapter 4 is the standard “plays” built from gates: adders, decoders, encoders, multiplexers.
Chapters 2 and 3 asked: how do we build and minimize one function? Chapter 4 asks: what are the reusable building blocks, and how do we design any function with them?
New ideas in this chapter:
- XOR/XNOR as odd/even functions and parity,
- half adder, full adder, ripple-carry adder,
- 2’s complement adder/subtractor and overflow detection,
- decoders (and implementing functions with them),
- encoders and priority encoders,
- multiplexers (and implementing functions with them), demultiplexers.
Erzin groups the blocks by job: decoding, encoding, selecting.
2. Core Ideas
2.1 Analysis vs Design
Analysis: given a circuit, find what it does.
- exhaustive (truth table),
- algebraic (expressions),
- simulation / test bench (HDL description, test vectors, compare with a known-good model).
Design: given a specification, build the circuit. Either write the equations directly from “logic”, or brute-force it: truth table → canonical sum → minimize (Chapter 3).
2.2 XOR: The Odd Function
is 1 when the inputs differ. A multi-input XOR is 1 when an odd number of inputs are 1 (sum modulo 2). XNOR is the even function.
The K-map of a 3- or 4-input XOR is a checkerboard: no two 1’s are adjacent, so it cannot be simplified as SOP. That is why XOR gets its own gate.
2.3 Parity
Multi-input XOR computes parity. A chain of 2-input XORs works but has a long delay line. A parity tree (balanced XOR tree) gives the same result with less delay.
2.4 Building Wide Adders
A 32-bit adder is a 64-input, 33-output combinational system. Its truth table is impossible to write, so it is built from 1-bit cells: a half adder (or a full adder with ) at bit 0 and full adders above, with each carry feeding the next stage. Two 32-bit adders cascade into a 64-bit adder by connecting of the low half to of the high half.
2.5 Subtraction with an Adder
In 2’s complement, . Invert every bit of and set the LSB carry-in to 1. No separate subtractor is needed.
2.6 Decoders
A decoder maps an -bit code to output lines. With enable on, exactly one output is 1: output is minterm of the inputs. With enable off, all outputs are 0.
Applications: selecting memory banks or I/O devices, instruction decoding, memory row selection, seven-segment (4-to-7) decoding.
2.7 Encoders and Priority
An encoder is the reverse of a decoder: inputs to an -bit code. A plain encoder assumes exactly one input is active. If two inputs are active, or none, it gives a wrong or ambiguous code.
A priority encoder fixes this: the highest-priority active input wins, lower inputs become don’t-cares, and a valid output says whether any input is active.
2.8 Multiplexers
A MUX selects one of many inputs and sends it to a single output. With select bits it has data inputs (-to-1 MUX). A demultiplexer (DMUX) is the inverse: one input routed to one of outputs. A 1-to-4 DMUX is the same circuit as a 2-to-4 decoder with enable, with the enable used as the data input.
3. Main Governing Equations and Formulas
3.1 XOR Identities
is why an XOR works as a controlled inverter (used in the adder/subtractor).
3.2 XOR with Four NAND Gates
One shared NAND makes , two NANDs combine it with and , one output NAND.
3.3 Half Adder
Adds two bits with no carry-in. One XOR and one AND.
3.4 Full Adder
Built from two half adders plus an OR gate: the first HA makes and , the second adds , the OR combines the two carries.
3.5 Ripple-Carry Adder
Bit 0 is on the right; the carry ripples right to left. full adders make an -bit adder, and the final carry is .
3.6 Adder/Subtractor
Each passes through an XOR with a control line ; also drives :
Use for any “add or subtract with one circuit” question (slide Fig. 3-31).
3.7 Overflow Detection
For an -bit 2’s complement adder/subtractor:
where is the carry out of the MSB and is the carry into the MSB. means overflow.
Slide examples (4 bits, range ): has carries , so : overflow. has carries : overflow. and have equal last two carries: no overflow.
(the carry out itself) is the overflow indicator for unsigned numbers; is the one for signed numbers.
3.8 Decoder Outputs
For a 2-to-4 decoder with enable :
In general:
3.9 Decoder Expansion
3-to-8 from two 2-to-4 decoders with enable:
go to both decoders. The upper decoder produces - (), the lower produces - (). With an overall enable, AND it into both enables.
3.10 Function from Decoder + OR
An -to- decoder generates every minterm, so any -variable function (or several functions at once) needs only one OR gate per output. Use when a question says “decoder and external OR gates”.
3.11 Binary Encoder (8-to-3)
Each output bit ORs the inputs whose index has that bit set. Valid only if exactly one input is 1.
3.12 4-to-2 Priority Encoder
Priority :
When (no input active), are don’t-cares. Derived from K-maps of Table 3-6 using the don’t-cares.
3.13 8-to-3 Priority Encoder from Two 4-to-2s
Let encoder A take - (outputs ) and encoder B take - (outputs ). The upper group has priority:
acts as the select of two 2-to-1 MUXes.
3.14 4-to-1 MUX
Each term is a select minterm ANDed with its data input. In general, a -to-1 MUX outputs . A quadruple 2-to-1 MUX is four 2-to-1 MUXes sharing one select line (selects a 4-bit word).
3.15 Function from a MUX
An -variable function fits a -to-1 MUX. Put the first variables on the selects; each data input becomes one of
where is the last variable. This is the Shannon expansion applied to the select variables.
Slide example: with , gives , , , .
Slide example: on an 8-to-1 MUX with gives , , , , , , , .
4. Problem-Solving Workflow
4.1 Implementing with a -to-1 MUX
- Write the truth table with the select variables as the leading (most significant) columns.
- Split the rows into pairs that share the same select values.
- In each pair, compare with the last variable:
- → ,
- → ,
- equals the last variable → ,
- is its complement → .
- Connect, making sure is the least significant select variable.
4.2 Implementing with a Decoder
- Express each output as (expand terms to minterms if given as an expression).
- Use an -to- decoder on the inputs.
- OR the decoder outputs listed in each function.
- If a function has many minterms, OR the outputs of and invert (NOR), which needs fewer inputs (textbook tip).
4.3 Designing a Priority Encoder
- Write the condensed truth table (inputs below the highest active one are X).
- Plot each output on a K-map, filling X rows as don’t-cares.
- Minimize each output; add as the OR of all inputs.
4.4 Adder/Subtractor Questions
- Choose the control: add, subtract.
- XOR each with ; set .
- Ripple through the full adders.
- Check overflow with .
5. Decision Rules / Decision Trees
5.1 Which Building Block?
Need exactly one of lines active from an -bit code? → decoder
Need the index of the active line as a code? → encoder (priority encoder if several can be active)
Need to route one of many inputs to one output? → multiplexer
Need many functions of the same inputs? → one decoder + one OR per function
Need one function of inputs with a single block? → -to-1 MUX
5.2 Overflow or Carry?
Operands are unsigned? → look at (carry out)
Operands are 2’s complement? → look at
5.3 Priority Encoder Output
Highest active input is ? → output is in binary, lower inputs ignored,
No input active? → , outputs are don’t-care
6. Important Tables / Correlations Needed
6.1 Adder Truth Tables
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
The half adder is the first four rows with (rows give ).
6.2 2-to-4 Decoder with Enable
| 0 | X | X | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
6.3 4-to-2 Priority Encoder (Table 3-6)
| 0 | 0 | 0 | 0 | X | X | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | X | 0 | 1 | 1 |
| 0 | 1 | X | X | 1 | 0 | 1 |
| 1 | X | X | X | 1 | 1 | 1 |
6.4 Block Size Summary
| Block | Inputs | Outputs | Control |
|---|---|---|---|
| -to- decoder | (+ enable) | enable | |
| -to- encoder | (+ if priority) | none | |
| -to-1 MUX | data | 1 | select |
| 1-to- DMUX | 1 data | select |
Slide quiz facts: a decoder with inputs has at most outputs; a priority encoder favoring higher indices with outputs .
7. Key Takeaways
- XOR is the odd function, XNOR the even function; their K-maps are checkerboards and cannot be simplified.
- Half adder: , . Full adder: , .
- Subtraction: invert , set ; one XOR per bit makes an adder/subtractor.
- Signed overflow: ; unsigned overflow: carry out .
- Decoder output is minterm ; decoder + OR gates implement any function.
- Expanding decoders: the extra MSB drives the enables ( and ).
- Priority encoder (4-to-2): , , OR of all inputs.
- 4-to-1 MUX: .
- -variable function on a -to-1 MUX: data inputs are , , or .
- Trap: check which variable goes to (LSB select); swapping selects scrambles the data inputs.