SlideShare a Scribd company logo
1 of 22
ECE/CS 552:
Integer Multipliers
© Prof. Mikko Lipasti
Lecture notes based in part on slides created by Mark
Hill, David Wood, Guri Sohi, John Shen and Jim Smith
Basic Arithmetic and the ALU
2
• Earlier in the semester
• Number representations, 2’s complement,
unsigned
• Addition/Subtraction
• Add/Sub ALU
• Full adder, ripple carry, subtraction
• Carry-lookahead addition
• Logical operations
• and, or, xor, nor, shifts
• Overflow
Basic Arithmetic and the ALU
• Now
– Integer multiplication
• Booth’s algorithm
• This is not crucial for the project
3
Multiplication
• Flashback to 3rd grade
– Multiplier
– Multiplicand
– Partial products
– Final sum
• Base 10: 8 x 9 = 72
– PP: 8 + 0 + 0 + 64 = 72
• How wide is the result?
– log(n x m) = log(n) + log(m)
– 32b x 32b = 64b result
4
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Array Multiplier
• Adding all partial products
simultaneously using an
array of basic cells
5
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Full Adder
Sin Cin Ai Bj
Cout Sout
Ai ,Bj
16-bit Array Multiplier
6
Conceptually straightforward
Fairly expensive hardware, integer multiplies relatively rare
Most used in array address calc: replace with shifts
[Source: J. Hayes,
Univ. of Michigan]
Instead: Multicycle Multipliers
• Combinational multipliers
– Very hardware-intensive
– Integer multiply relatively rare
– Not the right place to spend resources
• Multicycle multipliers
– Iterate through bits of multiplier
– Conditionally add shifted multiplicand
7
Multiplier
8
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Multiplier
9
Done
1. Test
Multiplier0
1a. Add multiplicand to product and
place the result in Product register
2. Shift the Multiplicand register left 1 bit
3. Shift the Multiplier register right 1 bit
32nd repetition?
Start
Multiplier0 = 0
Multiplier0 = 1
No: < 32 repetitions
Yes: 32 repetitions
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Multiplier Improvements
• Do we really need a 64-bit adder?
– No, since low-order bits are not involved
– Hence, just use a 32-bit adder
• Shift product register right on every step
• Do we really need a separate multiplier
register?
– No, since low-order bits of 64-bit product are
initially unused
– Hence, just store multiplier there initially
10
Multiplier
11
Control
test
Write
32 bits
64 bits
Shift right
Product
Multiplicand
32-bit ALU
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Multiplier
12
Done
1. Test
Product0
1a. Add multiplicand to the left half of
the product and place the result in
the left half of the Product register
2. Shift the Product register right 1 bit
32nd repetition?
Start
Product0 = 0
Product0 = 1
No: < 32 repetitions
Yes: 32 repetitions
1 0 0 0
x 1 0 0 1
1 0 0 0
0 0 0 0
0 0 0 0
1 0 0 0
1 0 0 1 0 0 0
Signed Multiplication
• Recall
– For p = a x b, if a<0 or b<0, then p < 0
– If a<0 and b<0, then p > 0
– Hence sign(p) = sign(a) xor sign(b)
• Hence
– Convert multiplier, multiplicand to positive number
with (n-1) bits
– Multiply positive numbers
– Compute sign, convert product accordingly
• Or,
– Perform sign-extension on shifts for prev. design
– Right answer falls out
13
Booth’s Encoding
• Recall grade school trick
– When multiplying by 9:
• Multiply by 10 (easy, just shift digits left)
• Subtract once
– E.g.
• 123454 x 9 = 123454 x (10 – 1) = 1234540 – 123454
• Converts addition of six partial products to one shift and one
subtraction
• Booth’s algorithm applies same principle
– Except no ‘9’ in binary, just ‘1’ and ‘0’
– So, it’s actually easier!
14
Booth’s Encoding
• Search for a run of ‘1’ bits in the multiplier
– E.g. ‘0110’ has a run of 2 ‘1’ bits in the middle
– Multiplying by ‘0110’ (6 in decimal) is equivalent to
multiplying by 8 and subtracting twice, since 6 x m = (8 – 2)
x m = 8m – 2m
• Hence, iterate right to left and:
– Subtract multiplicand from product at first ‘1’
– Add multiplicand to product after last ‘1’
– Don’t do either for ‘1’ bits in the middle
15
Booth’s Algorithm
16
Current
bit
Bit to
right
Explanation Example Operation
1 0 Begins run of ‘1’ 00001111000 Subtract
1 1 Middle of run of ‘1’ 00001111000 Nothing
0 1 End of a run of ‘1’ 00001111000 Add
0 0 Middle of a run of ‘0’ 00001111000 Nothing
Booth’s Encoding
• Really just a new way to encode numbers
– Normally positionally weighted as 2n
– With Booth, each position has a sign bit
– Can be extended to multiple bits
17
0 1 1 0 Binary
+1 0 -1 0 1-bit Booth
+2 -2 2-bit Booth
2-bits/cycle Booth Multiplier
• For every pair of multiplier bits
– If Booth’s encoding is ‘-2’
• Shift multiplicand left by 1, then subtract
– If Booth’s encoding is ‘-1’
• Subtract
– If Booth’s encoding is ‘0’
• Do nothing
– If Booth’s encoding is ‘1’
• Add
– If Booth’s encoding is ‘2’
• Shift multiplicand left by 1, then add
18
2 bits/cycle Booth’s
19
Current Previous Operation Explanation
00 0 +0;shift 2 [00] => +0, [00] => +0; 2x(+0)+(+0)=+0
00 1 +M; shift 2 [00] => +0, [01] => +M; 2x(+0)+(+M)=+M
01 0 +M; shift 2 [01] => +M, [10] => -M; 2x(+M)+(-M)=+M
01 1 +2M; shift 2 [01] => +M, [11] => +0; 2x(+M)+(+0)=+2M
10 0 -2M; shift 2 [10] => -M, [00] => +0; 2x(-M)+(+0)=-2M
10 1 -M; shift 2 [10] => -M, [01] => +M; 2x(-M)+(+M)=-M
11 0 -M; shift 2 [11] => +0, [10] => -M; 2x(+0)+(-M)=-M
11 1 +0; shift 2 [11] => +0, [11] => +0; 2x(+0)+(+0)=+0
1 bit Booth
00 +0
01 +M;
10 -M;
11 +0
Booth’s Example
• Negative multiplicand:
-6 x 6 = -36
1010 x 0110, 0110 in Booth’s encoding is +0-0
Hence:
20
1111 1010 x 0 0000 0000
1111 0100 x –1 0000 1100
1110 1000 x 0 0000 0000
1101 0000 x +1 1101 0000
Final Sum: 1101 1100 (-36)
Booth’s Example
• Negative multiplier:
-6 x -2 = 12
1010 x 1110, 1110 in Booth’s encoding is 00-0
Hence:
21
1111 1010 x 0 0000 0000
1111 0100 x –1 0000 1100
1110 1000 x 0 0000 0000
1101 0000 x 0 0000 0000
Final Sum: 0000 1100 (12)
Summary
• Integer multiply
– Combinational
– Multicycle
– Booth’s algorithm
22

