CS M151B / EE M116C: Computer Systems Architecture
CS M151B / EE M116C: Computer Systems Architecture
misc
Binary Numbers
Binary
0000
0001
0010
0011
Decimal
4
5
6
7
Binary
0100
0101
0110
0111
3+3=6
Decimal
0
1
2
3
4
2 s Complement Binary
0000
0001
0010
0011
0100
3 + (- 5) = -2
+
Decimal
-1
-2
-3
-4
-5
2 s Complement Binary
1111
1110
1101
1100
1011
0101
-6
1010
6
7
0110
0111
-7
-8
1001
1000
Negation
Overflow Detection
7
3
-6
-4
-2
-6
-4
-5
Binary fractions:
10112 = 1x23 + 0x22 + 1x21 + 1x20
AND:
101.012 = 1x22 + 0x21 + 1x20 + 0x2-1 + 1x2-2
Example:
.75 = 3/4 = 1/2 + 1/4 = .112
exponent
decimal point
sign
+6.02 x 10
Mantissa
23
radix (base)
Issues:
Arithmetic (+, -, *, / )
Representation, Normal form
Range and Precision
Rounding
Exceptions (e.g., divide by zero, overflow, underflow)
Errors
Properties ( negation, inversion, if A = B then A - B = 0 )
Single precision
representation of
(-1)S 2E-127 (1.M)
sign
bit
23
exponent:
excess 127
binary integer
(actual exponent
is e = E - 127)
mantissa:
sign + magnitude, normalized
binary significand with hidden
integer bit: 1.M
0 = 0 00000000 00 . . . 0
-1.5 = 1 01111111 10 . . . 0
325 = 101000101 = 1.01000101 x 28
= 0 10000111 01000101000000000000000
.02 = .0011001101100... = 1.1001101100... x 2-3
= 0 01111100 1001101100...
sign
11
20
32
exponent:
excess 1023
binary integer
actual exponent is e = E - 1023
N = (-1)S 2 E-1023(1.M)
mantissa:
sign + magnitude, normalized
binary significand with hidden
integer bit: 1.M
Instruction
Fetch
ALU operation
Instruction
Decode
Operand
Fetch
a
ALU
Execute
Result
Store
Next
Instruction
b
CarryOut
Zero
Result
Overflow
Operation
Operation
Operation
CarryIn
CarryIn
CarryIn
CarryIn
a
AND gate
0
00
aa
OR gate
1
11
1-bit adder
b
2
22
bb
Operation
Result
Result
Result
Operation
CarryIn
Multiplexor
b
CarryOut
0
CarryOut
CarryOut
1
Result
CarryOut
Result
CarryIn
no CarryIn
Sum
b
Inputs
Outputs
Sum
Comments
0+0+0=00
0+0+1=01
0+1+0=01
0+1+1=10
1+0+0=01
1+0+1=10
1+0+1=10
1+1+1=11
CarryIn CarryOut
CarryOut
Outputs
Sum
Comments
0+0+0=00
0+0+1=01
0+1+0=01
0+1+1=10
1+0+0=01
1+0+1=10
1+0+1=10
1+1+1=11
CarryIn CarryOut
Inputs
Outputs
Sum
Comments
0+0+0=00
0+0+1=01
0+1+0=01
0+1+1=10
1+0+0=01
1+0+1=10
1+0+1=10
1+1+1=11
CarryIn CarryOut
32-bit ALU
Operation
b0
CarryIn
a
CarryIn
Operation
CarryIn
ALU0
Result0
CarryOut
a1
b1
CarryIn
ALU1
Result1
CarryOut
Result
a2
b2
CarryOut
1-bit ALU
ALU2
Result2
CarryOut
CarryIn
a31
b31
CarryIn
ALU31
Result31
32-bit ALU
Subtraction?
Operation
CarryIn
0
1
CarryOut
Result
Overflow
Operation
CarryIn
0
1
Result
XOR
CarryOut
Overflow
Zero Detection
Conditional Branches
One big NOR gate
Zero = (ResultN-1+ResultN-2+....
Result1+Result0)
Any non-zero result will cause zero detection
output to be zero
Set-On-Less-Than (SLT)
SLT Implementation
a.
CarryOut
Binvert
Binvert
Operation
CarryIn
Operation
CarryIn
1
Result
1
b
Result
b
2
Less
3
Set
Less
3
Overflow
detection
CarryOut
b.
Overflow
Binvert
CarryIn
a0
b0
CarryIn
ALU0
Less
CarryOut
a1
b1
0
CarryIn
ALU1
Less
CarryOut
a2
b2
0
CarryIn
ALU2
Less
CarryOut
SLT Implementation
Operation
Result0
Result1
Result2
CarryIn
a31
b31
0
CarryIn
ALU31
Less
Result31
Set
Overflow
Bnegate
Operation
a0
b0
CarryIn
ALU0
Less
CarryOut
Result0
a1
b1
0
CarryIn
ALU1
Less
CarryOut
Result1
a2
b2
0
CarryIn
ALU2
Less
CarryOut
Result2
a31
b31
0
CarryIn
ALU31
Less
Zero
Result31
Set
Overflow
CarryIn
b
CarryOut
Now:
Cin1 = g0 | (p0 & Cin0)
Cin2 = g1 | (p1 & g0) | (p1 & p0 & Cin0)
Cin3 = g2 | (p2 & g1) | (p2 & p1 & g0) | (p2 & p1 & p0 &
Cin0)
Hierarchical CLA
CarryIn
a0
b0
a1
b1
a2
b2
a3
b3
CarryIn
Result0--3
ALU0
P0
G0
pi
gi
Car ry-lookahead unit
C1
a4
b4
a5
b5
a6
b6
a7
b7
a8
b8
a9
b9
a10
b10
a11
b11
a12
b12
a13
b13
a14
b14
a15
b15
ci + 1
CarryIn
Result4--7
ALU1
P1
G1
pi + 1
gi + 1
C2
ci + 2
CarryIn
Result8--11
ALU2
P2
G2
pi + 2
gi + 2
C3
ci + 3
CarryIn
Result12--15
ALU3
P3
G3
pi + 3
gi + 3
C4
CarryOut
ci + 4
Multiplication
Quick example
Multiplicand
Multiplier
1000
x
1001
1000
0000
0000
1000
Product 1001000
Multiply Version 1
Start
Multiplier0 = 1
Multiplicand
1. Test
Multiplier0
Multiplier0 = 0
Shift left
64 bits
Multiplier
Shift right
64-bit ALU
32 bits
Product
Write
Control test
64 bits
32nd repetition?
Yes: 32 repetitions
Done
Multiply Version 2
Start
Multiplier0 = 1
Multiplicand
1. Test
Multiplier0
Multiplier0 = 0
32 bits
Multiplier
Shift right
32-bit ALU
32 bits
Product
64 bits
Shift right
Write
Control test
32nd repetition?
Yes: 32 repetitions
Done
Multiply Version 3
Start
Product0 = 1
1. Test
Product0
Product0 = 0
Multiplicand
32 bits
32-bit ALU
Product
Shift right
Write
Control
te s t
64 bits
32nd repetition?
Yes: 32 repetitions
Done
Key Points