I think I got it totally wrong. First of all, I want to clarify what a block means in the context of a cache. Blocks are atomic units of trasfer between main memory and cache. So, when a block contains four words, this means that at a time, a chunk of four words is transfered from the memory to the cache. For example, if the memory address 1 was referenced and was not in the cache, then the entire block of addresses 0 through 3 would be trasferred, making [0,1,2,3] be the block that is moved into the cache.Here is a series of memory references given as word addresses
1,4 ,8,5,20,17,19,56,9,11,4,43,5,6,9,17.Assuming a direct mapped cache with four word blocks and a total size of 16 words,that are initially empty,label each reference as a hit/miss and show the final contents of the cache
Nkruti, thanks a lot for the question, as it does clarify some things. Now, I'm going to try to give it another shot:
First of all, the cache has 4 blocks, each with 4 words. Since we'll be transfering blocks in and out, first we should figure out which block a memory address would go to. With direct addressing, the one that makes most sense, is like this: Suppose the k-bit memory address in binary is: a_k a_{k-1} .... a_4 a_3 a_2 a_1. Then the block in cache in which this address is mapped to is {a_4 a_3}.
To run through miss / hit, its like this:
1: Miss. Words 0 - 3 transfered to Cache in Block 0.
4: Miss. Words 4 - 7 transfered to Cache in Block 1.
8: Miss. Words 8 - 11 transfered to Cache in Block 2.
5: Hit. Word 5 already in Cache Block 1.
20: Miss. Words 20 - 23 transfered to Cache in Block 1.
17: Miss. Words 16 - 19 transfered to Cache in Block 0.
19: Hit. Word 19 present in Cache Block 0.
56: Miss. Words 56 - 59 transfered to Cache in Block 2.
9: Miss. Words 8 - 11 transfered to Cache in Block 2.
11: Hit
4: Miss. Words 4 - 7 transfered to Cache in Block 1.
43: Miss. Words 40 - 43 transered to Cache in Block 2.
5: Hit.
6: Hit.
9: Miss. Words 8 - 11 transfered to Cache in Block 2.
17: Hit.
So overall, there are 6 Hits. And the final contents of the Cache are:
Block 0: Words 16 - 19.
Block 1: Words 4 - 7
Block 2: Words 8 - 11
Block 3: Empty.
Am I correct?



LinkBack URL
About LinkBacks







Reply With Quote




Bookmarks