More Related Content

Similar to ECE/CS 552: Integer Multipliers Lecture Notes

Similar to ECE/CS 552: Integer Multipliers Lecture Notes (20)

09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 
09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 
09 arithmetic 2
09 arithmetic 209 arithmetic 2
09 arithmetic 2
 
CA UNIT II.pptx
CA UNIT II.pptxCA UNIT II.pptx
CA UNIT II.pptx
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
CA Unit ii
CA Unit iiCA Unit ii
CA Unit ii
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth Multiplier
 
Boolean operators
Boolean operatorsBoolean operators
Boolean operators
 
Alu1
Alu1Alu1
Alu1
 
Booth Multiplication.pptx
Booth Multiplication.pptxBooth Multiplication.pptx
Booth Multiplication.pptx
 
ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS	  ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS
 
Encoding Schemes for Multipliers
Encoding Schemes for MultipliersEncoding Schemes for Multipliers
Encoding Schemes for Multipliers
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Decppt
DecpptDecppt
Decppt
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpu
 
data representation
 data representation data representation
data representation
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 

More from ansariparveen06

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxansariparveen06
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptansariparveen06
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptansariparveen06
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxansariparveen06
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxansariparveen06
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxansariparveen06
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.pptansariparveen06
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxansariparveen06
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptxansariparveen06
 

More from ansariparveen06 (20)

discrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptxdiscrete mathematics binary%20trees.pptx
discrete mathematics binary%20trees.pptx
 
Introduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).pptIntroduction to Arduino 16822775 (2).ppt
Introduction to Arduino 16822775 (2).ppt
 
Fundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.pptFundamentals of programming Arduino-Wk2.ppt
Fundamentals of programming Arduino-Wk2.ppt
 
pscheduling.ppt
pscheduling.pptpscheduling.ppt
pscheduling.ppt
 
