Booth's Multiplication Algorithm
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 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 bit numbers as:
Both numbers 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 the multiplicand and the multiplier.
The result 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 .
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 multiplier . The Booth algorithm always looks at every pair of two bits (, ) in the multiplier starting from the right-most place, the LSB, and moving toward the left.
To start, we write out our binary number . Let us take as an example:
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 . Therefore, we must add an implicit bit before the LSB to act as our first .
We can now start encoding by looking at ever pair (, ) and defining an operation that will be performed on our multiplicand from earlier. The encoding table looks as follows:
Operation on | Comment | ||
---|---|---|---|
0 | 0 | 0a | Multiply by 0 |
0 | 1 | +a | Multiply by 1 |
1 | 0 | -a | Multiply by -1 |
1 | 1 | 0a | Multiply by 0 |
We do not have to understand yet how to apply these operations. Let us first take our example multiplier and re-encode it according to the table.
Encoding the multiplier
We start by looking at the first pair (, ):
This pair is () so it encodes to "" according to the table.
Next up is the pair (, ):
Here we have the pair () which encodes to "".
The pattern should be obvious by now. Here we have the last two encodings:
The pairs are () and () which map to "" and "" respectively.
Inserting the encoded operations
Our encoding of the multiplier has given us four operations that we will perform on the multiplicand . 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
Notice how our place values (the s) are in binary and accordingly aligned with our multiplicand . Also notice that below every place value, we have inserted the corresponding “operation” that we derived from encoding the multiplier .
For example, the first operation we encoded from the pair (, ) was (). We therefore put the corresponding operation "" into the first column from the right. The next pair (, ) was () and so we put into the second column from the right the operation "".
With all that set up, we are ready to calculate our partial products.
Performing the multiplication
We will now multiply the entire multiplicand with whatever operation is written in the column we are currently looking at. Fortunately, all our “multiplying” is actually just multiplying by , or . That means we must only insert zeros, insert or insert the two’s complement of respectively.
Let start calculating our first partial product :
Any number multiplied by is trivially as well. Thus, we have already calculated our first partial product: . Notice that we are now using twice the bits we did to display the result. This is because when multiplying bits, we can receive an output that requires bits.
Let us look at our next partial product :
Here we multiply by -1, which yields us . Multiplying any number by flips the sign of that number. In this case, we simply take the two’s complement of .
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 column for our row (notice the gray color).
We continue with :
Just like , the result is all zero.
Let us calculate the final partial product :
Here we simply multiplied by , yielding us again. However, notice that we also filled the column with a as well.
This is because our number 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 as their MSB, therefore we copy that value into all leading bits as well, meaning column is filled with too.
Adding the partial products
All that is left to do is to add together our partial products and arrive at the final result:
Our binary addition yields us . Booth’s algorithm has correctly produced a final product that is also in two’s complement form.
Note how two of our partial products (, ) 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 bits can present.
Multiplying with the most negative number
The most negative number is special because multiplying it by or yields the same result when we are confined to our original bits. Let us take as an example and apply the two’s complement to it, i.e. multiplying by :
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 by one leading bit. Just like we added leading bits to our partial product, we simply copy the MSB of and append it to the left of again:
From now on, we always use for every time we perform the Booth algorithm. Let us see this change in action.
We will calculate . Encoding will yield us the following operations, right to left: , , ,
Let us draw our multiplication table but this time insert .
Note how in column , the bit of is now an explicit , giving us more “space”. This causes the two’s complement produce the value of : the additional bit we added allows us to represent .
Let us now look at the final result:
As expected we get the correct answer .
Can you see that we would have gotten a wrong answer of if we had used the old instead of ?
Summary
We can summarize Booth’s algorithm as a five-step process:
- Add a as a trailing bit before the LSB of the multiplier
- Pairwise encode all bits of according to the encoding table
- Add a leading bit after the MSB of the multiplicand . This bit has the same value as the MSB of .
- Calculate the partial products. Multiply by the respective numbers that were derived from encoding in step 2.
- Add all partial products together.
It is also important to remember:
- The partial products should be bits long. When adding leading bits, remember that they take the same value as the MSB of the 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 multiplier 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 . We define each triplet of bits as (, , ).
With three bits, we now have eight encoding possibilities. The encoding table for radix-4 looks as follows:
Operation on | Comment | |||
---|---|---|---|---|
0 | 0 | 0 | 0a | Multiply by 0 |
0 | 0 | 1 | +a | Multiply by 1 |
0 | 1 | 0 | +a | Multiply by 1 |
0 | 1 | 1 | +2a | Multiply by 2 |
1 | 0 | 0 | -2a | Multiply by -2 |
1 | 0 | 1 | -a | Multiply by -1 |
1 | 1 | 0 | -a | Multiply by -1 |
1 | 1 | 1 | 0a | Multiply by 0 |
The important additions are "" and "". They demand that we multiply our multiplicand by by or 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 with and . Note that we have already added a leading bit to our number .
We start by encoding . Remember to append a trailing to it for the encoding process.
With the modified algorithm, we only encode two operations from our 4 bit multiplier: "" and "".
Let us draw the multiplication table.
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 column. The second operation is placed in the 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 column, a fourth into the column and so on.
Let us now calculate our partial products:
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 we simply shift our result one column to the left. These shifts are highlighted in red ().
Our final result is 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:
is the amount of bits the factors use. 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:
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: (,, , ).
The table has 16 different encodings:
Operation on | Comment | ||||
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0a | Multiply by 0 |
0 | 0 | 0 | 1 | +a | Multiply by 1 |
0 | 0 | 1 | 0 | +a | Multiply by 1 |
0 | 0 | 1 | 1 | +2a | Multiply by 2 |
0 | 1 | 0 | 0 | +2a | Multiply by 2 |
0 | 1 | 0 | 1 | +3a | Multiply by 3 |
0 | 1 | 1 | 0 | +3a | Multiply by 3 |
0 | 1 | 1 | 1 | +4a | Multiply by 4 |
1 | 0 | 0 | 0 | -4a | Multiply by -4 |
1 | 0 | 0 | 1 | -3a | Multiply by -3 |
1 | 0 | 1 | 0 | -3a | Multiply by -3 |
1 | 0 | 1 | 1 | -2a | Multiply by -2 |
1 | 1 | 0 | 0 | -2a | Multiply by -2 |
1 | 1 | 0 | 1 | -a | Multiply by -1 |
1 | 1 | 1 | 0 | -a | Multiply by -1 |
1 | 1 | 1 | 1 | 0a | Multiply by 0 |
Unfortunately this encoding has a huge problem: the odd multiples "" and "". Unlike powers of two (, ) which we can easily realize in binary by left-shifting, multiplying by 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
-
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. ↩