【文档说明】课计算机组成原理课件第3章.ppt,共(62)页,738.578 KB,由小橙橙上传
转载请保留链接:https://www.ichengzhen.cn/view-77578.html
以下为本文档部分文字说明:
课计算机组成原理课件第3章MainContent•CharacteristicsofMemorySystem•TypesofMemory•TheMemoryHierarchy•CacheMemory•VirtualMemoryCharacteristicsofMemo
rySystemsLocationCPUInternalExternalCapacityWordByteInternalUsuallygovernedbydatabuswidthExternalUsuallyablockwhichismuchlargert
hanawordUnitofTransferAccessMethods(1)SequentialStartatthebeginningandreadthroughinorderAccesstim
edependsonlocationofdataandpreviouslocatione.g.tapeDirectIndividualblockshaveuniqueaddressAccessi
sbyjumpingtovicinityplussequentialsearchAccesstimedependsonlocationandpreviouslocatione.g.diskCharacteristicsofMemo
rySystemsRandomIndividualaddressesidentifylocationsexactlyAccesstimeisindependentoflocationorpreviou
saccesse.g.RAMAssociativeDataislocatedbyacomparisonwithcontentsofaportionofthestoreAccesstimeisindependentoflocationorpreviousaccesse.
g.cacheAccessMethods(2)CharacteristicsofMemorySystemsPerformanceAccesstimeTimebetweenpresentingtheaddressandgettingthevaliddata
MemoryCycletimeTimemayberequiredforthememoryto“recover”beforenextaccessCycletimeisaccess+recoveryTransferRateRa
teatwhichdatacanbemovedCharacteristicsofMemorySystemsPhysicalTypesSemiconductorRAMMagneticDisk&TapeOpticalCD&DVDOthers
HologramCharacteristicsofMemorySystemsTheBottomLineHowmuch?(Capacity)Greatercapacity,smallercostperbitGreat
ercapacity,sloweraccesstimeHowfast?(Accesstime)Fasteraccesstime,greatercostperbitHowexpensive?(Cost)M
emoryHierarchyRegistersInCPUInternalorMainmemoryMayincludeoneormorelevelsofcache“RAM”ExternalmemoryBackingstoreHierarchyListRegistersL1Cach
eL2CacheMainmemoryDiskOpticalTapeMemoryHierarchy-DiagramHierarchyListCacheSmallamountoffastmemorySitsbetweennormalmainmemoryand
CPUMaybelocatedonCPUchipormoduleContentaddressablememoryWhatmakescache“special”?Cacheisnotaccessedbyaddress;itisac
cessedbycontent.Forthisreason,cacheissometimescalledcontentaddressablememoryorCAM.TerminologyHit:Therequesteddatare
sidesinagivenlevelofmemory.Miss:Therequesteddataisnotfoundinthegivenlevelofmemory.HitRate:Thepercentageofmemor
yaccessesfoundinagivenlevelofmemory.MissRate:Thepercentageofmemoryaccessesnotfoundinagivenlevelofmemory.MissRate=1-HitR
ateHitTime:Thetimerequiredtoaccesstherequestedinformationinagivenlevelofmemory.MissPenalty:Thetimerequiredtop
rocessamiss,whichincludesreplacingablockinanupperlevelofmemory,plustheadditionaltimetodelivertherequest
eddatatotheprocessor.Cache/MainMemoryStructureCacheoperation–overviewCPUrequestscontentsofmemorylocationCheckcacheforthisdataIfpresent,ge
tfromcache(fast)Ifnotpresent,readrequiredblockfrommainmemorytocacheThendeliverfromcachetoCPUCacheincludestagstoidentifywhichblockofm
ainmemoryisineachcacheslotCacheReadOperation-FlowchartTypicalCacheOrganizationCacheDesignSizeMappingFunction
ReplacementAlgorithmWritePolicyBlockSizeNumberofCachesCacheSizeSmallenoughsooverallcost/bitisclosetotha
tofmainmemoryLargeenoughsooverallaverageaccesstimeisclosetothatofthecachealoneAccesstime=mainmemoryaccesstimepluscacheaccesstimeLar
gecachestendtobeslightlyslowerthansmallcachesItisimpossibletoarriveatasingle“optimum”cachesizeComparisonofCacheSi
zesProcessorTypeYearofIntroductionL1cacheaL2cacheL3cacheIBM360/85Mainframe196816to32KB——PDP-11/70Minicomputer19751KB——VAX11/780Minicomputer197
816KB——IBM3033Mainframe197864KB——IBM3090Mainframe1985128to256KB——Intel80486PC19898KB——PentiumPC19938KB/8KB256to512KB—PowerPC601PC
199332KB——PowerPC620PC199632KB/32KB——PowerPCG4PC/server199932KB/32KB256KBto1MB2MBIBMS/390G4Mainframe199732KB256KB2MBIBMS/390G6M
ainframe1999256KB8MB—Pentium4PC/server20008KB/8KB256KB—IBMSPHigh-endserver/supercomputer200064KB/32KB
8MB—CRAYMTAbSupercomputer20008KB2MB—ItaniumPC/server200116KB/16KB96KB4MBSGIOrigin2001High-endserver200132KB/32KB4MB—Itanium2PC/server200232KB256KB6M
BIBMPOWER5High-endserver200364KB1.9MB36MBCRAYXD-1Supercomputer200464KB/64KB1MB—MappingFunctionTheelementsincludedinth
efollowingexample:Cacheof64kByteCacheblockof4bytesi.e.cacheis16k(214)linesof4bytes16MBytesmainmemory24bitaddress(224=
16M)1.DirectMapping2.AssociativeMapping3.SetAssociativeMappingDirectMappingDirectMappingEachblockofmainmemorymapstoonlyonecac
helinei.e.ifablockisincache,itmustbeinonespecificplacei=jmodmWherei=cachelinenumberj=mainmemoryblocknumberm=numberof
linesinthecacheDirectMappingAddressisintwopartsLeastSignificantwbitsidentifyuniquewordMostSignifi
cantsbitsspecifyonememoryblockTheMSBsaresplitintoacachelinefieldrandatagofs-r(mostsignificant)Cachem=2rDirectMappingCacheLineTableCachelineM
ainMemoryblocksheld00,m,2m,3m…2s-m11,m+1,2m+1…2s-m+1m-1m-1,2m-1,3m-1…2s-1DirectMappingAddressStructureTags-rLineorSlotrWordw814224bitaddress
2bitwordidentifier(4byteblock)22bitblockidentifier8bittag(=22-14)14bitslotorlineNotwoblocksinthesameli
nehavethesameTagfieldCheckcontentsofcachebyfindinglineandcheckingTagDirectMappingCacheOrganizationD
irectMappingExampleDirectMappingSummaryAddresslength=(s+w)bitsNumberofaddressableunits=2s+wwordsorbytesBlocksize=linesize=2wwordsorbytesNumberofb
locksinmainmemory=2s+w/2w=2sNumberoflinesincache=m=2rSizeoftag=(s–r)bitsDirectMappingpros&consSimpleInexpensiv
eFixedlocationforgivenblockIfaprogramaccesses2blocksthatmaptothesamelinerepeatedly,cachemissesareveryhighAssociativ
eMappingAmainmemoryblockcanloadintoanylineofcacheMemoryaddressisinterpretedastagandwordTaguniquelyidentifiesblockof
memoryEveryline’stagisexaminedforamatchCachesearchinggetsexpensiveAssociativeMappingAssociativeMapping024631570246315781012141191315LineNumber
BlockTagCacheMemoryAssociativeCacheOrganizationAssociativeMappingExampleTag22bitWord2bitAssociativeMappingAd
dressStructure22bittagstoredwitheach32bitblockofdataComparetagfieldwithtagentryincachetocheckforhitLeastsignificant2bitsofaddressidentifywhi
ch16bitwordisrequiredfrom32bitdatablocke.g.AddressTagDataCachelineFFFFFCFFFFFC246824683FFFAssociativeMappingSummaryAddressleng
th=(s+w)bitsNumberofaddressableunits=2s+wwordsorbytesBlocksize=linesize=2wwordsorbytesNumberofblocksinm
ainmemory=2s+w/2w=2sNumberoflinesincache=undeterminedSizeoftag=sbitsSetAssociativeMappingCacheisdividedintoanumbe
rofsetsEachsetcontainsanumberoflinesAgivenblockmapstoanylineinagivensete.g.BlockBcanbeinanylineofsetie.g.2linesperset2way
associativemappingAgivenblockcanbeinoneof2linesinonlyonesetSetAssociativeMappingSetAssociativeMappingBlockLineNumberCacheMemory02463157Set0Se
t1Set2Set30246315781012141191315KWaySetAssociativeCacheOrganizationSetAssociativeMappingAddressStructureUsesetfieldtodeterminecaches
ettolookinComparetagfieldtoseeifwehaveahite.gAddressTagDataSetnumber1FF7FFC1FF123456781FFF0017FFC001112233441FFFTag9bitSet13bi
tWord2bitSetAssociativeMappingExample13bitsetnumber000000,008000,018000,FF8000…maptosamesetTwoWaySetAssociativeMappingExampleTw
oWaySetAssociativeMappingExampleSetAssociativeMappingSummaryAddresslength=(s+w)bitsNumberofaddressableunits=2s+wwor
dsorbytesBlocksize=linesize=2wwordsorbytesNumberofblocksinmainmemory=2s+w/2w=2sNumberoflinesinset=kNumberofsets=v=2dNumberoflinesincache=k×
v=k×2dSizeoftag=(s–d)bitsSetAssociativeMappingSummaryWhenv=m,k=1,thesetassociativemappingreducestodirectmapping.Whenv
=1,k=m,thesetassociativemappingreducestoassociativemapping.Theuseoftwolinesperset(v=m/2,k=2)isthecommonsetassociativemappingorganization.Replace
mentAlgorithms(1)DirectmappingNochoiceEachblockonlymapstoonelineReplacethatlineReplacementAlgorithms
(2)Associative&SetAssociativeHardwareimplementedalgorithm(speed)LeastRecentlyused(LRU)e.g.in2waysetassociativeWhicho
fthe2blockisLRU?Firstinfirstout(FIFO)replaceblockthathasbeenincachelongestLeastfrequentlyusedreplaceblockwh
ichhashadfewesthitsRandomWritePolicyMustnotoverwriteacacheblockunlessmainmemoryisuptodateMultipleCPUsmayhaveindividualcachesI/Omayaddressm
ainmemorydirectlyWritethroughAllwritesgotomainmemoryaswellascacheMultipleCPUscanmonitormainmemorytraffictokee
plocal(toCPU)cacheuptodateLotsoftrafficSlowsdownwritesWritebackUpdatesinitiallymadeincacheonlyUpdatebitforcacheslotissetwhenupdateocc
ursIfblockistobereplaced,writetomainmemoryonlyifupdatebitissetOthercachesgetoutofsyncI/OmustaccessmainmemorythroughcacheLineSize(块的大小)Astheblock
sizeincreasesfromverysmalltolargersizes,thehitratewillatfirstincreasebecausethedatainthevicinityofareferencedwordarelikelytoberef
erencedinthenearfuture.Thehitratewillbegintodecrease,astheblockbecomesevenbigger.64~128bytecachelinesizesaremostfrequentlyused.
NumberofCachesMultilevelCaches(L1/L2)On-chipCacheOff-chipCacheSplitCachesDataCacheInstructionCache
Pentium4Cache80386–noonchipcache80486–8kusing16bytelinesandfourwaysetassociativeorganizationPentium(allversions)–twoonchipL1caches
Data&instructionsPentiumIII–L3cacheaddedoffchipPentium4L1caches8kbytes64bytelinesfourwaysetassociativeL2cache256
k128bytelines8waysetassociativeL3cacheonchipIntelCacheEvolutionProblemSolutionProcessoronwhichfeaturefirstappears
Externalmemoryslowerthanthesystembus.Addexternalcacheusingfastermemorytechnology.386Increasedprocessorspeedresultsinexternalbusbecomingabottleneckfor
cacheaccess.Moveexternalcacheon-chip,operatingatthesamespeedastheprocessor.486Internalcacheisrathersmall,duetolimitedspaceonc
hipAddexternalL2cacheusingfastertechnologythanmainmemory486ContentionoccurswhenboththeInstructionPrefetcherandtheExecutionU
nitsimultaneouslyrequireaccesstothecache.Inthatcase,thePrefetcherisstalledwhiletheExecutionUnit’sdataaccesstakesplace.Createseparateda
taandinstructioncaches.PentiumIncreasedprocessorspeedresultsinexternalbusbecomingabottleneckforL2cacheaccess.Createseparateback-sidebusthatrunsathigh
erspeedthanthemain(front-side)externalbus.TheBSBisdedicatedtotheL2cache.PentiumProMoveL2cacheontotheprocessorchip
.PentiumIISomeapplicationsdealwithmassivedatabasesandmusthaverapidaccesstolargeamountsofdata.Theon-chipcachesaretoosmall.Add
externalL3cache.PentiumIIIMoveL3cacheon-chip.Pentium4PowerPCCacheOrganization601–single32kb8waysetassociat
ive603–16kb(2x8kb)twowaysetassociative604–32kb620–64kbG3&G464kbL1cache8waysetassociative256k,512kor1ML2cachetwowaysetassociativeG5
32kBinstructioncache64kBdatacacheVirtualMemoryThepurposeofvirtualmemoryistousetheharddiskasanextensio
nofRAM,thusincreasingtheavailableaddressspaceaprocesscanuse.Themostcommonwaytoimplementvirtualmemoryisusing
paging,amethodinwhichmainmemoryisdividedintofixed-sizeblocksandprogramsaredividedintothesamesizebloc
ks.VirtualMemoryEachprogramhasapagetableassociatedwithitthatmapseachprogrampagetoamemorypageframe.Thus,logical
addressesinaprogramareinterpretedasaphysicaladdress--pageframenumberandanoffsetwithinthepage.VirtualMemorySupposeaprogramis16byt
eslong,hasaccesstoan8-bytememorythatusesbytesaddressing,andapageis2bytesinlength.Astheprogramexecutes,itgeneratesthefollowingaddr
essesreferencestring:0,1,2,3,6,7,10,11.ReviewQuestions(思考题)CHAPTER01.Explainthepurposeofvirtualmemoryandcac
he.2.Explainhowassociativemappingcacheisdifferentfromdirectmappingcache.NextLessonCHAPTER0ControlUnit(控制单
元)ControlUnitOperationMicroprogrammedControl