Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
26 views10 pages

Booths Multe Du

Uploaded by

ishaanksheth2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views10 pages

Booths Multe Du

Uploaded by

ishaanksheth2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/262177138

An effective educational module for Booth's multiplication algorithm

Article · April 2012

CITATIONS READS
3 632

3 authors, including:

Chris Jenkins David Furcy


University of Iowa University of Wisconsin - Oshkosh
14 PUBLICATIONS 12 CITATIONS 39 PUBLICATIONS 1,339 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Chris Jenkins on 04 May 2020.

The user has requested enhancement of the downloaded file.


AN EFFECTIVE EDUCATIONAL MODULE FOR BOOTH'S

MULTIPLICATION ALGORITHM*

Christopher M. Jenkins, Computer Science Department, Trinity University, San


Antonio, TX 78212, [email protected]

Adam D. Voss, Computer Science Department, Luther College, Decorah, IA 52101,


[email protected]

David Furcy, Computer Science Department, University of Wisconsin Oshkosh,


Oshkosh, WI 54901, [email protected]

ABSTRACT
We have developed a free online module for the self-study of Booth's
multiplication algorithm. This module includes an algorithm visualization tool
that displays both the pseudo-code and the contents of hardware registers
during execution. This tool accepts user-generated inputs, randomly generates
questions to foster active learning and comes with a user guide and a
standalone hyper-textbook chapter that explains the algorithm, justifies it
mathematically and includes exercises that are integrated with our
visualization tool. Student grades and feedback suggest that this module is an
effective platform for self-study.

1 INTRODUCTION
Since "[a] professional in any field of computing should not regard the computer as
just a black box that executes programs by magic[, a]ll students of computing should
acquire some understanding and appreciation of a computer system's functional
components" [1]. Therefore, virtually all computer science curricula include at least one
course on computer architecture, covering a wide range of topics from data representation
to multiprocessing. Given the increasing importance of recent architectural trends, such
as multiprocessing and distributed architectures, instructors end up having to make tough
decisions about topic coverage. To make room for these high-level architectural trends,

___________________________________________
*
Copyright © 2012 by the Consortium for Computing Sciences in Colleges. Permission to copy
without fee all or part of this material is granted provided that the copies are not made or
distributed for direct commercial advantage, the CCSC copyright notice and the title of the
publication and its date appear, and notice is given that copying is by permission of the
Consortium for Computing Sciences in Colleges. To copy otherwise, or to republish, requires a
fee and/or specific permission.

54
CCSC: South Central Conference

there is a tendency to drop topics close to the hardware-software interface, especially at


