Escolar Documentos
Profissional Documentos
Cultura Documentos
Computer Arithmetic
Part I: Integers
1
In this lecture:
Integer Representations
Integer Arithmetic
2
Chapter1 Review
3
Computer Arithmetic
4
Integer representation
5
Integer representation cntd
6
Integer Arithmetic
Addition (signed)
Q. Compute using 2s complement representation (use 4 bits)
i) 3+4
ii) -4+5
iii) 7+5
iv) (-4) +(-5)
Overflow will not occur if two numbers added have opposite signs.
If two numbers are added, and they are both positive or both negative,
then overflow occurs if and only if the result has the opposite sign.
Subtraction (signed)
A B = A+(-B) (find the negative equivalent of B then add with A)
7
Adder/Subtractor Unit
Register B Register A
Complementer
SW
8
Integer Multiplication
Unsigned integers
e.g. 1011 Multiplicand
We can store the partial
products and then add them
1101 Multiplier to find the product
But large number of registers
00001011 are required as no. of bits
000 0000 0 Partial products
increases (e.g. 32 registers
00 1011 00 for 32 bits)
Better approach is to add the
01011 000 partial products as we go
10001111 Product
9
Integer Multiplicationcntd
Important observations
Start
nth repetition NO
?
YES
Done 11
Method 1cntd
13
Method 2
A -> n-bits
C -> 1-bit
Multiplicand (M) -> n-bits
Multiplier (Q) -> n-bits
P=A:Q
14
Method 2cntd
e.g. 1011 X 1101
15
Method 2cntd
16
Method 2cntd
Exercise
Compute using method 2
i) 1000 X 1010
ii) 110 X 111
Faster multiplication
Calculate partial products in parallel
Need more components
17
Next Class
18
More Readings
19