kmap.pptx
kmap.pptxkmap.pptx
kmap.pptx
 
Combinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptxCombinational_Logic_Circuit.pptx
Combinational_Logic_Circuit.pptx
 
presentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptxpresentation_python_7_1569170870_375360.pptx
presentation_python_7_1569170870_375360.pptx
 
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptxBCom-Sem2-Marketing-Digital-payment-Presentation.pptx
BCom-Sem2-Marketing-Digital-payment-Presentation.pptx
 
dsa.ppt
dsa.pptdsa.ppt
dsa.ppt
 
11-IOManagement.ppt
11-IOManagement.ppt11-IOManagement.ppt
11-IOManagement.ppt
 
May14ProcessScheduling.ppt
May14ProcessScheduling.pptMay14ProcessScheduling.ppt
May14ProcessScheduling.ppt
 
UNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptxUNIPROCESS SCHEDULING.pptx
UNIPROCESS SCHEDULING.pptx
 
1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx1-introduction-to-dart-programming.pptx
1-introduction-to-dart-programming.pptx
 
CHAP4.pptx
CHAP4.pptxCHAP4.pptx
CHAP4.pptx
 
green IT cooling.pptx
green IT cooling.pptxgreen IT cooling.pptx
green IT cooling.pptx
 
06-Deadlocks.ppt
06-Deadlocks.ppt06-Deadlocks.ppt
06-Deadlocks.ppt
 
chp9 green IT.pptx
chp9 green IT.pptxchp9 green IT.pptx
chp9 green IT.pptx
 
regex.ppt
regex.pptregex.ppt
regex.ppt
 
BOM.ppt
BOM.pptBOM.ppt
BOM.ppt
 
Cooling.pptx
Cooling.pptxCooling.pptx
Cooling.pptx
 

Recently uploaded

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Association for Project Management
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1GloryAnnCastre1
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 

Recently uploaded (20)

Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
Team Lead Succeed – Helping you and your team achieve high-performance teamwo...
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1Reading and Writing Skills 11 quarter 4 melc 1
Reading and Writing Skills 11 quarter 4 melc 1
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 

