5.8.Allthreeinstructionsarestoredinthecacheaftertherstpass,andtheyre-
maininplaceduringsubsequentpasses.Inthiscase,thereisatotalof6read
operationsfromthemainmemoryand6fromthecache.Executiontimeis66.
Instructionsanddataarebeststoredinseparatecachestoavoidthedataover-
writinginstructions,asinProblem5.7.
5.9.(a)4096blocksof128wordseachrequire12+7=19bitsforthemainmemory
address.
(b)TAGeldis8bits.SETeldis4bits.WORDeldis7bits.
5.10.(a)TAGeldis10bits.SETeldis4bits.WORDeldis6bits.
(b)Words0,1,2,,4351occupyblocks0to67inthemainmemory(MM).
Afterblocks0,1,2,,63havebeenreadfromMMintothecacheontherst
pass,thecacheisfull.Becauseofthefactthatthereplacementalgorithmis
LRU,MMblocksthatoccupytherstfoursetsofthe16cachesetsarealways
overwrittenbeforetheycanbeusedonasuccessivepass.Inparticular,MM
blocks0,16,32,48,and64continuallydisplaceeachotherincompetingfor
the4blockpositionsincacheset0.Thesamethingoccursincacheset1(MM
blocks,1,17,33,49,65),cacheset2(MMblocks2,18,34,50,66)andcache
set3(MMblocks3,19,35,51,67).MMblocksthatoccupythelast12sets
(sets4through15)arefetchedonceontherstpassandremaininthecachefor
thenext9passes.Ontherstpass,all68blocksoftheloopmustbefetched
fromtheMM.Oneachofthe9successivepasses,blocksinthelast12setsof
thecache(412=48)arefoundinthecache,andtheremaining20(6848)
blocksmustbefetchedfromtheMM.
Improvementfactor=
Timewithoutcache
Timewithcache
=
106810
16811+9(2011+481)
=2:15
5.11.Thisreplacementalgorithmisactuallybetteronthisparticularlargeloopex-
ample.Afterthecachehasbeenlledbythemainmemoryblocks0,1,,63
ontherstpass,block64replacesblock48inset0.Onthesecondpass,block
48replacesblock32inset0.Onthethirdpass,block32replacesblock16,and
onthefourthpass,block16replacesblock0.Onthefourthpass,therearetwo
replacements:0kicksout64,and64kicksout48.Onthesixth,seventh,and
eighthpasses,thereisonlyonereplacementinset0.Ontheninthpassthereare
tworeplacementsinset0,andonthenalpassthereisonereplacement.The
situationissimilarinsets1,2,and3.Again,thereisnocontentioninsets4
through15.Intotal,thereare11replacementsinset0inpasses2through10.
Thesameistrueinsets1,2,and3.Therefore,theimprovementfactoris
106810
16811+41111+(96844)1
=3:8
4