






















































































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. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 1
Jan. 2009^
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. 2008
Jan. 2009
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 4
Key elements of the single-cycle MicroMIPS data path.
/
Datacache
Next addr^ Instrcache
Regfile jta inst imm opfn rs^
(rs) (rt)
Dataaddr Datain (^01) ALUSrcALUFunc
DataReadDataWrite
SE
RegInSrc
rt rd RegDstRegWrite
(^32) / 16
Register input
Dataout
ALUOvfl Ovfl Func
(^01231)
Incr PC Next PC
(PC) Br&Jump
ALUout
PC
Registerwriteback^012
Instruction fetch
Reg access / decode
ALU operation
Data access
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 5
Computer Arithmetic as a Topic of Study
Graduate courseECE 252B – Text: Computer Arithmetic
Oxford U Press, 2000nd^ (2ed., late 2009) 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. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 7
9.1 Positional Number Systems
sticks or
unary^
code
radix-10 or
decimal
code
radix-2 or
binary
code
Roman numerals
Value of a number:
x^ = ( x
x... k –1 k –^
xx )=^10 r^
For example:27 = (11011)
= (1two^
Number of digits for [0,
P ]:^ k^
=^ ⎡log r^
⎤^ =^ ⎣log k –1^ i =0 P ⎦^ + 1 r^
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 8
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. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 10
9.2 Digit Sets and Encodings Conventional and unconventional digit sets • Decimal digits in [0, 9]; 4-bit BCD, 8-bit ASCII • Hexadecimal, or hex for short: digits 0-9 & a-f • Conventional ternary digit set in [0, 2]Conventional digit set for radix
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 11
= (1two^
Possible encodings (a) Binary
(b) Unary
01 (First alternate)
10 (Second alternate)
11 (Unused)
First bit
Second bit
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 13
9.3 Number Radix Conversion
-^ Perform arithmetic in the new radix
Suitable for conversion from radix
r^ to radix 10
Horner’s rule:^ ( xxk –
...^ k – xx )= (…((0 +^10 r^
x ) r^ + k –^
x ) r^ +... + k –
x ) r^ +^1 x^0
= 0 + 1two^
-^ Perform arithmetic in the old radix
Suitable for conversion from radix 10 to radix
Divide the number by
R , use the remainder as the LSD and the quotient to repeat the process 19 / 3^ →^
rem 1, quo 6 / 3
→^ rem 0, quo 2 / 3
→^ rem 2, quo 0
Thus, 19 = (2 0 1)
three
Two ways to convert numbers from an old radix
r^ to a new radix
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 14
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. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 16
Figure 9.
Schematic representation of 4-bit 2’s-complement code for integers in [–8, +7].
(^0000 )
0010
1110
0011
1101
0100
1100
1000
0101
1011
0110
1010
0111 1001
+0^ +
+2 +3 +4 +5 +6+ –1 –2 –3 –4 –5 –6–7–
_^
Turn^ x^ notchescounterclockwiseto add^ x^1 –1^2 –2^03 –3–4^4 –5^5 –6^6 –7^7 –8 Turn 16^ –^ y^ notchescounterclockwise toadd^ – y^ (subtract^ y )
With^ k^
bits, numbers in the range [–
k –1^ k –1, 2
Negation is performed by inverting all bits and adding 1.
Jan. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 17
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. 2009^
Computer Architecture, The Arithmetic/Logic Unit
Slide 19
9.5 Fixed-Point Numbers
Value of a number:
x^ = ( xk
x^.. .–1 k –^
xx.^ x^10 –
x...^ –^
i x r (^) i
For example:^ 2.375 = (
. 011)^ two
Numbers in the range [0,
k^ r –^ ulp ] representable, where
ulp^ =^ r
Fixed-point arithmetic same as integer arithmetic^ (radix point implied, not explicit) Two’s complement properties (including sign change) hold here as well: (01. 011)
2’s-compl^
2’s-compl^
Schematic representation of 4-bit 2’s-complement
- Jan. - Slide - Figure 9. Fixed-Point 2’s-Complement Numbers - 1.