CampusFlow
ArchitectureBooth's Algorithm

✖️ Booth's Algorithm

Signed binary multiplication using bit shifting and addition/subtraction. Reduces the number of partial products for efficient hardware implementation.

What is Booth's Algorithm?

ℹ️

Purpose

Booth's Algorithm multiplies signed binary numbers in two's complement form. It works by examining adjacent bit pairs of the multiplier to determine whether to add, subtract, or just shift the multiplicand.

Invented by Andrew Donald Booth in 1951, the algorithm handles both positive and negative multipliers uniformly and reduces the number of add/sub operations when there are consecutive 1s or 0s.

Booth's Algorithm Flowchart

StartA = 0, Q₋₁ = 0, M = MultiplicandCount = n (number of bits)Q₀Q₋₁?1001A = A - MA = A + M00 or 11No opArithmetic Shift Right A, Q, Q₋₁Count = n?YesNoEnd

Interactive Simulator

How Booth's Algorithm Works

The algorithm operates on n-bit signed binary numbers in two's complement form. Three registers are used:

  • A (Accumulator): n-bit register, initialized to 0
  • Q (Multiplier): n-bit register holding the multiplier
  • Q₋₁: 1-bit register, initialized to 0
  • M (Multiplicand): n-bit register holding the multiplicand

At each step, examine the LSB of Q (Q₀) and Q₋₁:

Q₀Q₋₁Operation
00No arithmetic operation. Arithmetic Shift Right.
01Add M to A. Arithmetic Shift Right.
10Subtract M from A. Arithmetic Shift Right.
11No arithmetic operation. Arithmetic Shift Right.

Numerical Example: 7 × 3

StepQ₀Q₋₁OperationAQQ₋₁
0Initial000000110
110A = A - MA=0000-0111=100110010011
ASR110010011
211No op110010011
ASR111001001
301A = A + MA=1110+0111=010101010100
ASR001010100
400No op001010100
ASR000101010

Result: A:Q = 0001:0101 = 21 (decimal). ✓

Code Example

python

def booth_multiply(M: int, Q: int, bits: int = 4) -> int:
    A = 0
    Q_1 = 0
    mask = (1 << bits) - 1
    M_neg = ((~M) + 1) & mask  # two's complement negation

    for step in range(bits):
        q0 = Q & 1
        if q0 == 0 and Q_1 == 1:
            A = (A + M) & mask
        elif q0 == 1 and Q_1 == 0:
            A = (A + M_neg) & mask
        
        # arithmetic shift right (A:Q:Q_1)
        lsb_A = A & 1
        msb_A = (A >> (bits - 1)) & 1
        A = (A >> 1) | (msb_A << (bits - 1))
        Q = (Q >> 1) | (lsb_A << (bits - 1))
        Q_1 = q0

    result = (A << bits) | Q
    sign = (result >> (2 * bits - 1)) & 1
    return result if sign == 0 else result - (1 << (2 * bits))

Interview Questions

Why is Booth's Algorithm used in hardware multiplication?

Booth's Algorithm allows multiplication of signed binary numbers using only addition, subtraction, and shifting operations. It reduces the number of partial products, especially when the multiplier has consecutive 1s or 0s, making it efficient for hardware implementation in ALUs.

How does Booth's Algorithm handle negative multipliers?

Unlike simple multiplication algorithms, Booth's Algorithm naturally handles negative multipliers because it works with two's complement representation. The algorithm examines pairs of bits (Q₀ and Q₋₁) and subtracts M when it sees a '10' pattern, which effectively handles the sign extension needed for negative numbers.

What is the difference between Booth's Algorithm and the modified Booth's Algorithm?

The modified (Booth-2/radix-4) algorithm examines 3 bits at a time (overlapping by 1), reducing the number of partial products by half. While standard Booth's does n steps for n-bit numbers, the modified version does n/2 steps, using operations like +M, +2M, -M, -2M instead of just +M and -M.