---
title: Multipliers and dividers
heading: Partial products, Booth recoding, reduction trees and iterative division
eyebrow: S3 · Lesson 9 · Multipliers and dividers
xp: 50
---

::: hook
An N-bit multiplier forms N rows of partial products, each a copy of one operand ANDed with one bit of the other, and adds them. Adding N rows one after another is slow; the art of multiplier design is cutting the number of rows (Booth recoding) and adding them in a tree of carry-save adders that never propagate a carry until the very end (Wallace and Dadda trees). Division is harder still: it's inherently sequential in its simple forms, so fast dividers either do several bits per cycle or switch to Newton–Raphson iteration, which doubles the number of correct bits every step.
:::

::: play
- The depth of the partial-product reduction against the operand width N, in carry-save adder stages. A linear array adds one row per stage (N − 2 stages); a Dadda tree of 3:2 counters reduces the heights through 2, 3, 4, 6, 9, 13, 19, 28, 42, 63, … so its depth grows logarithmically.
- Radix-4 Booth recoding halves the rows before the tree, saving a stage or two.
- After reduction, two rows remain, and one fast carry-propagate adder (lesson 8) finishes the product.
:::
:::

```sim plot
view: graph
x: N = 4..64
y: s = 0..64
plot: N - 2 | samples: 300 | label: linear array, N − 2 stages
plot: step(N - 2.5) + step(N - 3.5) + step(N - 4.5) + step(N - 6.5) + step(N - 9.5) + step(N - 13.5) + step(N - 19.5) + step(N - 28.5) + step(N - 42.5) + step(N - 63.5) | samples: 600 | color: ch2 | label: Dadda tree
plot: step(N/2 - 2.5) + step(N/2 - 3.5) + step(N/2 - 4.5) + step(N/2 - 6.5) + step(N/2 - 9.5) + step(N/2 - 13.5) + step(N/2 - 19.5) + step(N/2 - 28.5) | samples: 600 | color: ch3 | label: Booth radix-4 + Dadda tree
```

::: predict
## A 32 × 32-bit multiplier's partial products are reduced by a Dadda tree. About how many carry-save stages does that take?

- [ ] 30
- [ ] 16
- [x] 8
- [ ] 5

::: reveal
Eight. Each stage of 3:2 counters reduces the height of the partial-product matrix by about a factor of 1.5, following the Dadda heights 2, 3, 4, 6, 9, 13, 19, 28: 32 rows need eight steps to come down to 2. A linear array would need 30. With radix-4 Booth recoding, 16 rows need only 6 stages.
:::
:::

::: nameit
## Partial products

Multiplying an M-bit number by an N-bit number gives N rows of M partial-product bits (M × N AND gates), shifted and summed into an M + N bit product.

## Carry-save reduction

A full adder used as a **3:2 counter** takes three bits of the same weight and outputs a sum bit (same weight) and a carry bit (next weight), without propagating anything. A layer of them turns three rows into two in one full-adder delay. **Wallace** and **Dadda** trees apply layers until two rows remain; Dadda's schedule reduces the column heights to the sequence 2, 3, 4, 6, 9, 13, 19, 28, 42, 63, …, each $\lfloor1.5\times\rfloor$ the last, using the fewest counters. The depth is the number of entries in that sequence below N.

## Booth recoding

Radix-4 Booth recoding scans the multiplier two bits at a time (with one bit of overlap) and turns each pair into one of 0, ±1, ±2 times the multiplicand, all easy to form by shifting and negating. It halves the number of rows, to about N/2. It also handles two's complement operands naturally.

## Sequential and FPGA multipliers

A shift-and-add multiplier uses one adder for N cycles. FPGAs provide hard multiplier blocks (for example 18 × 27 bits) that are far faster and smaller than LUT-built ones; larger multiplies are tiled from several.

## Division

- **Restoring and non-restoring** division produce one quotient bit per cycle by trial subtraction: N cycles for N bits.
- **SRT** division uses a redundant digit set so each step's guess needn't be exact, allowing faster steps or radix 4.
- **Newton–Raphson** iterates $x_{k+1} = x_k(2 - dx_k)$ toward 1/d. The error squares each step, so the number of correct bits doubles: from an 8-bit seed in a lookup table, 3 iterations give 64 bits. Each step costs two multiplications, so it pays off when a fast multiplier already exists.
:::

