Combinational logic

Digital logic & computing · tree view

Combinational circuits — adders, decoders, multiplexers — produce outputs that depend only on the current input combination; Karnaugh maps minimize the gate count needed to realize any truth table.

Prerequisites

ttl-7400 symbol
ttl-7400
cmos-4000 symbol
cmos-4000
half-adder.svg
half-adder.svg
mux-demux.svg
mux-demux.svg
decoder-2to4.svg
decoder-2to4.svg
kmap-minimization.svg
kmap-minimization.svg

In mathematics a combination is an unordered set, which is a formal way to say that nobody cares which order the items came in. Most games work this way, if you rolled dice one at a time and get a 2 followed by a 3 it is the same as if you had rolled a 3 followed by a 2. With combinational logic, the circuit produces the same output regardless of the order the inputs are changed.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Introduction source

Practical circuits will have a mix of combinational and sequential logic, with sequential logic making sure everything happens in order and combinational logic performing functions like arithmetic, logic, or conversion.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Introduction source

Simplifying boolean equations or making some Karnaugh map will produce the same circuit shown below, but start by looking at the results. The Σ column is our familiar XOR gate, while the Cout column is the AND gate. This device is called a half-adder for reasons that will make sense in the next section.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — A Half-Adder source

A decoder is a circuit that changes a code into a set of signals. It is called a decoder because it does the reverse of encoding, but we will begin our study of encoders and decoders with decoders because they are simpler to design.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Decoder source

A common type of decoder is the line decoder which takes an n-digit binary number and decodes it into 2n data lines.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Decoder source

A demultiplexer, sometimes abbreviated dmux, is a circuit that has one input and more than one output. It is used when a circuit wishes to send a signal to one of many devices. This description sounds similar to the description given for a decoder, but a decoder is used to select among many devices while a demultiplexer is used to send a signal among many devices.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Demultiplexers source

A multiplexer, abbreviated mux, is a device that has multiple inputs and one output.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Multiplexers source

For any large combinational circuit there are generally two approaches to design: you can take simpler circuits and replicate them; or you can design the complex circuit as a complete device.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — A Full-Adder source

Maurice Karnaugh, a telecommunications engineer, developed the Karnaugh map at Bell Labs in 1953 while designing digital logic based telephone switching circuits.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 8 — Karnaugh maps, truth tables, and Boolean expressions source

Karnaugh maps reduce logic functions more quickly and easily compared to Boolean algebra. By reduce we mean simplify, reducing the number of gates and inputs. We like to simplify logic to a lowest cost form to save costs by elimination of components. We define lowest cost as being the lowest number of gates with the lowest number of inputs per gate.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 8 — Karnaugh maps, truth tables, and Boolean expressions source

Note the sequence of numbers across the top of the map. It is not in binary sequence which would be 00, 01, 10, 11. It is 00, 01, 11 10, which is Gray code sequence. Gray code sequence only changes one binary bit as we go from one number to the next in the sequence, unlike binary. That means that adjacent cells will only vary by one bit, or Boolean variable.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 8 — Logic simplification with Karnaugh maps source

On a cautionary note, do not attempt to form groups of three. Groupings must be powers of 2, that is, 1, 2, 4, 8 ...

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 8 — Larger 4-variable Karnaugh maps source

As you might suspect, a Sum-Of-Products Boolean expression is literally a set of Boolean terms added (summed) together, each term being a multiplicative (product) combination of Boolean variables.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 7 — Converting truth tables into Boolean expressions source
Show alternative explanations

Look at the Karnaugh map as being a rearranged truth table. The Output of the Boolean equation may be computed by the laws of Boolean algebra and transfered to the truth table or Karnaugh map.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 8 — Karnaugh maps, truth tables, and Boolean expressions source

Informally, there is a lot of confusion. Both demultiplexers and multiplexers have similar names, abbreviations, schematic symbols and circuits, so confusion is easy. The term multiplexer, and the abbreviation mux, are often used to also mean a demultiplexer, or a multiplexer and a demultiplexer working together.

— kuphaldt-linac DIGI, Vol. IV (Digital), ch. 9 — Multiplexers source

QUARTER ADDER circuits produce the sum of two numbers but do not generate a carry. HALF ADDER circuits produce the sum of two numbers and generate a carry. FULL ADDER circuits add a carry to obtain the correct sum.

— NEETS Module 13, Module 13, ch. 3 summary (adders), p. 3-41

Half adder — Σ is XOR, Cout is AND

Add two bits: 0+0=0, 0+1=1, 1+0=1, and 1+1=10₂ — one column of sum plus a carry. The sum bit Σ equals A XOR B; the carry-out equals A AND B. Two gates are the whole adder.

To predict the outcome:

  1. Write the four single-bit addition facts in binary, keeping the carry.
  2. Fill the Σ column with A ⊕ B.
  3. Fill the Cout column with A · B.
  4. Note the 11 row: Σ=0, Cout=1 — that carry is why 1+1 writes "10".
absum_sigmacarry_outbinary_sum
000000
011001
101001
110110

Full adder — three inputs, eight rows