ECE/CS 552: Integer Multipliers Lecture Notes

  • 1. ECE/CS 552: Integer Multipliers © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim Smith
  • 2. Basic Arithmetic and the ALU 2 • Earlier in the semester • Number representations, 2’s complement, unsigned • Addition/Subtraction • Add/Sub ALU • Full adder, ripple carry, subtraction • Carry-lookahead addition • Logical operations • and, or, xor, nor, shifts • Overflow
  • 3. Basic Arithmetic and the ALU • Now – Integer multiplication • Booth’s algorithm • This is not crucial for the project 3
  • 4. Multiplication • Flashback to 3rd grade – Multiplier – Multiplicand – Partial products – Final sum • Base 10: 8 x 9 = 72 – PP: 8 + 0 + 0 + 64 = 72 • How wide is the result? – log(n x m) = log(n) + log(m) – 32b x 32b = 64b result 4 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
  • 5. Array Multiplier • Adding all partial products simultaneously using an array of basic cells 5 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 Full Adder Sin Cin Ai Bj Cout Sout Ai ,Bj
  • 6. 16-bit Array Multiplier 6 Conceptually straightforward Fairly expensive hardware, integer multiplies relatively rare Most used in array address calc: replace with shifts [Source: J. Hayes, Univ. of Michigan]
  • 7. Instead: Multicycle Multipliers • Combinational multipliers – Very hardware-intensive – Integer multiply relatively rare – Not the right place to spend resources • Multicycle multipliers – Iterate through bits of multiplier – Conditionally add shifted multiplicand 7
  • 8. Multiplier 8 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
  • 9. Multiplier 9 Done 1. Test Multiplier0 1a. Add multiplicand to product and place the result in Product register 2. Shift the Multiplicand register left 1 bit 3. Shift the Multiplier register right 1 bit 32nd repetition? Start Multiplier0 = 0 Multiplier0 = 1 No: < 32 repetitions Yes: 32 repetitions 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
  • 10. Multiplier Improvements • Do we really need a 64-bit adder? – No, since low-order bits are not involved – Hence, just use a 32-bit adder • Shift product register right on every step • Do we really need a separate multiplier register? – No, since low-order bits of 64-bit product are initially unused – Hence, just store multiplier there initially 10
  • 11. Multiplier 11 Control test Write 32 bits 64 bits Shift right Product Multiplicand 32-bit ALU 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
  • 12. Multiplier 12 Done 1. Test Product0 1a. Add multiplicand to the left half of the product and place the result in the left half of the Product register 2. Shift the Product register right 1 bit 32nd repetition? Start Product0 = 0 Product0 = 1 No: < 32 repetitions Yes: 32 repetitions 1 0 0 0 x 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0
  • 13. Signed Multiplication • Recall – For p = a x b, if a<0 or b<0, then p < 0 – If a<0 and b<0, then p > 0 – Hence sign(p) = sign(a) xor sign(b) • Hence – Convert multiplier, multiplicand to positive number with (n-1) bits – Multiply positive numbers – Compute sign, convert product accordingly • Or, – Perform sign-extension on shifts for prev. design – Right answer falls out 13
  • 14. Booth’s Encoding • Recall grade school trick – When multiplying by 9: • Multiply by 10 (easy, just shift digits left) • Subtract once – E.g. • 123454 x 9 = 123454 x (10 – 1) = 1234540 – 123454 • Converts addition of six partial products to one shift and one subtraction • Booth’s algorithm applies same principle – Except no ‘9’ in binary, just ‘1’ and ‘0’ – So, it’s actually easier! 14
  • 15. Booth’s Encoding • Search for a run of ‘1’ bits in the multiplier – E.g. ‘0110’ has a run of 2 ‘1’ bits in the middle – Multiplying by ‘0110’ (6 in decimal) is equivalent to multiplying by 8 and subtracting twice, since 6 x m = (8 – 2) x m = 8m – 2m • Hence, iterate right to left and: – Subtract multiplicand from product at first ‘1’ – Add multiplicand to product after last ‘1’ – Don’t do either for ‘1’ bits in the middle 15
  • 16. Booth’s Algorithm 16 Current bit Bit to right Explanation Example Operation 1 0 Begins run of ‘1’ 00001111000 Subtract 1 1 Middle of run of ‘1’ 00001111000 Nothing 0 1 End of a run of ‘1’ 00001111000 Add 0 0 Middle of a run of ‘0’ 00001111000 Nothing
  • 17. Booth’s Encoding • Really just a new way to encode numbers – Normally positionally weighted as 2n – With Booth, each position has a sign bit – Can be extended to multiple bits 17 0 1 1 0 Binary +1 0 -1 0 1-bit Booth +2 -2 2-bit Booth
  • 18. 2-bits/cycle Booth Multiplier • For every pair of multiplier bits – If Booth’s encoding is ‘-2’ • Shift multiplicand left by 1, then subtract – If Booth’s encoding is ‘-1’ • Subtract – If Booth’s encoding is ‘0’ • Do nothing – If Booth’s encoding is ‘1’ • Add – If Booth’s encoding is ‘2’ • Shift multiplicand left by 1, then add 18
  • 19. 2 bits/cycle Booth’s 19 Current Previous Operation Explanation 00 0 +0;shift 2 [00] => +0, [00] => +0; 2x(+0)+(+0)=+0 00 1 +M; shift 2 [00] => +0, [01] => +M; 2x(+0)+(+M)=+M 01 0 +M; shift 2 [01] => +M, [10] => -M; 2x(+M)+(-M)=+M 01 1 +2M; shift 2 [01] => +M, [11] => +0; 2x(+M)+(+0)=+2M 10 0 -2M; shift 2 [10] => -M, [00] => +0; 2x(-M)+(+0)=-2M 10 1 -M; shift 2 [10] => -M, [01] => +M; 2x(-M)+(+M)=-M 11 0 -M; shift 2 [11] => +0, [10] => -M; 2x(+0)+(-M)=-M 11 1 +0; shift 2 [11] => +0, [11] => +0; 2x(+0)+(+0)=+0 1 bit Booth 00 +0 01 +M; 10 -M; 11 +0
  • 20. Booth’s Example • Negative multiplicand: -6 x 6 = -36 1010 x 0110, 0110 in Booth’s encoding is +0-0 Hence: 20 1111 1010 x 0 0000 0000 1111 0100 x –1 0000 1100 1110 1000 x 0 0000 0000 1101 0000 x +1 1101 0000 Final Sum: 1101 1100 (-36)
  • 21. Booth’s Example • Negative multiplier: -6 x -2 = 12 1010 x 1110, 1110 in Booth’s encoding is 00-0 Hence: 21 1111 1010 x 0 0000 0000 1111 0100 x –1 0000 1100 1110 1000 x 0 0000 0000 1101 0000 x 0 0000 0000 Final Sum: 0000 1100 (12)
  • 22. Summary • Integer multiply – Combinational – Multicycle – Booth’s algorithm 22