ANDMICROPROCESSORS
Computer Organization, Computer Arithmetic
(Lecture - 6)
Dr.Sudip Roy
CourseWebsite:http://faculty.iitr.ac.in/~sudiproy.fcs/csn221_2015.html
PiazzaSite:https://piazza.com/iitr.ac.in/fall2015/csn221
ComputerArchitectureinLevelsofTransformation:
Ausercentricview:computer
designedforusers
Theentirestackshouldbe
optimizedforuser
Dr.SudipRoy
ATypicalMemoryHierarchyinaComputer:
Before2002:
After2002:
Dr.SudipRoy
ATypicalMemoryHierarchyinaComputer:
DuetosizeofDRAM
Duetocostandwiredelays(wiresonchipcostmuchless,andarefaster)
KeytoyourArchitecturalDesign:
Dr.SudipRoy
SingleCoreComputer:
Dr.SudipRoy
SingleCoreCPUChip:
Dr.SudipRoy
MultiCoreCPUChip:
Dr.SudipRoy
Dr.SudipRoy
NumberRepresentationinaComputer:
Hardwarecanonlydealwithbinarydigits,0and1
Mustrepresentallnumbers,integersorfloatingpoint,positiveornegative,
bybinarydigits,calledbits
Deviseelectroniccircuitstoperformarithmeticoperations:add,subtract,
multiplyanddivide,onbinarynumbers
IntegerRepresentation:
Positivenumbersstoredinbinary,e.g.,5710=1110012
Nominussign
Noperiod
SignMagnitude
Twoscomplement
Dr.SudipRoy
SignMagnitude:
Leftmostbitissignbit
0meanspositive
1meansnegative
+18=00010010
18=10010010
Problems:
Needtoconsiderbothsignandmagnitudeinarithmetic
Tworepresentationsofzero(+0and0)
Dr.SudipRoy
10
2sComplement:
+3=00000011
+2=00000010
+1=00000001
+0=00000000
1=11111111
2=11111110
3=11111101
Benefits:
OnlyonerepresentationforZero
Arithmeticworkseasily
Negatingisfairlyeasy:Add1to1scomplementrepresentation
3=00000011
Booleancomplementgives 11111100
Add1toLSB
11111101(3)
Dr.SudipRoy
11
GeometricDepictionof2sComplementIntegers:
Exactlyasmanypositivenumbersasnegativenumbers
Slightasymmetry thereisonenegativenumberwithnopositivecounterpart
Overflowrule: Iftwonumberswiththesamesignbit(both+ve orbothve)are
added,theoverflowoccursifandonlyiftheresulthastheoppositesign
Dr.SudipRoy
12
MIPS(MicroprocessorwithoutInterlockedPipelineStages):
MIPSarchitectureuses32bitnumbers.Whatistherangeofintegers
(positiveandnegative)thatcanberepresented?
Positiveintegers:0to2,147,483,647
Whatarethebinaryrepresentationsoftheextremepositiveandnegative
integers?
01111111111111111111111111111111 =231 1=2,147,483,647
10000000000000000000000000000000 = 231
= 2,147,483,648
Whatisthebinaryrepresentationofzero?
Dr.SudipRoy
00000000000000000000000000000000
13
ThreeRepresentations:
Sign-magnitude 1s complement
2s complement
000 = +0
001 = +1
010 = +2
011 = +3
100 = - 0
101 = - 1
110 = - 2
111 = - 3
000 = +0
001 = +1
010 = +2
011 = +3
100 = - 4
101 = - 3
110 = - 2
111 = - 1
000 = +0
001 = +1
010 = +2
011 = +3
100 = - 3
101 = - 2
110 = - 1
111 = - 0
(Preferred)
Dr.SudipRoy
14
BinaryAddition:
Addingbits:
0+0=0
0+1=1
1+0=1
1+1=(1)0
carry
Addingintegers:
1
0 0 0...... 0
0 0 0...... 0
1
1
1
0
1
1
12=
02=
710
610
15
BinarySubtraction:
Directsubtraction
0 0 0......0
0 0 0......0
1
1
1
1
12=
02=
710
610
= 0 0 0...... 0
12 =
110
Taketwoscomplimentofsubstahend andaddtominuend
i.e.,a b=a+(b)
So,weonlyneedadditionandcomplementcircuits
2scomplementsubtraction
1 1 1......1
0 0 0......0
1 1 1......1
1
1
0
0
1
1
1 2 = 710
0 2 = - 610
110
16
DesignHardwareBitbyBit:
Addingtwobits:
a
0
0
1
1
b
0
1
0
1
half_sum
0
1
1
0
carry_out
0
0
0
1
Halfaddercircuit:
Dr.SudipRoy
a
b
XOR
half_sum
AND
carry_out
17
ReviewofBooleanGates:
Dr.SudipRoy
18
ReviewofBooleanGates:
Dr.SudipRoy
19
OnebitFullAdder:
Onebitfulladdertruthtable
a
0
0
0
0
1
1
1
1
Dr.SudipRoy
b
0
0
1
1
0
0
1
1
ci
0
1
0
1
0
1
0
1
half_sum
0
0
1
1
1
1
0
0
carry_out
0
0
0
0
0
0
1
1
sum
0
1
1
0
1
0
0
1
co
0
0
0
1
0
1
1
1
20
OnebitFullAdderCircuit:
ci
ai
bi
Dr.SudipRoy
FAi
XOR
AND
sumi
XOR
AND
OR
Ci+1
21
32bitRippleCarryAdder:
c0
a0
b0
sum0
FA0
a1
b1
sum1
FA1
a2
b2
sum2
FA2
sum31
a31
b31
FA31
Longestdelaypath(criticalpath)runsfromCin tosum31
Supposedelayoffulladderis100ps
Criticalpathdelay=3,200ps
Clockratecannotbehigherthan1/(3,2001012)Hz=312MHz
Dr.SudipRoy
22
SpeedingUptheAdder:
b0-b15
cin
a16-a31
b16-b31
0
a16-a31
b16-b31
1
Dr.SudipRoy
16-bit
ripple
carry
adder
16-bit
ripple
carry
adder
16-bit
ripple
carry
adder
sum0-sum15
Multiplexer
a0-a15
sum16-sum31
FastAdders:
Ingeneral,anyoutputofa32bitaddercanbeevaluatedasalogic
expressionintermsofall65inputs
Numberoflevelsoflogiccanbereducedtolog2NforNbitadder.Ripple
carryhasNlevels
Moregatesareneeded,aboutlog2Ntimesthatofripplecarrydesign
Fastestdesignisknownascarrylookahead adder
Dr.SudipRoy
24
NbitAdderDesignOptions:
Type of adder
Time complexity
(delay)
Space complexity
(size)
Ripple-carry
O(N)
O(N)
Carry-lookahead
O(log2N)
O(N log2N)
Carry-skip
O(N)
O(N)
Carry-select
O(N)
O(N)
Dr.SudipRoy
25