Memory mapping

3,077 views 9 slides Aug 03, 2021
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

These slides explains the memory mapping concepts and direct mapping techniques.


Slide Content

Memory Mapping
Ms. Snehalata Agasti
Department CSE

Cache
•Cache memory is present in between main memory and processor.
•Smaller insizeand faster.
•Two typesofcache memory is used.
•Cache memory is updatedusingeitherwrite-Backorwrite-Through
policies.
processor
Cache
memory
Main
memory

Mapping
•Mappingis a technique which maps CPU generated address into
cache lines.
•Main memoryispartitionedintonumberofblocks.
•Cache mapping helps to bring the content of main memory into cache
memory.
Cache memory
Main memory

Some important points
•Number of cache block=size of cache memory / size of each block
•Size ofcache memory = Number of cache block x size of each block
•If mainmemorysizeisgivenMthennumberofbitsrequiredto
representthe address lines = log
2
M
•If block size is given B then number ofbitsrequired torepresentblock
offset= log
2
B
•If number of cache blocks =C then number of bits required to
represent cache offset= log
2
C

Types of mapping
•Three different types of mapping technique.
-Direct mapping
-Associative mapping
-Set associativemapping
•Indirectmapping,eachblockofmainmemoryismappedtosingle
cachelines.Asmainmemorysizeislargeandcachememorysizeis
small,toasinglecachelinenumberofmainmemoryblockis
mapped.Soalongwithcompulsorymiss,conflictmissoccurred.

Direct mapping
•Main memory block is mapped to cache memory block using the
technique
•cachememoryblocknumber=
Main memoryblocknumber%number ofblockincache
•mainmemoryaddressisdivided into3parts
✓Tag
✓cacheoffset
✓Word offset
Tag Cache offset Word offset

Explanation of Cache lines mapping
•Let number of cache blocks =4
•Total numberofmainmemoryblock=8
•Then to each cache line 2-number of blocks will be mapped
•In direct mapping , we are using the formula L= Jmod M, where
L=Cache lines J= Main memory block number and M= number of
blocks in cache.
0,4
1,5
2,6
3,7
0
1
3
2
0
1
2
3
4
5
6
7
•Mainmemoryaddress0,4ismappedtocache
line0,as0%4=0and4%4=0.
•Blocknumber1and5ismappedtocacheline-1.
•similarly3and6blocksaremappedtocacheline-
2andblocknumber3and7ismappedtocache
line-3.
•Initiallycacheblocksarefree.Socompulsorymiss
occurredandconflictmissoccurreddueto
multiplemainmemoryblocksaremappedinto

Direct Mapping Problem
•Let Block size is given 16B, size of cache is given 64KB, and number of bits
that represent memory address in main memory is 32-bits then find
number of bits required for tag, Block offset, word offset.
•Solution:
Block size =16 =2
4
Number ofbitsrequiredforblockoffset= log
2
16
= log
22
4
=4*1=4
Size of cache memory=64KB=2
6
x 2
10
B = 2
16
B
Number of cache lines = size of cache/block size = 64KB/ 16=4KB
No ofbitsrequiredforcacheoffset= log
2
4K
= log
22
12
= 12*1 = 12
Number of bits given for main memory addressing :32bits
Tag= 32 -12-4= 16 bits
Tag=16 Cache offset=12Block offset=4
32