the logic design level [1]. In this paper, we consider one such lower-level topic within the
first core area in the latest ACM/IEEE computer science curriculum recommendation,
namely "signed and unsigned arithmetic" [1]. Given the wide variety of data
representation schemes, algorithms and hardware implementations, some important ideas
in this area are being covered less and less frequently. In this paper, we focus on one such
topic, namely signed integer multiplication, for which Andrew Booth presented a seminal
solution [3]. While his algorithm is still being covered in some modern textbooks (e.g.,
[10]), it is not even mentioned in others ([e.g., [11]). Another classic textbook by
Patterson and Hennessy [9] best illustrates the recent fading of this topic. Their second
edition devotes five full pages to it (pages 259-263) in the main body of the text. Their
third edition devotes the same number of pages but moves them out of the main text and
onto the accompanying CD. Their fourth edition does not cover this algorithm at all: in
fact, the full-text search engine provided with the book yielded "no results found" over
the entire text and CD contents when fed the single keyword "Booth."
Given the decreasing availability of textbook materials and class time for such
low-level but nevertheless important topics, our goal is to provide support for instructors
who would still like their students to gain familiarity with Booth's algorithm. Therefore,
we have designed a self-contained educational module that includes an online textbook
or hyper-textbook chapter and an engaging visualization tool. Our hypothesis is that our
free, online learning module will enable students to study and master this topic with little
or no class time devoted to it, and no textbook reference. In this paper, we describe this
module and our preliminary test of this hypothesis. In the next section, we describe
related work. Then we describe our hyper-textbook and visualization tool in the next two
sections, respectively. We then report some preliminary results on the pedagogical
effectiveness of our module. We conclude this paper with a discussion of future work.

2 RELATED WORK
Booth's multiplication algorithm is still covered or at least mentioned in several
textbooks [e.g., 5,8,10]. The most common approach to teaching Booth's algorithm uses
pseudo-code or a flowchart as well as one or more traces of it on canned inputs. Some
presentations justify mathematically why the algorithm works for both positive and
negative numbers. Some include a description of "Booth recoding," which is a way to
rewrite the multiplier to reformulate the multiplication as a sequence of additions and
subtractions. While a discussion of Booth recoding is not strictly necessary to explain the
algorithm, our module not only discusses it, but also includes pseudo-code and a
mathematical justification for the algorithm's correctness and performance characteristics.
The next two sections provide more details on the algorithm.
The main shortcoming of standard textbooks is their static nature. Since they only
contain canned contents, they do not naturally support hands-on, interactive learning.
Once the student has read the pseudo-code and included example(s), textbooks do not
have any affordances for additional practice or active self-study. In contrast, our module
enables students to trace through an arbitrarily large number of examples with
randomized or user-selected input values and register sizes. The tracing of the algorithm
is step-by-step, interactive, with the possibility to move both forward and backward
through the trace. Randomized stop-and-think questions pop up to promote active

55
JCSC 27, 4 (April 2012)

learning. The use of algorithm visualization also aims to foster learning in visual thinkers.
The only other publicly available visualization of Booth's algorithm we found is a
JavaScript simulator that, like our module, allows the learner to pick the two numbers to
multiply, in either binary or decimal format [5]. However, this simulator is not interactive
after the data entry stage. In fact, it produces the whole trace in one shot (no animation).
Unlike our module, this simulator does not include pop-up questions or exercises. On the
other hand, the web site associated with the textbook (see [5]) includes simulations for
other arithmetic algorithms, which our module does not yet.
The Algorithm Visualization Portal [2] does not include any visualization of Booth's
algorithm. However, our literature search yielded two relevant papers. Garzón et al.
describe an approach to teaching computer architecture that includes "carefully designed
practical exercises […] supported by an auxiliary computer-based environment" [4],
which, to the best of our knowledge, are not publicly available. Finally, Thiebaut
describes an architecture course in which students must build animations of algorithms,
including Booth's [12]. His practice is the opposite of ours since class time is devoted to
GUI programming and teaching the API to Trolltech's Qt GUI software toolkit before
getting to the architecture topics proper. While the activity of building (as opposed to
using) algorithm visualizations promotes a higher level of student engagement [7], the
class time devoted to non-architectural topics makes it, in our opinion, less viable, given
the recent trends described earlier.

3 HYPER-TEXTBOOK FOR BOOTH'S MULTIPLICATION ALGORITHM


The hyper-textbook chapter in our pedagogical module contains nine sections. The
first section describes the prerequisite knowledge that is expected of the reader, namely
mastery of the two's complement representation of signed integers and the basic operation
of addition. The rest of the chapter is a motivated and progressive unveiling of Booth's
algorithm that builds on students' existing knowledge. The second section explains why
multiplying two numbers p and q via q additions of p is not an acceptable hardware
implementation approach since its runtime is unpredictable. The third section considers
an alternative approach to multiplication, namely the shift-and-add or paper-and-pencil
approach, and introduces important terminology, such as multiplicand, multiplier, partial
product, etc. The fourth section describes two improvements to this algorithm that are
motivated by hardware constraints: the use of a running total of the partial products, since
hardware typically handles the addition of only two numbers, and the switch to a
sign-preserving or arithmetic right shift, which more efficiently lines up the two numbers
to be added and sets aside one more bit of the final result as soon as it has acquired its
correct value. The fifth section illustrates with an example why this algorithm does not
handle negative numbers correctly. The sixth section explains Booth's recoding of the
multiplier in terms of additions and subtractions and why this transformation corrects the
mishandling of negative multipliers. At this point, students have been given a complete
justification for the specification of Booth's algorithm, whose pseudo-code is shown on
the right side of Figure 2 below. The seventh section brings the description of the
algorithm down to the level of hardware registers. The eighth section contains a hyperlink
to our visualization tool. The ninth and final section is comprised of three types of
exercises. In some exercises, our visualization tool randomly generates numbers to
multiply and asks students to fill in initial, intermediate or final register values, which

56
CCSC: South Central Conference

they can only do by tracing the algorithm. In contrast, the last kind of exercises ask
students to input two numbers whose multiplication will exhibit the worst run time of
Booth's algorithm. These exercises target a deeper level of understanding, beyond the
tracing of the algorithm. Indeed, students are responsible for inferring that replacing a
series of additions corresponding to a series of consecutive ones in the multiplier only
speeds up the algorithm when the series of ones is long enough. What is common to all
exercises is that the size of the registers is randomly generated, as are all of the initial
numbers provided to students. More importantly, the exercises are fully integrated with
our visualization tool: after students have entered their numerical answers, our
visualization tool traces the algorithm based on them and identifies any errors students
may have made at the time when these errors come up in the trace.

4 VISUALIZATION TOOL FOR BOOTH'S MULTIPLICATION ALGORITHM


Since our visualization tool uses the JHAVE platform, we start by highlighting the
architectural and user interface features of JHAVE that are relevant to this project.

4.1 The JHAVE Educational Platform


The Java-Hosted Algorithm Visualization Environment (JHAVE [6]) supports a
variety of algorithm visualization (AV) engines by providing them with:
• a common drawing context called the "main pane,''
• a standard set of DVR-like controls that allow students to step through a series a
snapshots, one for each step in the algorithm being visualized in the main pane,
• two side panes where dynamically-generated HTML pages display accompanying
text, such as pseudo-code and explanations of the visualization,
• input generators that gather student-generated input data needed by the algorithm,

• stop-and-think questions that pop up randomly during the visualization to foster


active learning, and
• a database that keeps a record of all student answers for automatic assessment
purposes.
JHAVE has a script-based, client-server architecture. In a typical session, the
student web-starts the client program and selects an algorithm to visualize. If input is
required, the server sends back an input generator. Once the student has entered the input
data, the server runs the algorithm and generates a script, that is, a description of
snapshots that portray the behavior of the algorithm. The AV engine (client) then
retrieves this script and visualizes it in the main pane, moving forward and backward
through the snapshots as the student clicks on the DVR-like controls, asking questions
at random times and recording the student's answers. Therefore, the JHAVE platform
supports a high level of interactivity. Besides zooming and panning, students can navigate
through the visualization both forward and backward to help them identify as quickly as
possible at what step of the algorithm their mental model breaks down.

57
JCSC 27, 4 (April 2012)

4.2 User Interface


Our module includes a detailed user guide to our visualization that we summarize
in this section. First, students point their favorite web browser to http://jhave.org and web
start the JHAVE client (a Java application that will run on any platform) with a single
click. In the client's window, students enter the name "booth" in the category field to
select one among dozens of algorithms available. After clicking "Connect" (to the server)
and "Visualize" (the algorithm), students are presented with an input generator (see
Figure 1) with four text fields that enable them to pick the values of two numbers they
want to multiply, and one drop-down menu to select the size of the registers in bits.

Figure 1: Input generator window

To make this tool as user-friendly as possible, the input generator automatically


converts each input number from decimal to two's complement binary and vice-versa.
Similarly, the default value for the register size is computed automatically but can be
overridden with the drop-down menu. Finally, an error message is displayed if one of the
numbers overflows the selected register size. After students have completed the input
stage, they click the "OK" button to bring up our main visualization window. After going
through the first few steps of the algorithm, the window will look like Figure 2, with the
pseudo-code and graphical depictions of the algorithm in the right and left panes,
respectively. Each pseudo-code line is numbered and highlighted in sync with the
graphical depiction. The top corners of the left pane always display the multiplication
being visualized in both decimal (left corner) and binary (right corner) formats, with a
textual description of the current step between these two multiplications. The trace of the
algorithm appears below this top line, with the first row of boxes depicting the
initialization steps on pseudo-code lines 2 through 6, as shown in Figure 2. Every row
under this initialization row depicts the execution of one iteration of the main loop on
lines 10 through 21. Figure 3 depicts the final contents of all registers with the result of
the multiplication in registers A and Q. Lack of space prevents us from including
intermediate snapshots in which the Math/ALU column contains a detailed depiction of
the subtraction or addition that is performed on lines 11 or 14, respectively. Finally, our
visualization tool randomly generates contextually appropriate questions that pop up to
engage the learner in active learning instead of passive viewing. Our visualization
leverages all four types of questions supported by JHAVE, namely true/false, multiple
choice, short answer (see Figure 4) and multiple selection (see Figure 5) questions.

58
CCSC: South Central Conference

Figure 2: Algorithm visualization during execution

Figure 3: Algorithm visualization after termination

59
JCSC 27, 4 (April 2012)

Figure 4: Pop-up question Figure 5: Another pop-up question

5 PEDAGOGICAL EFFECTIVENESS: PRELIMINARY RESULTS


In the Fall 2011 semester, the third author used our module in a junior/senior-level
course on computer organization that is a follow-up to a sophomore-level course on
computer architecture and assembly language. After a lecture and a ten-minute quiz on
the pencil-and-paper (P) algorithm for multiplication, students were given one week to
peruse our module on their own (no lecture), after which they took two consecutive
10-minute quizzes. The first quiz (B1) required students to trace the Booth algorithm on
a randomly generated pair of numbers and a fixed register size. The second quiz (B2),

P B1 B2
Minimum score / #students 6/1 6/3 6/3
Maximum score / 10 / 4 10 / 8 10 / 6
#students
Average score 8.44 8.50 8.39
(Standard deviation) (1.21) (1.54) (1.64)
Table 1: Quiz results

taken right after B1, first asked students to compare the run time performance of both the
paper-and-pencil and Booth's algorithms in terms of the number of primitive operations
executed when run on three different input pairs. Then, the second half of quiz B2 asked
students to produce the only input numbers that would exhibit the best and worst
performances by Booth's algorithm. Table 1 reports the minimum, maximum and average
scores for all three quizzes (sample size of 18) out of a maximum possible score of 10.
The first observation is that the average quiz scores are rather close, even though quiz P
was taken after a lecture on the topic, while the preparation for quizzes B1 and B2 was
through self-study exclusively. However, both the variance and number of students who
received the minimum and maximum scores are larger for both quizzes on Booth's
algorithm. We conjecture that self-study, in this case, accentuated individual differences
in motivation, perseverance and time on task. We also observe that more students earned
a maximum score on B1 and B2 than on quiz P. This is surprising to us, since quiz B2
assessed a much deeper understanding of the algorithm, namely prediction of overall
performance without tracing, compared to quizzes P and B1, both of which required
mechanical tracing of the execution. We believe that a significant number of our students

60
CCSC: South Central Conference

mastered the algorithm on their own. In a 13-question survey administered anonymously


after quiz B2, students reported a wide range of study times (from no time at all to 3
hours) and frequency of use of our visualization tool (from 0 to 12 times or up to 30
minutes). When asked how helpful they found our tool, students gave an average score
of 4.35 on a scale from 1 (useless) to 5 (indispensable). Finally, 6 out of 18 students
reported having used the Wikipedia entry for Booth's algorithm during their self-study,
which, as retrieved on 11/2/2011, does not discuss the performance aspects assessed in
quiz B2.

6 FUTURE WORK AND CONCLUSION


Following up on the feature requests obtained through our survey, we are working
on improving the level of detail in the feedback given to students when they give a wrong
answer to a pop-up question. In addition, we plan to conduct a thorough empirical study
to characterize and improve the pedagogical efficacy of our module. Finally, we would
like our module to cover a variety of additional arithmetic algorithms (e.g., division) that
are well within the scope of our visualization tool and hyper-textbook.

7 REFERENCES
1. ACM/IEEE Interim Review Task Force, Computer Science Curriculum 2008: An
Interim Revision of CS 2001,
http://www.acm.org/education/curricula-recommendations, 2008
2. The algorithm visualization portal, http://algoviz.org/.
3. Booth, A., A signed binary multiplication technique, The Quarterly Journal of
Mechanics and Applied Mathematics, IV, (2), 236-240, 1951.
4. Garzón, E., García, I., Fernández, J., An approach to teaching computer
arithmetic, International Meeting on High Performance Computing for
Computational Science, 2002.
5. Koren, I, Computer Arithmetic Algorithms, 2nd Edition, A. K. Peters, 2002.
6. Naps, T., Rößling, G., JHAVE -- More visualizers (and visualizations) needed,
Electronic Notes in Theoretical Computer Science (ENTCS), 178, 33-41, 2007.
7. Naps, G., Rößling, G., Almstrum, V., Dann, W., Fleischer, R., Hundhausen, C.,
Korhonen, A., Malmi, L., McNally, M., Rodger, S., Velázquez-Iturbide, J.,
Exploring the role of visualization and engagement in computer science
education, ACM SIGCSE Bulletin, 35, (2), 2003.
8. Null, L., Lobur, J., The Essentials of Computer Organization and Architecture,
3rd Edition, Jones & Bartlett Learning, 2012.
9. Patterson, D., Hennessy, J., Computer Organization and Design, 2nd 3rd and 4th
Editions, Morgan Kaufmann, 1998, 2005, and 2009.
10. Stallings, W., Computer Organization and Architecture, 8th Edition, Prentice
Hall, 2010.

61
JCSC 27, 4 (April 2012)

11. Tanenbaum, A, Structured Computer Organization, 5th Edition, Prentice Hall,


2006.
12. Thiebaut, D., On startups and teaching computer architecture, Journal of
Computing Sciences in Colleges, 22, (6), 28-36, 2007.

8 ACKNOWLEDGEMENTS
This research was funded by an NSF REU grant (award #0851569).

62

View publication stats

You might also like