Logo
All chapters
Volume II: Digital Logic  ›  Combinational Logic

Binary Adder–Subtractor

Chain full adders to add multi-bit numbers; flip a control line to subtract.

PrevDesign Procedure
NextDecimal Adder

Description

A combinational circuit that adds (or subtracts) two n-bit binary numbers. Addition is the core operation an ALU must perform; subtraction reuses the same hardware. Cascade n full adders; for subtract, XOR the B inputs with a mode line and set carry-in = 1.

  • Adds three bits (A, B, carry-in) → Sum and Carry-out.
  • Sum = A ⊕ B ⊕ Cin; Cout = AB + Cin(A ⊕ B).
  • Carry-out of each stage feeds the carry-in of the next — it 'ripples'.
  • Subtraction: invert B and set carry-in to 1 (adds the two's complement).
  • Trade-off: simple but slow — carry must propagate through every stage.
  • What: A combinational circuit that adds (or subtracts) two n-bit binary numbers.
  • Why: Addition is the core operation an ALU must perform; subtraction reuses the same hardware.
  • How: Cascade n full adders; for subtract, XOR the B inputs with a mode line and set carry-in = 1.
  • Where: The arithmetic core of every CPU/GPU ALU and DSP datapath.
  • When: Any integer add, subtract, compare, or address calculation.

At a glance

What

A combinational circuit that adds (or subtracts) two n-bit binary numbers.

Why

Addition is the core operation an ALU must perform; subtraction reuses the same hardware.

How

Cascade n full adders; for subtract, XOR the B inputs with a mode line and set carry-in = 1.

Where

The arithmetic core of every CPU/GPU ALU and DSP datapath.

When

Any integer add, subtract, compare, or address calculation.

Think of it like…

A ripple adder is a bucket brigade: each person can't pass water (carry) until the one before them does. The last bucket waits the longest — that wait is the adder's delay.

Full adder

  • Adds three bits (A, B, carry-in) → Sum and Carry-out.
  • Sum = A ⊕ B ⊕ Cin; Cout = AB + Cin(A ⊕ B).

Ripple carry & subtract

  • Carry-out of each stage feeds the carry-in of the next — it 'ripples'.
  • Subtraction: invert B and set carry-in to 1 (adds the two's complement).
  • Trade-off: simple but slow — carry must propagate through every stage.

Full-adder truth table

ABCinSumCout
00000
00110
01010
01101
10010
10101
11001
11111

Black-box view

A[3:0]B[3:0]Cin4-bit Adderblack boxSum[3:0]Cout

Inputs on the left → outputs on the right · particles show signal direction

Functional / block diagram

A,BCin
FA bit0
FA bit1
FA bit2
FA bit3
SumCout

Functional blocks · arrows animate in the direction data flows

Logic diagram

0Sum0CoutA0B0Cin0XORXORANDANDOR

Click inputs to toggle · glowing wires carry 1 · particles show signal direction

4-bit ripple adder / subtractor

▶ live simulator
A = 11
1bit weight 2^30bit weight 2^21bit weight 2^11bit weight 2^0
B = 6
0bit weight 2^31bit weight 2^21bit weight 2^10bit weight 2^0
carry in
1100
(cin=0)
Sum = 1
·bit weight 2^3·bit weight 2^2·bit weight 2^11bit weight 2^0

Carry out = 1 · the glowing column is the full-adder stage currently computing; carry ripples right→left.

HDL — Verilog · VHDL · SystemVerilog

module adder #(parameter N = 4)
  (input  [N-1:0] a, b,
   input          cin,
   output [N-1:0] sum,
   output         cout);
  assign {cout, sum} = a + b + cin;
endmodule

Parameterized adder. '+' synthesizes to a carry chain; {cout,sum} captures the carry.

Real-world applications

Every CPU/GPU ALUAddress generation unitsDSP MAC (multiply-accumulate)Program counters & loop indicesChecksum / CRC accumulation

The 5 Whys

  1. 1

    Why chain full adders? To add numbers wider than one bit.

  2. 2

    Why does carry ripple? Each bit's sum depends on the carry from the bit below.

  3. 3

    Why is ripple slow? The last bit must wait for the carry to travel through all stages.

  4. 4

    Why tolerate it anyway? It is the smallest, simplest adder — fine for narrow widths.

  5. 5

    Root cause: speed-vs-area trade-off; faster adders (carry-lookahead) cost more gates.

Cheat sheet

Working principle

  • Cascade n full adders; for subtract, XOR the B inputs with a mode line and set carry-in = 1.
  • A combinational circuit that adds (or subtracts) two n-bit binary numbers.

Formulas & Boolean expressions

  • Sum = A ⊕ B ⊕ Cin
  • Cout = A·B + Cin·(A ⊕ B)
  • Subtract: A − B = A + B′ + 1
  • Overflow = Cn ⊕ Cn₋₁
  • Sum = A ⊕ B ⊕ Cin; Cout = AB + Cin(A ⊕ B).

Key facts

  • Adds three bits (A, B, carry-in) → Sum and Carry-out.
  • Carry-out of each stage feeds the carry-in of the next — it 'ripples'.

Why it exists

  • Root cause: speed-vs-area trade-off; faster adders (carry-lookahead) cost more gates.
PrevDesign Procedure
NextDecimal Adder