Computer arithmetic
-
Upload
buddhans-shrestha -
Category
Technology
-
view
485 -
download
0
Transcript of Computer arithmetic
![Page 1: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/1.jpg)
Computer Arithmetic
Prepared by: Buddha Shrestha Devendra Bhandari Diasy Dongol
![Page 2: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/2.jpg)
• Arithmetic means the operation with operand.
– Like
•ADDITION ( + )• SUBTRACTION ( - )•MULTIPLICATION ( * )•DIVIDE ( / )
![Page 3: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/3.jpg)
Eight Conditions for Signed-Magnitude Addition/Subtraction
OperationADD
Magnitudes
SUBTRACT Magnitudes
A > B A < B A = B
(+A) + (+B) + (A + B)
(+A) + (-B) + (A – B ) - (B – A ) + (A – B )
(-A) + (+B) - (A – B ) + (B – A ) + (A – B )
(-A) + (-B) - ( A + B)
(+A) - (+B) + (A – B ) - (B – A ) + (A – B )
(+A) - (-B) + (A + B)
(-A) - (+B) - ( A + B)
(-A) - (-B) - (A – B ) + (B – A ) + (A – B )
12345678
![Page 4: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/4.jpg)
Hardware for signed-magnitude addition and subtraction
A register
AVF
E
Bs
AS
B register
Complementer
Parallel AdderS
Load Sum
MMode Control
Input CarryOutput Carry
![Page 5: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/5.jpg)
![Page 6: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/6.jpg)
Add operation
≠ 0 =0
A>=B
As = BS
=0=1
Augend in A Added in B
END
As BS+
EA A + B
AVF E
EA A + B +1AVF 0
EA
As 0
A A
A A+1As As
As ≠ BS
=0 =1A<B
![Page 7: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/7.jpg)
• For Example of Addition
• (+1) + (+2)
(+A) + (+B)
![Page 8: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/8.jpg)
Add operation
≠ 0 =0
A>=B
As = BS
=0=1
Augend in A Added in B
END
As BS+
EA A + B
AVF E
EA A + B +1AVF 0
EA
As 0
A A
A A+1As As
As ≠ BS
=0 =1A<B
(+1) + (+2)
![Page 9: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/9.jpg)
• (-1) + (+2)
(-A) + (+B)
![Page 10: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/10.jpg)
Add operation
≠ 0 =0
A>=B
As = BS
=0=1
Augend in A Added in B
END
As BS+
EA A + B
AVF E
EA A + B +1AVF 0
EA
As 0
A A
A A+1As As
As ≠ BS
=0 =1A<B
(-1) + (+2)
![Page 11: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/11.jpg)
• For Example of Subtraction
• (+1) - (-2)(+A) - (-B)
![Page 12: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/12.jpg)
As ≠ BS
Subtract operation
≠ 0 =0
A>=B
As = BS
=0 =1
Miuend in A Subtrahend in B
END
As BS+
EA A + B
AVF E
EA A + B +1AVF 0
EA
As 0
A A
A A+1As As
=0 =1A<B
(+1) - (-2)
![Page 13: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/13.jpg)
• (+5) – (+2)
(+A) – (+B)
![Page 14: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/14.jpg)
As ≠ BS
Subtract operation
≠ 0 =0
A>=B
As = BS
=0 =1
Miuend in A Subtrahend in B
END
As BS+
EA A + B
AVF E
EA A + B +1AVF 0
EA
As 0
A A
A A+1As As
=0 =1A<B
(+5) – (+2)
![Page 15: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/15.jpg)
Figure: Hardware for signed-2’s complement addition and subtraction.
BR register
Complementer and parallel adder
AC register
V
Overflow
![Page 16: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/16.jpg)
Subtract
Figure: Algorithm for adding and subtracting numbers in signed-2’s complement representation.
Add
Augend in ACAddend in BR
AC AC + BR V overflow
END
Minuend in ACSubtrahend in BR
AC AC + BR + 1V overflow
END
![Page 17: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/17.jpg)
Figure: Hardware for multiply operation
Bs
B register Sequence counter (SC)
Complementer and parallel adder
A register Q register
As
E
Qs
(rightmost bit)Qn
0
![Page 18: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/18.jpg)
SC
Qn
Multiply operation
Multiplicand in BMultiplier in Q
As Qs Bs
Qs Qs Bs
A 0,E 0SC n-1
EA A + Bshr EAQSC SC-1
END(products is in AQ)
= 0
= 0 = 1
≠ 0
Figure: Flowchart for multiply operation.
![Page 19: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/19.jpg)
BOOTH MULTIPLICATION ALGORITHM
Introduction Hardware for Booth Algorithm Booth Algorithm for multiplication of signed 2’s
complement numbers
![Page 20: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/20.jpg)
INTRODUCTION
multiplication algorithm that multiplies two signed binary numbers in two's complement notation.
was invented by Andrew Donald Booth in 1950 used desk calculators that were faster at shifting
than adding and created the algorithm to increase their speed
is of interest in the study of computer architecture.
![Page 21: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/21.jpg)
Hardware for Booth Algorithm
Sign bits are not separated from the rest of the registers
rename registers A,B, and Q as AC,BR and QR respectively
Qn designates the least significant bit of the multiplier in register QR
Flip-flop Qn+1 is appended to QR to facilitate a double bit inspection of the multiplier
BR register Sequence COUNTER (SC)
Complementer and parallel adder
AC register QR register
Qn Qn+1
![Page 22: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/22.jpg)
Booth Algorithm for multiplication of signed 2’s
complement numbers
![Page 23: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/23.jpg)
= 10
=00=11
Multiplicand in BRMultiplier in QR
AC<-0Qn+1<-0
SC<-n
Qn Qn+1
AC<-AC+BR+1 AC<-AC+BR
ASHR(AC & QR)SC<-SC-1
SC END
Multiply
≠ 0 = 0
= 01
![Page 24: Computer arithmetic](https://reader035.fdocuments.net/reader035/viewer/2022062308/558a8c6bd8b42a095f8b463f/html5/thumbnails/24.jpg)
Thank You