::: example
## Size a 32 × 32 multiplier: partial-product bits, product width, rows after Booth recoding, and Dadda stages with and without Booth.

::: solution
1. **Partial products.**
   $$32 \times 32 = 1024\ \text{bits}$$
   one AND gate each, and the product is 64 bits wide.
2. **Booth recoding.** Booth radix-4 cuts the 32 rows to 16 (17 for unsigned operands).
3. **Dadda stages.** From 32 rows it takes 8 stages ($28 < 32 \leq 42$); from 16 rows, 6 stages ($13 < 16 \leq 19$).
4. **Final add.** A 64-bit prefix adder finishes the product.

**Answer:** 1024 partial-product bits and a 64-bit product; Booth makes 16 rows (17 unsigned); Dadda takes 8 stages without Booth and 6 with it.
:::
:::

::: example
## A divider starts Newton–Raphson from an 8-bit-accurate table lookup. How many iterations reach 53 bits (a double's mantissa)?

::: solution
1. **Double the bits each iteration.**
   $$8 \to 16 \to 32 \to 64$$
   so three iterations exceed 53, at six multiplications.
2. **Against restoring division.** A one-bit-per-cycle restoring divider would take 53 cycles. That's why high-performance floating-point units use multiplicative division, while small microcontrollers use the restoring kind.

**Answer:** three iterations (six multiplications).
:::
:::

::: example
## A Newton–Raphson divider computes 1/0.75 from the seed $x_0$ = 1.3. Follow the error $\varepsilon_k = 1 - dx_k$ for two iterations.

::: solution
1. **Starting error.**
   $$\begin{aligned} \varepsilon_0 &= 1 - 0.75 \times 1.3 \\ &= 0.025 \end{aligned}$$
2. **First iteration.**
   $$\begin{aligned} x_1 &= x_0(2 - dx_0) \\ &= 1.3 \times 1.025 \\ &= 1.3325 \end{aligned}$$
   and the error squares:
   $$\begin{aligned} \varepsilon_1 &= \varepsilon_0^2 \\ &= 6.25 \times 10^{-4} \end{aligned}$$
3. **Second iteration.**
   $$\begin{aligned} \varepsilon_2 &= \varepsilon_1^2 \\ &= 3.9 \times 10^{-7} \end{aligned}$$
4. **Correct bits.** That's about 5, 11 and 21 correct bits, doubling each time toward 1.33333.

**Answer:** the error goes 0.025, $6.25 \times 10^{-4}$, $3.9 \times 10^{-7}$: about 5, 11 and 21 correct bits.
:::
:::

::: check
given: M = 8 | 16 | 24; N = 8 | 12 | 32
answer: M + N
tolerance: 0

## An {M}-bit number is multiplied by an {N}-bit number. How wide is the product?

::: right
Right. M + N = {answer} bits.
:::

::: misses
- [(M + N + abs(M - N))/2] The product needs the sum of the widths, not the larger one.
- [any] Not yet. The largest product is $(2^M - 1)(2^N - 1)$.
:::
:::

::: check
given: M = 8 | 16 | 24; N = 8 | 12 | 32
answer: M*N
tolerance: 0

## How many partial-product bits (AND gates) does an {M} × {N}-bit multiplier form?

::: right
Right. M × N = {answer}.
:::

::: misses
- [any] Not yet. One row of M bits for each of the N multiplier bits.
:::
:::

::: check
given: N = 9 | 13 | 19 | 28 | 32 | 50
answer: step(N - 2.5) + step(N - 3.5) + step(N - 4.5) + step(N - 6.5) + step(N - 9.5) + step(N - 13.5) + step(N - 19.5) + step(N - 28.5) + step(N - 42.5) + step(N - 63.5)
tolerance: 0

## How many Dadda reduction stages does it take to bring {N} rows of partial products down to 2?

::: right
Right. Counting the Dadda heights 2, 3, 4, 6, 9, 13, 19, 28, 42 below {N}: {answer} stages.
:::

::: misses
- [N - 2] That's a linear array; the tree reduces by about 1.5× per stage.
- [any] Not yet. Count the entries of 2, 3, 4, 6, 9, 13, 19, 28, 42, 63 that are smaller than N.
:::
:::

