Skip to main content

Logic Gates · 45 min

Combinational Circuits

Circuits whose outputs are pure functions of current inputs, from gates to adders, comparators, multipliers, delay, fan-out, and glitches.

Why This Matters

A 64-bit ripple-carry adder built from full adders with a 90 ps carry delay has a worst-case carry path near 5.76 ns before wire delay. At 3 GHz, one clock cycle is about 333 ps, so that adder cannot sit alone on one cycle without a different architecture or pipelining.

Combinational circuits are the stateless part of digital computation. Integer addition, address comparison, instruction decoding, multiplexing, and much of a CPU datapath are Boolean functions realized as gates and wires. The same rules also explain why a simulator may show a temporary wrong value for a few picoseconds before the final output settles.

Core Definitions

Definition

Combinational circuit

A combinational circuit is an acyclic interconnection of logic gates whose outputs at time t+dt + d are functions only of the input values applied at time tt, for some finite propagation delay dd. It has no memory elements and no feedback loop that stores a previous value.

Definition

Propagation delay

The propagation delay of a gate or wire segment is the time between an input transition crossing its switching threshold and the corresponding output transition crossing its threshold. In a combinational network, the worst-case delay is the maximum total delay over all input-to-output paths.

Definition

Critical path

The critical path is a path from some primary input to some primary output with maximum total delay. For a clocked system, the clock period must exceed the longest combinational delay between source and destination registers, plus register timing margins.

Definition

Fan-out

The fan-out of a signal is the number of gate inputs driven by that signal. Larger fan-out increases capacitance and usually increases delay. Logic equations alone do not capture this electrical loading.

A combinational circuit can be specified by a truth table, a Boolean expression, a gate-level netlist, or a hardware description language fragment. These are different views of the same object when the netlist is acyclic.

From Gates to Adders

A half-adder adds two one-bit inputs, aa and bb. It produces a sum bit ss and carry bit cc.

aabbsscc
0000
0110
1010
1101

The equations are s=abs = a \oplus b and c=abc = a b.

a ─────┬──── XOR ─── s
       │
b ─────┘

a ─────┬──── AND ─── c
       │
b ─────┘

A full-adder adds aa, bb, and an incoming carry cinc_{in}. It emits ss and coutc_{out}.

aabbcinc_{in}sscoutc_{out}
00000
00110
01010
01101
10010
10101
11001
11111

A useful implementation uses two half-adders and an OR gate:

s=abcins = a \oplus b \oplus c_{in}

cout=ab+cin(ab)c_{out} = ab + c_{in}(a \oplus b)

a ─────┬──── XOR ── x ─── XOR ─── s
       │                 │
b ─────┘                 │
                         │
c_in ────────────────────┘

a ─────┬──── AND ── c1 ──┐
       │                 │
b ─────┘                 OR ─── c_out
                         │
x ─────┬──── AND ── c2 ──┘
       │
c_in ──┘

A ripple-carry adder chains full-adders. For bit ii, it computes:

si=aibicis_i = a_i \oplus b_i \oplus c_i

ci+1=aibi+ci(aibi)c_{i+1} = a_i b_i + c_i(a_i \oplus b_i)

Worked 4-bit example, adding 011120111_2 and 000120001_2:

bit iiaia_ibib_icic_isis_ici+1c_{i+1}
011001
110101
210101
300110

The result is 100021000_2. The carry must travel through all four stages in this input case.

A C version is a useful executable specification:

#include <stdint.h>

uint8_t add4(uint8_t a, uint8_t b) {
    uint8_t carry = 0;
    uint8_t sum = 0;

    for (int i = 0; i < 4; i++) {
        uint8_t ai = (a >> i) & 1;
        uint8_t bi = (b >> i) & 1;
        uint8_t s = ai ^ bi ^ carry;
        uint8_t cout = (ai & bi) | (carry & (ai ^ bi));
        sum |= s << i;
        carry = cout;
    }
    return sum | (carry << 4);
}

For a = 0x7 and b = 0x1, this returns 0x08. For a = 0xF and b = 0x1, it returns 0x10, a five-bit result.

Carry Lookahead as a Prefix Computation

Ripple-carry addition has linear carry depth. Carry-lookahead reduces depth by separating each bit into generate and propagate signals.

For bit ii:

gi=aibig_i = a_i b_i

pi=aibip_i = a_i \oplus b_i

ci+1=gi+picic_{i+1} = g_i + p_i c_i

Here gig_i means bit ii generates a carry no matter what came in. pip_i means bit ii passes an incoming carry to the next bit.

For a 4-bit adder:

c1=g0+p0c0c_1 = g_0 + p_0 c_0

c2=g1+p1g0+p1p0c0c_2 = g_1 + p_1 g_0 + p_1 p_0 c_0

c3=g2+p2g1+p2p1g0+p2p1p0c0c_3 = g_2 + p_2 g_1 + p_2 p_1 g_0 + p_2 p_1 p_0 c_0

