Booth's Multiplication Algorithm

Published: | 20 min read | Author: Hayashi Jirou | Edu. Level: Tertiary

How do computers multiply signed numbers? In this article, we will explore in detail the Booth algorithm for multiplication. Included are long examples of applying the algorithm, many explanations and a look at the modified Booth algorithm (Radix-4, Radix-8).

One commonly discussed type of binary multiplier is the Booth multiplier; a hardware multiplier based on Booth’s multiplication algorithm. This algorithm was invented by Andrew Donald Booth in 1950 and aims to simplify the multiplication of two, signed nn bit numbers. The sign of these numbers being represented by the two’s complement notation.

Booth multipliers have the advantage of potentially reducing the amount of additions / subtractions needed to perform a multiplication. If we take the advanced form of the algorithm which is known as modified Booth algorithm, then we can even reduce the amount of partial products that must be added together. Both of these benefits help us speed up the process of multiplication by reducing the propagation delay of our calculating circuit.

In order to understand the Booth algorithm, you should already be familiar with regular binary multiplication also known as long multiplication. You should also have an understanding of basic binary arithmetic in the form of addition and subtraction with two’s complement.

Multiplication Basics

Let us start by defining some terminology. We define a multiplication of two nn bit numbers as:

a×b=Pa \times b = P

Both numbers a,ba,b are known as factors inside a multiplication. The multiplication of numbers is communicative which is why we usually make no distinction between the two factors. For the Booth algorithm, however, we want to distinguish the two numbers. We call aa the multiplicand and bb the multiplicator.

The result PP is known as the product. When we do long multiplication we will generally have partial results that we need to add together in the final step to receive the product. We call these partial results partial products and we will denote them as pppp.

Booth Algorithm (Booth-1 / Radix-2)

Booth’s algorithm works by re-encoding the partial multiplication steps we do as part of normal long multiplication. This re-encoding will result in simplified partial products which, when added together, will produce a final product that is already in two’s complement notation.

The re-encoding is determined by the bits that make up the multiplicator bb. The Booth algorithm always looks at every pair of two bits (yiy_i, yi1y_{i-1}) in the multiplicator bb starting from the right-most place, the LSB, and moving toward the left.

To start, we write out our binary number bb. Let us take b=610=01102b = 6_{10} = 0110_{2} as an example:

b=0110b = 0110

For Booth’s algorithm to work, we must append an additional bit before the LSB. This is because we start by defining our LSB as our first yiy_i. Therefore, we must add an implicit 00 bit before the LSB to act as our first yi1y_{i-1}.

b=01100b = 0110\color{red}{0}

We can now start encoding by looking at ever pair (yiy_i, yi1y_{i-1}) and defining an operation that will be performed on our multiplicand aa from earlier. The encoding table looks as follows:

yiyi1Operation on aComment000xMultiply a by 001+xMultiply a by 110xMultiply a by -1110xMultiply a by 0\begin{array}{|r|r|r|r|} \hline y_i & y_{i-1} & \text{Operation on } a & \text{Comment} \\ \hline 0 & 0 & 0x & \text{Multiply $a$ by 0} \\ 0 & 1 & +x & \text{Multiply $a$ by 1} \\ 1 & 0 & -x & \text{Multiply $a$ by -1} \\ 1 & 1 & 0x & \text{Multiply $a$ by 0} \\ \hline \end{array}

We do not have to understand yet how to apply these operations. Let us first take our example multiplicator bb and re-encode it according to the table.

Encoding the multiplicator

We start by looking at the first pair (y1y_1, y0y_0):

b=01100    0xb = 011\underbrace{00}_{\implies 0x}

This pair is (0000) so it encodes to "0x0x" according to the table.
Next up is the pair (y2y_2, y1y_1):

b=0110    x0b = 01\underbrace{10}_{\implies -x}0

Here we have the pair (1010) which encodes to "x-x".
The pattern should be obvious by now. Here we have the last two encodings:

b=011    0x00b=01    +x100b = 0\underbrace{11}_{\implies 0x}00\\ b = \underbrace{01}_{\implies +x}100

The pairs are (1111) and (0101) which map to "0x0x" and "+x+x" respectively.

Inserting the encoded operations

Our encoding of the multiplicator bb has given us four operations that we will perform on the multiplicand aa. We will perform these operations just as we would in normal long multiplication, so writing our multiplication and partial results out in columns.

