Concerning Caches

Cache Simulation

Suppose our cache has only eight blocks and each block contains four words. The cache is 2-way set associative, so there are four sets of two blocks. The write policy is write-back and write-allocate. LRU replacement is used. Assume memory is initialized to zero.

Initial cache status:

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 0             0            
1 0             0            
2 0             0            
3 0             0            

Cache status after storing the value 5 at address 0. Compulsory miss, block is fetched from memory, dirty bit is set.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 0 5 0 0 0 0            
1 0             0            
2 0             0            
3 0             0            

Cache status after loading the value at address 64. Compulsory miss, block is fetched from memory, dirty bit is not set.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 0 5 0 0 0 1 0 1 0 0 0 0
1 0             0            
2 0             0            
3 0             0            

Cache status after storing the value 7 at address 4. Hit.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 0 5 7 0 0 1 0 1 0 0 0 0
1 0             0            
2 0             0            
3 0             0            

Cache status after storing the value 8 at address 40. Compulsory miss.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 0 5 7 0 0 1 0 1 0 0 0 0
1 0             0            
2 1 1 0 0 8 0 0 0            
3 0             0            

Cache status after loading the value at address 68. Hit.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 0 5 7 0 0 1 0 1 0 0 0 0
1 0             0            
2 1 1 0 0 8 0 0 0            
3 0             0            

Cache status after storing the value 9 at address 128. Conflict miss, leftmost block in set is evicted because it is the least recently used. It is written back because it is dirty.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 2 10 0 0 0 1 0 1 0 0 0 0
1 0             0            
2 1 1 0 0 8 0 0 0            
3 0             0            

Cache status after loading the value at address 0. Conflict miss, rightmost block in set is evicted because it is the least recently used. It is not written back because it is not dirty.

  Valid Dirty Tag Data   Valid Dirty Tag Data
Set
Index
0 1 1 2 10 0 0 0 1 0 0 5 7 0 0
1 0             0            
2 1 1 0 0 8 0 0 0            
3 0             0            


CSE 378 Spring 2002 - Section 9
First Previous Page 3 Next Last