c4=g3+p3g2+p3p2g1+p3p2p1g0+p3p2p1p0c0c_4 = g_3 + p_3 g_2 + p_3 p_2 g_1 + p_3 p_2 p_1 g_0 + p_3 p_2 p_1 p_0 c_0

For a=01112a=0111_2, b=00012b=0001_2, and c0=0c_0=0:

iiaia_ibib_igig_ipip_i
01110
11001
21001
30000

Then c1=1c_1=1, c2=1c_2=1, c3=1c_3=1, and c4=0c_4=0. The sum bits are si=picis_i = p_i \oplus c_i, giving 00000000 for bits 0 through 2 and 11 for bit 3.

A prefix adder computes combined generate-propagate pairs. For a block from bit jj through bit ii:

Pi:j=pipi1pjP_{i:j} = p_i p_{i-1} \cdots p_j

Gi:j=gi+pigi1++pipi1pj+1gjG_{i:j} = g_i + p_i g_{i-1} + \cdots + p_i p_{i-1} \cdots p_{j+1} g_j

Then ci+1=Gi:0+Pi:0c0c_{i+1} = G_{i:0} + P_{i:0}c_0. A tree can combine adjacent pairs using:

(G,P)(G,P)=(G+PG,PP)(G,P) \circ (G',P') = (G + P G', PP')

This is the same associativity pattern as prefix sums. With a balanced tree, carry depth grows as O(logn)O(\log n) gate levels instead of O(n)O(n). The tradeoff is more gates and more wiring.

Multipliers from Shift and Add

Unsigned binary multiplication decomposes into partial products. Each bit of the multiplier either selects a shifted copy of the multiplicand or selects zero.

Compute 13×1113 \times 11 using 4-bit inputs:

        1101     13
      x 1011     11
      -----
        1101     bit 0 is 1
       11010     bit 1 is 1, shifted left 1
      000000     bit 2 is 0
     1101000     bit 3 is 1, shifted left 3
     -------
     10001111    143

At the gate level, each partial product bit is an AND:

ppi,j=aibjpp_{i,j} = a_i b_j

Then add shifted rows with adders. A direct array multiplier for 4 by 4 bits creates 16 AND gates and a grid of half-adders and full-adders. Its delay is usually dominated by carry propagation through the addition structure, not by the AND gates.

A shift-and-add sequential multiplier reuses one adder across cycles, but that circuit has state and is not purely combinational. A combinational multiplier does all selected shifts and additions in one combinational network, with one final output after the critical path settles.

Comparators and Magnitude Circuits

Equality is the easiest comparator. Two nn-bit words are equal exactly when every bit pair matches:

eq=i=0n1¬(aibi)eq = \bigwedge_{i=0}^{n-1} \neg(a_i \oplus b_i)

For a=101101002a=10110100_2 and b=101111002b=10111100_2, the XOR vector from bit 7 to bit 0 is 00001000, so the equality output is 0.

A magnitude comparator decides a>ba > b, a=ba = b, or a<ba < b. For unsigned numbers, compare from most significant bit downward. At the first differing bit, the word with 1 is larger.

For 4-bit words a3a2a1a0a_3a_2a_1a_0 and b3b2b1b0b_3b_2b_1b_0:

a>b=a3¬b3+e3a2¬b2+e3e2a1¬b1+e3e2e1a0¬b0a>b = a_3\neg b_3 + e_3 a_2\neg b_2 + e_3e_2 a_1\neg b_1 + e_3e_2e_1 a_0\neg b_0

where ei=¬(aibi)e_i = \neg(a_i \oplus b_i).

Worked example, a=10012a=1001_2 and b=01112b=0111_2:

bitaia_ibib_ieie_ilocal ai¬bia_i\neg b_i
31001
20100
10100
01110

The most significant differing bit is bit 3, so a>b=1a>b=1. Lower bits do not matter after bit 3 differs.

Delay, Critical Paths, Fan-Out, and Hazards

In a simple delay model, assign each gate a delay and add delays along paths. Suppose XOR has 70 ps delay, AND has 40 ps, OR has 40 ps, and a full-adder carry is implemented as ab+cin(ab)ab + c_{in}(a \oplus b).

For a carry input reaching coutc_{out} after aba \oplus b is already stable, the path is AND then OR, or 80 ps. If aa or bb changes and affects carry through XOR, AND, OR, the path is 150 ps. In a 32-bit ripple-carry adder, a worst-case carry propagation estimate using 80 ps per stage is 2.56 ns. A final sum bit may need one more XOR delay, so about 2.63 ns, excluding wire delay and input register delay.

Fan-out changes these numbers. A signal driving one nearby gate input may switch faster than a signal driving 32 gate inputs across a chip. Textbook Boolean algebra treats wires as free. Physical circuits do not.

Hazards are temporary wrong outputs caused by unequal path delays. Consider:

f=xy+¬xzf = xy + \neg x z

For y=1y=1 and z=1z=1, the Boolean function is always 1, no matter what xx is. A gate network can still glitch when xx changes from 1 to 0.

