



















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















































































Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 1
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 2
About This Presentation
This presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers
Oxford University Press, 2005, ISBN 0-19-515455-X. It is updatedregularly by the author as part of his teaching of the upper-divisioncourse ECE 154, Introduction to Computer Architecture, at theUniversity of California, Santa Barbara. Instructors can use theseslides freely in classroom teaching and for other educationalpurposes. Any other use is strictly prohibited. © Behrooz Parhami^ Edition
Released
Revised
Revised
Revised
Revised
First^
July 2003
July 2004
July 2005
Mar. 2006
Jan. 2007
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 4
Computer Arithmetic as a Topic of Study
Graduate courseECE 252B – Text: Computer Arithmetic
Oxford U Press, 2000 Brief overview article – Encyclopedia of Info Systems
Academic Press, 2002,Vol. 3, pp. 317-
Our textbook’s treatmentof the topic falls betweenthe two extremes (4 chap.)
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 5
9 Number Representation
Positional Number Systems 9.2 Digit Sets and Encodings 9.3 Number-Radix Conversion 9.4 Signed Integers 9.5 Fixed-Point Numbers 9.6 Floating-Point Numbers
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 7
Figure 9.
Schematic representation of 4-bit code for integers in [0, 15].
0000
0001 1111
0010
1110
0011
1101
0100
1100
1000
0101
1011
0110
1010
0111 1001
0 1
(^234567) (^151411) (^1312)
98 Inside: Natural numberOutside: 4-bit encoding^10
Turn^ x^ notchescounterclockwiseto add^ x^1 15203456978 Turn^ y^ notchesclockwiseto subtract^ y (^1413121110)
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 8
Figure 9.
Overflow regions in finite number representation systems. For unsigned representations covered in this section,
-^ max
max
Finite set of representable numbers
max Overflow region
Overflow region
Numbers largerthan^ max
Numbers smallerthan^
max
−^
−^
Example 9.2, Part d
Discuss if overflow will occur when computing 3
in a number
system with
k^ = 8 digits in radix
r^ = 10.
Solution The result 86 093 442 is representable in the number system which has a range [0, 99 999 999]; however, if 3
17 is computed en route to
the final result, overflow will occur.
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 10
= (1two^
Possible encodings (a) Binary
(b) Unary
01 (First alternate)
10 (Second alternate)
11 (Unused)
First bit
Second bit
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 11
Twocarry-saveinputs
Carry-saveinputBinary inputCarry-saveoutput
This bitbeing 1representsoverflow(ignore it)
0
0 0
a. Carry-save addition.
Carry-saveaddition b. Adding two carry-save numbers.
Carry-saveaddition
Digit-set combination: {0, 1, 2} + {0, 1} = {0, 1, 2, 3} = {0, 2} + {0, 1}
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 13
Justifying one step of the conversion of
x^ to radix 2.
x^^0 x mod 2
Binary representation of
⎣ x /2⎦ Justifying Horner’s rule.
1
2
1 2 0
1
2
1
0
(^
)^
k^
k
k^ k^
r^
k^
k
x^ x
x^
x^ r^
x^ r
x r^
x
−^
−
−^ −^
−^
−
=^
+^
+^ +
L^
L
0
1
2 (^
(^
(^ )))
x^ r x
r x
r
=^
+^
+^
+^ L
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 14
9.4 Signed Integers
-^ We dealt with representing the natural numbers •^ Signed or directed whole numbers = integers^ {... ,
-^ Signed-magnitude representation^ +27 in 8-bit signed-magnitude binary code
–27 in 8-bit signed-magnitude binary code
− N ,^ P ] by the unsigned
interval [0,
P^ +^ N ]; i.e., by adding
N^ to every number
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 16
Example 9.
Convert
x^ = (1 0 1 1 0 1 0 1)
2’s-compl^
to decimal.
Solution Given that x is negative, one could change its sign and evaluate –
x.
Shortcut: Use Horner’s rule, but take the MSB as negative–^
→^ –75 Example 9.
Given^ y
, find the representation of –2’s-compl
y.
Solution^ – y^ = (0 1 0 0 1 0 1 0) + 1 = (0 1 0 0 1 0 1 1)
2’s-compl^
(i.e., 75)
Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 17
Figure 9.
k / k /
k /
k /
Schematic representation of 4-bit 2’s-complement
- Jan. - Slide - Figure 9. Fixed-Point 2’s-Complement Numbers - 1. Jan. 2007^
Computer Architecture, The Arithmetic/Logic Unit
Slide 20
-^ Perform arithmetic in the new radix
Evaluate a polynomial in
–1 r : (. 011)
= 0^ two^
Simpler: View the fractional part as integer, convert, divide by
l r
(. 011)^ two
= (?)^ ten Multiply by 8 to make the number an integer: (011)
= (3)two^
ten
Thus, (
. 011)^ two
= (. ten 375)ten
-^ Perform arithmetic in the old radix
Multiply the given fraction by
R , use the whole part as the MSD
and the fractional part to repeat the process(. 72)^ = (?)ten^
two 0.72^ ×^
2 = 1.44, so the answer begins with 0. 0.44^ ×^
2 = 0.88, so the answer begins with 0. Convert the whole and fractional parts separately.To convert the fractional part from an old radix
r^ to a new radix