Lets write out the multiplication vertically like a long multiplication. For our example we will set a=710=1001a = -7_{10} = 1001

23222120a=1001Operation=+x0xx0x\begin{array}{r|r|r|r|r} & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & 1 & 0 & 0 & 1 \\ Operation = & +x & 0x & -x & 0x \\ \end{array}

Notice how our place values (the 2i2^is) are in binary and accordingly aligned with our multiplicand aa. Also notice that below every place value, we have inserted the corresponding “operation” that we derived from encoding the multiplicator bb.

For example, the first operation we encoded from the pair (y1y_1, y0y_0) was (0000). We therefore put the corresponding operation "0x0x" into the first column from the right. The next pair (y2y_2, y1y_1) was (1010) and so we put into the second column from the right the operation "x-x".

With all that set up, we are ready to calculate our partial products.

Performing the multiplication

We will now multiply the entire multiplicand aa with whatever operation is written in the column we are currently looking at. Fortunately, all our “multiplying” is actually just multiplying by 00, 11 or 1-1. That means we must only insert zeros, insert aa or insert the two’s complement of aa respectively.

Let start calculating our first partial product pp1pp_1:

2726252423222120a=1001Operation=+x0xx0xpp1=00000000\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & & & & & 1 & 0 & 0 & 1 \\ Operation = & & & & & +x & 0x & -x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{array}

Any number multiplied by 00 is trivially 00 as well. Thus, we have already calculated our first partial product: pp1=00000000pp_1 = 00000000. Notice that we are now using twice the bits we did to display the result. This is because when multiplying nn bits, we can receive an output that requires 2n2n bits.

Let us look at our next partial product pp2pp_2:

2726252423222120a=1001Operation=+x0xx0xpp1=00000000pp2=00001110\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & & & & & 1 & 0 & 0 & 1 \\ Operation = & & & & & +x & 0x & -x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 1 & 1 & 1 & \color{grey}{0} \end{array}

Here we multiply aa by -1, which yields us 01112=7100111_2 = 7_{10}. Multiplying any number by 1-1 flips the sign of that number. In this case, we simply take the two’s complement of aa.

Note that just like in decimal long multiplication, we fill all columns to the right of the column we are looking at with zeros. In this case, we put a zero into the 202^0 column for our pp2pp_2 row (notice the gray color).

We continue with pp3pp_3:

2726252423222120a=1001Operation=+x0xx0xpp1=00000000pp2=00001110pp3=00000000\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & & & & & 1 & 0 & 0 & 1 \\ Operation = & & & & & +x & 0x & -x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 1 & 1 & 1 & \color{grey}{0} \\ pp_3 = & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} & \color{grey}{0} \end{array}

Just like pp1pp_1, the result is all zero.

Let us calculate the final partial product pp4pp_4:

2726252423222120a=1001Operation=+x0xx0xpp1=00000000pp2=00001110pp3=00000000pp4=11001000\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & & & & & 1 & 0 & 0 & 1 \\ Operation = & & & & & +x & 0x & -x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 1 & 1 & 1 & \color{grey}{0} \\ pp_3 = & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} & \color{grey}{0} \\ pp_4 = & 1 & 1 & 0 & 0 & 1 & \color{grey}{0} & \color{grey}{0} & \color{grey}{0} \end{array}

Here we simply multiplied aa by 11, yielding us aa again. However, notice that we also filled the 272^7 column with a 11 as well.

This is because our number 7-7 is in two’s complement form. When we expand our 4 bit number into an 8-bit number, all new leading bits must take over the same value as the MSB of our original 4 bit number.

Negative two’s complement numbers always have 11 as their MSB, therefore we copy that value into all leading bits as well, meaning column 272^7 is filled with 11 too.

Adding the partial products

All that is left to do is to add together our partial products and arrive at the final result:

2726252423222120pp1=00000000pp2=00001110pp3=00000000pp4=11001000+00010000P=11010110\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 0 \\ pp_3 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_4 = & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 \\ \hline \\ + & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ \hline \\ P = & 1 & 1 & 0 & 1 & 0 & 1 & 1 & 0 \end{array}

Our binary addition yields us 110101102=4210=7×611010110_2 = -42_{10} = -7 \times 6. Booth’s algorithm has correctly produced a final product that is also in two’s complement form.

Note how two of our partial products (pp1pp_1, pp3pp_3) were just all zero, meaning we did not need to account for them while doing our addition. This is an example of how the Booth algorithm can potentially reduce the amount of additions we need to make.