Assume NOT delay is 20 ps, AND delay is 30 ps, OR delay is 30 ps. Initially x=1x=1, so xy=1xy=1 and ¬xz=0\neg x z=0. When xx falls to 0, the direct path to xyxy turns off after 30 ps, while the inverted path turns on after 20 ps plus 30 ps, or 50 ps. For about 20 ps, both AND outputs can be 0, so the OR output drops to 0 before returning to 1.

The consensus term yzyz removes this static-1 hazard:

f=xy+¬xz+yzf' = xy + \neg xz + yz

For y=z=1y=z=1, the extra term is 1 during the transition. This does not change the truth table, but it changes transient behavior.

Main Theorem

Theorem

Sum-of-Products Universality for Combinational Circuits

Statement

Every Boolean function f:{0,1}n{0,1}f:\{0,1\}^n \to \{0,1\} can be implemented by an acyclic combinational circuit using AND, OR, and NOT gates.

Intuition

A truth table names every input row where the function returns 1. Build one small detector for each such row, then OR all detectors together.

Proof Sketch

For each input vector v=(v0,,vn1)v=(v_0,\ldots,v_{n-1}) with f(v)=1f(v)=1, form a minterm mvm_v. The minterm contains xix_i when vi=1v_i=1 and ¬xi\neg x_i when vi=0v_i=0, all joined by AND. This minterm is 1 exactly on row vv and 0 on every other row. Then compute ff as the OR of all minterms for which f(v)=1f(v)=1. If no rows return 1, use the constant 0 circuit. If every row returns 1, the OR contains all minterms or can be simplified to constant 1.

Why It Matters

This theorem justifies treating truth tables, Boolean expressions, and combinational gate networks as equivalent descriptions. Adders, comparators, decoders, multiplexers, and fixed lookup tables are all special cases.

Failure Mode

The construction may be large. A function with about half of its 2n2^n rows equal to 1 needs about 2n12^{n-1} minterms in the direct construction. Universality is not a size guarantee.

Common Confusions

Watch Out

A temporary glitch is not stored state

A hazard can make an output pulse for 20 ps, but that does not make the circuit sequential. If the network is acyclic and contains no latch or flip-flop, the final settled output remains a function of current inputs. State appears when feedback or storage elements preserve information after inputs change.

Watch Out

Carry-lookahead does not make addition constant time

Carry-lookahead reduces the depth of carry computation with a prefix tree. With bounded fan-in gates and real wires, depth grows with word size, often like O(logn)O(\log n) at the logic level. Wire delay and fan-out still matter.

Watch Out

The truth table ignores delay

A truth table specifies settled values. It does not specify whether an output briefly glitches before settling. Two circuits can implement the same Boolean function and have different transient behavior.

Exercises

ExerciseCore

Problem

Build the full-adder outputs for a=1a=1, b=0b=0, and cin=1c_{in}=1. Give ss, coutc_{out}, and the internal values x=abx=a\oplus b, c1=abc_1=ab, and c2=cin(ab)c_2=c_{in}(a\oplus b).

ExerciseCore

Problem

For an 8-bit ripple-carry adder, assume the carry path through one full-adder takes 85 ps and the final sum XOR takes 60 ps. Estimate the worst-case delay from c0c_0 to s7s_7.

ExerciseAdvanced

Problem

For f=xy+¬xzf=xy+\neg xz, use delays NOT 20 ps, AND 30 ps, and OR 30 ps. Let y=z=1y=z=1 and let xx switch from 1 to 0 at time 0. Give the time interval during which the OR inputs are both 0.

References

Canonical:

  • Charles Petzold, Code: The Hidden Language of Computer Hardware and Software, 2nd ed. (2022), ch. 10-14. Relays, gates, adders, and binary arithmetic.
  • David A. Patterson and John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 5th ed. (2013), Appendix B. Logic gates, combinational logic, adders, and ALU building blocks.
  • J. Clark Scott, But How Do It Know? The Basic Principles of Computers for Everyone (2009), ch. 2-8. Gates, adders, memory contrast, and datapath intuition.
  • M. Morris Mano and Michael D. Ciletti, Digital Design, 5th ed. (2013), ch. 3-4. Boolean algebra, gate-level simplification, combinational logic, adders, subtractors, and comparators.
  • John F. Wakerly, Digital Design: Principles and Practices, 4th ed. (2006), ch. 4-6. Combinational logic design, timing, hazards, and arithmetic circuits.

Accessible:

  • Nand2Tetris, Boolean Arithmetic and Combinational Chips project materials.
  • MIT OpenCourseWare, 6.004 Computation Structures, combinational logic and timing lectures.
  • Ben Eater, Building an 8-bit breadboard computer, videos on adders and arithmetic logic.

Next Topics

  • /computationpath/sequential-circuits
  • /computationpath/finite-state-machines
  • /computationpath/instruction-decoders
  • /computationpath/arithmetic-logic-units
  • /topics/boolean-algebra