::: check
given: N = 16 | 24 | 54
answer: N/2
tolerance: 0

## Radix-4 Booth recoding of an {N}-bit signed multiplier gives how many partial-product rows?

::: right
Right. N/2 = {answer}.
:::

::: misses
- [N] Booth radix-4 handles two bits per row.
- [any] Not yet. One row per pair of bits.
:::
:::

::: check
given: s = 4 | 8; b = 24 | 53 | 113
answer: ceil(log(b/s)/log(2) - 0.0001)
tolerance: 0

## Newton–Raphson division starts from a {s}-bit-accurate seed. How many iterations reach {b} correct bits?

::: right
Right. The accuracy doubles each step: {answer} iterations.
:::

::: misses
- [b - s] Convergence is quadratic: bits double, they don't add one at a time.
- [any] Not yet. Double {s} until it reaches {b}.
:::
:::

::: check
given: N = 16 | 32 | 64; f = 100 | 500
answer: N/(f*1e6)*1e9
unit: ns
tolerance: 0.5%

## A restoring divider produces one quotient bit per cycle at {f} MHz. How long does an {N}-bit division take?

::: right
Right. N cycles: {answer} ns.
:::

::: misses
- [any] Not yet. One bit per clock.
:::
:::

::: check
kind: parts
given: M = 8 | 16 | 32; N = 8 | 16 | 32

## An unsigned {M} × {N} multiplier reduces its partial products with a Dadda tree (heights 2, 3, 4, 6, 9, 13, 19, 28, …).

::: part
answer: M*N
tolerance: 0

### How many partial-product bits (AND gates) does it form?

::: misses
- [any] One per bit pair.
:::
:::

::: part
answer: M + N
tolerance: 0

### How wide is the product?

::: misses
- [any] M + N bits.
:::
:::

::: part
answer: step(N - 2.5) + step(N - 3.5) + step(N - 4.5) + step(N - 6.5) + step(N - 9.5) + step(N - 13.5) + step(N - 19.5) + step(N - 28.5)
tolerance: 0

### How many reduction stages does the Dadda tree need for its {N} rows?

::: misses
- [any] Count the Dadda heights below the row count.
:::
:::
:::

::: check
kind: derivation
vars: d = 0.5..1, e = 0.001..0.1

## A Newton–Raphson reciprocal of d starts from a seed whose error is $\varepsilon_0 = 1 - dx_0$ = e.

::: step
answer: (1 - e)/d

### What is the seed $x_0$?
:::

::: step
answer: (1 - e^2)/d

### What is $x_1 = x_0(2 - dx_0)$?
:::

::: step
answer: e^4

### What is the error after two iterations?
:::

::: right
Right. The error squares each step, so the correct bits double.
:::
:::

::: explain
## Why does a carry-save adder tree add many rows faster than adding them one at a time with ordinary adders?

::: model
An ordinary adder must propagate carries across its full width before its result is valid, so adding N rows one after another costs N carry propagations in series. A carry-save adder never propagates: each full adder takes three bits of the same weight and passes its carry to the next column as a separate output, to be added in the next layer. A layer of them turns three rows into two in the time of one full adder, regardless of width. Arranged as a tree, the layers cut the number of rows by a factor of about 1.5 each, so N rows come down to two in a number of steps that grows only logarithmically. Only then does one carry-propagate adder resolve the carries, once.
:::
:::

::: practice

::: check
given: M = 12 | 20; N = 10 | 18
answer: M + N
tolerance: 0

## Product width: {M} × {N} bits?

::: misses
- [any] M + N.
:::
:::

::: check
given: N = 8 | 12 | 16 | 24 | 32 | 40 | 53
answer: step(N - 2.5) + step(N - 3.5) + step(N - 4.5) + step(N - 6.5) + step(N - 9.5) + step(N - 13.5) + step(N - 19.5) + step(N - 28.5) + step(N - 42.5) + step(N - 63.5)
tolerance: 0

## Dadda stages for {N} rows?

::: misses
- [any] Count Dadda heights below N.
:::
:::

::: check
given: s = 6 | 10; b = 32 | 64
answer: ceil(log(b/s)/log(2) - 0.0001)
tolerance: 0

## Newton–Raphson iterations: {s}-bit seed to {b} bits?

::: misses
- [any] Doublings needed.
:::
:::
:::
