## CS/ECE 552 Introduction to Computer Architecture

Spring 2012 Section 1
Instructor David A. Wood and T. A. Ramkumar Ravikumar
URL: http://www.cs.wisc.edu/~david/courses/cs552/S12/

## Notes on Booth's Algorithm

Several people had questions about Booth's algorithm and found the web page on Booth Recoding less than enlightening. Here are a few clarifying notes.

The table in the other web page is confusing because it goes straight to the two bit encoding. It is easier to think about the one bit encoding first, and then convert to two bits.

The key idea is to exploit the basic relationship that 2^i = 2^(i+1) - 2^i. We will use this relationship to recode a string of 1s into one 1 and one -1. In essence, Booth encoding comes down to detecting the beginning and end of strings of 1's. To figure out the correct recoding for bit i, you need to look at bit i-1 as well.

``` i   i-1   Recoded bit i
0    0       0
0    1       1  (bit i is to the left of a string of 1s)
1    0       -1 (bit i is the start of a string of 1s)
1    1       0  (bit i is part of a string of 1s)
```

So we can recode the following number: 0011110110 (and remember that for bit i=0, bit i-1 is implicitly 0).

``` 2SC  0  0  1  1  1  1  0  1  1  0
1-bit
Booth 0  1  0  0  0 -1  1  0 -1  0
2-bit
Booth    1     0    -1     2    -2
```

To get the two bit Booth, you look at each pair of bits. Remember that the leftmost bit has 2X the weight of the rightmost bit in each pair. So the pair (1 -1) means 2*1 + -1 = 1.

You might think that in the 2-bit recoding, you could have 3 and -3, but these would have to result from the pairs (1 1) and (-1 -1) arising in the 1-bit encoding. But neither of these pairs can happen because a -1 indicates the start of a string of ones (the rightmost end) and a 1 indicates the end of a string of ones. You can't have two adjacent starts or ends because at least one of the pair would have to be part of a longer string of ones.

You can also go directly to 2-bit Booth, as in the web page I sent out, but it is important to remember that you are recoding bits i+1 and i, and you are just looking at bit i-1 to decide whether i starts or ends a string of 1s.

```i+1   i   i-1   Recoded 1-bit pair      2-bit Booth
(i+1  i)
0    0    0       (0  0)                0
0    0    1       (0  1)                1
0    1    0       (1 -1)                1
0    1    1       (1  0)                2
1    0    0       (-1 0)               -2
1    0    1       (-1 1)               -1
1    1    0       (0 -1)               -1
1    1    1       (0  0)                0
```

So going back to the string 0011110110, you look at bits 1, 0, and (the non-existent) -1 which have values (1 0 0). Looking in the table, this says the least significant 2-bit Booth digit is -2, which is the same as we got above. For the next digit, you look at bits 3, 2, and 1, which gives the triple (0 1 1), which from the table is 2, also the same digit we got using the other method.

Computer Sciences | UW Home
 Page last modified: Tuesday, 22-Nov-2011 16:51:10 CST Feedback or content questions: send email to david [at] cs.wisc.edu Technical or accessibility issues: lab@cs.wisc.edu Copyright © 2002, 2003 The Board of Regents of the University of Wisconsin System.