Chain the carry: a full adder sums bit A, bit B and the carry from the column to the right (Cin). Σ = A ⊕ B ⊕ Cin, and Cout = AB + Cin·(A ⊕ B). Stack one full adder per bit and any word width adds.

To predict the outcome:

  1. Add the three bits as ordinary numbers (0, 1, 2 or 3).
  2. Σ is that total mod 2 (the odd/even part); Cout is the total halved (⌊total/2⌋).
  3. Verify the all-ones row: 1+1+1 = 11₂ → Σ=1, Cout=1.
abcinsum_sigmacout
00000
00110
01010
01101
10010
10101
11001
11111

2-to-1 multiplexer — the select line picks the data

A mux is a data switch: Y follows A when S=0 and B when S=1 (Y = A·S′ + B·S). With two data inputs and one select there are 2³ = 8 full input combinations.

To predict the outcome:

  1. For each row, ask only one question: what is S?
  2. S=0 → copy A into Y, ignore B; S=1 → copy B into Y, ignore A.
  3. Check the S column against Y in every row — Y must equal the selected input each time.
absyselected
0000A
0010B
0100A
0111B
1001A
1010B
1101A
1111B

4-to-1 multiplexer — two select bits address four data lines

Four data inputs (D3…D0), two select bits (S1 S0): select value n (0–3) routes Dn through to Y. To see the routing clearly, the data pattern is fixed at D3D2D1D0 = 0101 in every row; only the select changes, and Y must follow the addressed line.

To predict the outcome:

  1. Read S1S0 as a binary address (00=0, 01=1, 10=2, 11=3).
  2. Y must equal the selected Dn for that address — D0 when 00, D1 when 01, D2 when 10, D3 when 11.
  3. With the fixed pattern 0101, check each Y against the addressed bit.
d3d2d1d0s1s0yselected_line
0101001D0
0101010D1
0101101D2
0101110D3

2-to-4 line decoder — one address, one hot line

A 2-to-4 decoder turns a 2-bit address A1A0 into four data lines where exactly the addressed line goes high (one-hot): D0 = A1′·A0′, D1 = A1′·A0, D2 = A1·A0′, D3 = A1·A0. Four gates, four unique codes.

To predict the outcome:

  1. Read A1A0 as a binary address (0–3).
  2. For each row, mark which of D0–D3 must be 1 — the row whose number equals the address.
  3. Confirm exactly one 1 per row and every line gets exactly one row.
a1a0d3d2d1d0
000001
010010
100100
111000

K-map minimization worked example — F(A,B,C) = Σm(1,3,5,6,7)

Plot each minterm as a 1 on a 3-variable K-map (A rows, BC columns in Gray code 00,01,11,10). Two groups cover all the 1s: a quad of the four cells with C=1 (minterms 1,3,5,7 — C is the only variable they share), and a pair on the AB=11 column (minterms 6,7 — they share A and B). Reading each group as one product term gives F = C + AB.

To predict the outcome:

  1. Write a product term per minterm (SOP): A′B′C + A′BC + AB′C + ABC′ + ABC — five terms, ungainly to simplify by algebra alone.
  2. Plot the 1s in the map; groups must be rectangles of 1, 2, 4, 8 cells, and may wrap around the edges.
  3. Circle the quad (right four cells: all have C=1) → term "C".
  4. Circle the pair (bottom row, AB=11 columns) → term "AB".
  5. OR the group terms: F = C + AB. Two gates instead of five terms.
mintermabcfcovered_by
00000—
10011quad → C
20100—
30111quad → C
41000—
51011quad → C
61101pair → AB
71111quad → C and pair → AB

Candidate projects — awaiting review

  • Ben Eater-style 4-bit ripple adder: build two stacked full-adder stages (or all four) from 74LS86 XOR + 74LS08 AND + 74LS32 OR chips on breadboards, set A and B with DIP switches, read the 5-bit sum on LEDs, and check ten additions by hand in binary. (https://www.reddit.com/r/programming/comments/f8xybc/learn_how_computers_add_numbers_and_build_a_4_bit/, community)
  • Minimum-gate adder challenge: after the classic build, re-derive your full-adder Cout with a K-map and rebuild with the cheapest gate set you can manage (the book's chain form: Cout = AB + Cin·(A ⊕ B)), then race both versions on the 111+1 worst-case carry propagation. (https://www.instructables.com/4-Bit-Binary-Adder-FINAL-PROJECT/, community)
  • Two-out-of-three sensor voter: take Kuphaldt's incinerator flame-vote truth table, minimize F = AB + BC + AC with a K-map, build it from two or three gates, and verify all eight input rows with LEDs and switches. (https://www.ibiblio.org/kuphaldt/electricCircuits/DIGI/DIGI_8.html (Logic simplification with Karnaugh maps), book)
  • Multiplexed 4-digit display: one BCD-to-7-segment decoder chip shared across four digits through a 4-to-1 mux/demux pair driven by a slow oscillator — reproduce the book's scanning architecture and confirm only one digit is lit at a time, yet all four appear steady. (https://www.ibiblio.org/kuphaldt/electricCircuits/DIGI/DIGI_9.html (Using multiple combinational circuits), book)