However, there remains one major issue we have not yet encountered nor addressed: multiplying with the most negative number our nn bits can present.

Multiplying with the most negative number

The most negative number is special because multiplying it by 11 or 1-1 yields the same result when we are confined to our original nn bits. Let us take 810=10002-8_{10} = 1000_2 as an example and apply the two’s complement to it, i.e. multiplying by 1-1:

¬1000=01110111+0001=1000\neg1000 = 0111\\ 0111 + 0001 = 1000\\

This circumstance causes Booth algorithm to not produce correct results when utilizing the most negative number. Luckily, we can fix this.

In order to use the most negative number, we must expand our multiplicand aa by one leading bit. Just like we added leading bits to our partial product, we simply copy the MSB of aa and append it to the left of aa again:

a=1000a=11000a = 1000\\ a' = \color{red}{1}\color{black}1000

From now on, we always use aa' for every time we perform the Booth algorithm. Let us see this change in action.

We will calculate 8×8-8 \times -8. Encoding b=10000b = 1000\color{red}{0} will yield us the following operations, right to left: 0x0x, 0x0x, 0x0x, x-x

Let us draw our multiplication table but this time insert aa'.

2726252423222120a=11000Operation=x0x0x0xpp1=00000000pp2=00000000pp3=00000000\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a' = & & & & \color{red}{1} & 1 & 0 & 0 & 0 \\ Operation = & & & & & -x & 0x & 0x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} \\ pp_3 = & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} & \color{grey}{0} \end{array}

Note how in column 242^4, the bit of aa' is now an explicit 11, giving us more “space”. This causes the two’s complement produce the value of 0100001000: the additional bit we added allows us to represent +8+8.

Let us now look at the final result:

2726252423222120a=11000Operation=x0x0x0xpp1=00000000pp2=00000000pp3=00000000pp4=01000000+00000000P=01000000\begin{array}{r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a' = & & & & \color{red}{1} & 1 & 0 & 0 & 0 \\ Operation = & & & & & -x & 0x & 0x & 0x \\ \hline pp_1 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ pp_2 = & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} \\ pp_3 = & 0 & 0 & 0 & 0 & 0 & 0 & \color{grey}{0} & \color{grey}{0} \\ pp_4 = & 0 & 1 & 0 & 0 & 0 & \color{grey}{0} & \color{grey}{0} & \color{grey}{0} \\ \hline \\ + & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline \\ P = & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \end{array}

As expected we get the correct answer 010000002=6410=8×801000000_2 = 64_{10} = -8 \times -8.

Can you see that we would have gotten a wrong answer of 64-64 if we had used the old aa instead of aa'?

Summary

We can summarize Booth’s algorithm as a five-step process:

  1. Add a 00 as a trailing bit before the LSB of the multiplicator bb
  2. Pairwise encode all bits of bb according to the encoding table
  3. Add a leading bit after the MSB of the multiplicand aa. This bit has the same value as the MSB of aa.
  4. Calculate the partial products. Multiply aa by the respective numbers that were derived from encoding bb in step 2.
  5. Add all partial products together.

It is also important to remember:

  • The partial products should be 2n2n bits long. When adding leading bits, remember that they take the same value as the MSB of the nn bit long number.
  • Fill the columns to the right of the currently processed column with zeros. Like in ordinary, decimal long multiplication

Modified Booth Algorithm (Booth-2 / Radix-4)

The “normal” Booth algorithm has the potential to reduce the amount of partial products we need to add together. However, this is only the case if one or more partial products ends up being zero.

In terms of a hardware implementation, this is of little use to us. The propagation delay is determined by the critical path in our circuit. That is the path which is the longest and takes the most amount of time. For the Booth algorithm, the longest path would be if all partial products are non-zero. We always have to take the worst case scenario as the basis for our circuit. This means that we have no significant speed benefit from utilizing a Booth multiplier when compared to a regular multiplier.1

The modified Booth algorithm is an advanced version of Booth’s algorithm and fixes this speed issue by consistently reducing the amount partial products. It does so by encoding the multiplicator three bits at a time.

While the modified Booth algorithm is slightly more complicated, it is often the preferred algorithm for signed multiplication due to its significant speed benefit.

Radix-4 encoding

The modified Booth algorithm uses a radix-4 encoding, meaning we now encode triplets of the multipliator bb. We define each triplet of bits as (yi+1y_{i+1}, yiy_{i}, yi1y_{i-1}).

With three bits, we now have eight encoding possibilities. The encoding table for radix-4 looks as follows:

yi+1yiyi1Operation on aComment0000xMultiply a by 0001+xMultiply a by 1010+xMultiply a by 1011+2xMultiply a by 21002xMultiply a by -2101xMultiply a by -1110xMultiply a by -11110xMultiply a by 0\begin{array}{|r|r|r|r|r|} \hline y_{i+1} & y_i & y_{i-1} & \text{Operation on } a & \text{Comment} \\ \hline 0 & 0 & 0 & 0x & \text{Multiply $a$ by 0} \\ 0 & 0 & 1 & +x & \text{Multiply $a$ by 1} \\ 0 & 1 & 0 & +x & \text{Multiply $a$ by 1} \\ 0 & 1 & 1 & +2x & \text{Multiply $a$ by 2} \\ 1 & 0 & 0 & -2x & \text{Multiply $a$ by -2} \\ 1 & 0 & 1 & -x & \text{Multiply $a$ by -1} \\ 1 & 1 & 0 & -x & \text{Multiply $a$ by -1} \\ 1 & 1 & 1 & 0x & \text{Multiply $a$ by 0} \\ \hline \end{array}

The important additions are "2x2x" and "2x-2x". They demand that we multiply our multiplicand by aa by 22 or 2-2 respectively.

Multiplying and diving by powers of two is very easy with binary numbers. To multiply by two, all bits must only be shifted once to the left.

Example

Let us look at a 4 bit example to see how the modified Booth algorithm works.

We will be calculating a×ba\times b with a=510=00101a = 5_{10} = 00101 and b=610=0110b = 6_{10} = 0110. Note that we have already added a leading bit to our number aa.

We start by encoding bb. Remember to append a trailing 00 to it for the encoding process.

b=01100    2xb=011    +2x00b = 01\underbrace{100}_{\implies -2x}\\ b = \underbrace{011}_{\implies +2x}00\\

With the modified algorithm, we only encode two operations from our 4 bit multiplicator: "2x-2x" and "+2x+2x".

Let us draw the multiplication table.

2423222120a=00101Operation=+2x2x\begin{array}{r|r|r|r|r|r} & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & 0 & 0 & 1 & 0 & 1 \\ Operation = & & & +2x & & -2x \\ \end{array}

Note how we only have two operations and that these two operations are at different place values. Our first operation is still placed in the 202^0 column. The second operation is placed in the 222^2 column. This is because we utilize a radix-4 encoding: our operations are written in the columns which are powers of four. If we had a third operation we would write it in the 242^4 column, a fourth into the 262^6 column and so on.

Let us now calculate our partial products:

2726252423222120a=00101Operation=+2x2xpp1=11110110pp1=00101000+11000000P=00011110\begin{array}{r|r|r|r|r|r|r|r|r|} & 2^7 & 2^6 & 2^5 & 2^4 & 2^3 & 2^2 & 2^1 & 2^0 \\ \hline a = & & & & 0 & 0 & 1 & 0 & 1 \\ Operation = & & & & & & +2x & & -2x \\ \hline pp_1 = & 1 & 1 & 1 & 1 & 0 & 1 & 1 & \color{red}{0} \\ pp_1 = & 0 & 0 & 1 & 0 & 1 & \color{red}{0} & \color{grey}{0} & \color{grey}{0} \\ \hline \\ + & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline \\ P = & 0 & 0 & 0 & 1 & 1 & 1 & 1 & 0 \end{array}

Notice that per new row, we add two zeros to the right. Because we are in radix-4, we automatically skip every second column.

For the multiplication by 22 we simply shift our result one column to the left. These shifts are highlighted in red (0\color{red}{0}).

Our final result is 000111102=3010=5×600011110_2 = 30_{10} = 5 \times 6 which is correct.

The modified Booth algorithm has halved the amount of partial products compared to the normal Booth algorithm. This gives us a significant speed benefit because we only need to do one addition instead of three additions.

Reducing partial products

The amount of partial products created by a given Booth algorithm can be calculated like so:

nNb=Amount of partial products\lceil{\frac{n}{N_b}}\rceil = \text{Amount of partial products}

nn is the amount of bits the factors use. NbN_b is the number denoting the different types of Booth’s algorithm (Booth-1, Booth-2, Booth-3…).

We multiplied 4 bit numbers with Booth-1 (normal) and Booth-2 (modified). Let us verify the formula gives us the same partial products we saw during our examples:

Booth-1 with 4 bit=nNb=41=4\text{Booth-1 with 4 bit} = \lceil{\frac{n}{N_b}}\rceil = \lceil{\frac{4}{1}}\rceil = 4 Booth-2 with 4 bit=nNb=42=2\text{Booth-2 with 4 bit} = \lceil{\frac{n}{N_b}}\rceil = \lceil{\frac{4}{2}}\rceil = 2

We can see that the normal Booth algorithm never reduces the amount of partial products when compared to conventional multiplication. The amount of partial products is equal to the amount of bits used.

The modified Booth algorithm halves the amount of partial products which is why it is the preferred algorithm for hardware implementations.

Booth-3 / Radix-8

Given the significant reduction of partial products with the modified Booth algorithm, we might consider to look at the next level and encode four bits at a time. This algorithm is called Booth Radix-8 or Booth-3 and would result in only a third of the usual partial products.

The radix-8 algorithm looks at quadruples of bits: (yi+2y_{i+2},yi+1y_{i+1}, yiy_{i}, yi1y_{i-1}).
The table has 16 different encodings:

yi+2yi+1yiyi1Operation on aComment00000xMultiply a by 00001+xMultiply a by 10010+xMultiply a by 10011+2xMultiply a by 20100+2xMultiply a by 20101+3xMultiply a by 30110+3xMultiply a by 30111+4xMultiply a by 410004xMultiply a by -410013xMultiply a by -310103xMultiply a by -310112xMultiply a by -211002xMultiply a by -21101xMultiply a by -11110xMultiply a by -111110xMultiply a by 0\begin{array}{|r|r|r|r|r|r|} \hline y_{i+2} & y_{i+1} & y_i & y_{i-1} & \text{Operation on } a & \text{Comment} \\ \hline 0 & 0 & 0 & 0 & 0x & \text{Multiply $a$ by 0} \\ 0 & 0 & 0 & 1 & +x & \text{Multiply $a$ by 1} \\ 0 & 0 & 1 & 0 & +x & \text{Multiply $a$ by 1} \\ 0 & 0 & 1 & 1 & +2x & \text{Multiply $a$ by 2} \\ 0 & 1 & 0 & 0 & +2x & \text{Multiply $a$ by 2} \\ 0 & 1 & 0 & 1 & +3x & \text{Multiply $a$ by 3} \\ 0 & 1 & 1 & 0 & +3x & \text{Multiply $a$ by 3} \\ 0 & 1 & 1 & 1 & +4x & \text{Multiply $a$ by 4} \\ 1 & 0 & 0 & 0 & -4x & \text{Multiply $a$ by -4} \\ 1 & 0 & 0 & 1 & -3x & \text{Multiply $a$ by -3} \\ 1 & 0 & 1 & 0 & -3x & \text{Multiply $a$ by -3} \\ 1 & 0 & 1 & 1 & -2x & \text{Multiply $a$ by -2} \\ 1 & 1 & 0 & 0 & -2x & \text{Multiply $a$ by -2} \\ 1 & 1 & 0 & 1 & -x & \text{Multiply $a$ by -1} \\ 1 & 1 & 1 & 0 & -x & \text{Multiply $a$ by -1} \\ 1 & 1 & 1 & 1 & 0x & \text{Multiply $a$ by 0} \\ \hline \end{array}

Unfortunately this encoding has a huge problem: the odd multiples "3x3x" and "3x-3x". Unlike powers of two (2x2x, 4x4x) which we can easily realize in binary by left-shifting, multiplying by 33 or any odd number is not so simple.

Because of the odd multiples, the radix-8 algorithm is not often considered for hardware implementations. However, if the odd multiples can be overcome, there is a benefit in further reducing the amount of partial products.

The practical use and calculation of radix-8 and beyond is left up to the reader from this point.

Bibliography

  • Booth, Andrew Donald, 1951, “A Signed Binary Multiplication Technique”
  • Brown University, 2010, “Booth’s Algorithm for Multiplication”

Footnotes

  1. A Booth multiplier still has a speed advantage over a regular multiplier given it multiplies and preserves the sign. It does more work in the same amount of time it would take a regular long multiplier to do unsigned multiplication.