Professional Documents
Culture Documents
Memory - IV: CS220: Introduction To Computer Organization 2011-12 Ist Semester
Memory - IV: CS220: Introduction To Computer Organization 2011-12 Ist Semester
Memory - IV: CS220: Introduction To Computer Organization 2011-12 Ist Semester
Memory - IV
Amey Karkare karkare@cse.iitk.ac.in
Department of CSE, IIT Kanpur
Replacement policy
Rules for creating space for a new block in cache. LRU, FIFO, LFU, random . . .
Associativity
Number of possible tags where a physical block may be found Fully associative, k-way associative
Write Policy
Write through, Write back
CS220, Memory
1/12
CS220, Memory
2/12
Direct Mapping
Main Memory
16-bit address. 4K blocks of 16 bytes each. Total 64K bytes.
Cache
128 blocks of 16 bytes each. Total 2048 (2K) bytes.
CS220, Memory
3/12
CS220, Memory
4/12
CS220, Memory
5/12
CS220, Memory
6/12
A combination of direct- and fully associative- mapping Blocks in cache are grouped into sets.
k-way associative: Each set contains k blocks. k = 1 direct mapping. k = # of cache blocks fully associative.
16-bit memory address divided in three parts. Example: 2-way set associative.
Total 128/2 = 64 sets. Total 64 blocks mapped per set. Tag Set # 6 6
Offset 4
Lower 4 bits of address are the offset within the block (24 = 16). Middle 6 bits of address specify the set (26 = 64). Upper 6 bits of address are compared with tag (26 = 64).
CS220, Memory
7/12
CS220, Memory
8/12
Replacement Policies
CS220, Memory
9/12
CS220, Memory
10/12
Other Issues
What do we do if the cache block is not in sync with memory? Cache block is more current. Need to store this information. Dirty (D) bit per block.
Set when a write occurs in the block. Reset when a new block is brought it. If dirty bit is set, write the block in memory before reading another block.
In case of FIFO, replacement candidate is selected with highest counter value. In case of LRU, replacement candidate is chosen using ref bits with most zeros at the end. For k = 2, we need just one bit of history/reference information per block. For k = 1 (direct mapping) we need no extra information.
karkare, CSE, IITK CS220, Memory 11/12 karkare, CSE, IITK
CS220, Memory
12/12