Set Associative Cache Exercises

I am trying to solve an exercise on set-associative cache , i struggled with it for a while but i think that i figured out the answer , would be helpful if someone could check if my solution is correct

Here is the question:

Considering a main memory with 1024 addresses , divided in blocks of 8 words each, and a set associative cache with 4 sets and 8 ways:

a) How many words can the cache memory contain?

b) in which cache position the word with address 75(octal) could be memorized?

• 0
• 1
• 2
• 3
• 4
• 5
• 6
• 7
• other

c) if a cache miss occurs , how many words in cache memory will be modified?

a) We have a maain memory with 1024 locations, each location has 8 words 1024 * 8 = 8192 words in main memory (2^13).

Then we have a set associative cache with 4 sets , 8 ways each, 4*8 = 32 , so the cache has 32 blocks . each block contains 8 words, 32 * 8 = 256.

So the cache can contain 256 words (2^8)

b)

We know that in set associative cache , the main memory address is divided into

tag|set|offset

n = number of bits of the main memory address m = number of bits of the cache memory address b = size (expressed in words) of the block

n = 13 m = 8 b = 8

offset = log2 b = 3 set = log2 (number of sets) , 4 sets , so log2 4 = 2 tag = n - offset - set (13 - 3 - 2) = 8

so the address is divided in : 8 bits|2 bits|3 bits tag set offset

The address of the word is 75(octal) , convrted in binary is 111101 it is a 6 bits address , the main memory generates 13 bits addresses, so we rewrite it as 0000000111101 , we divide the address in:

00000001|11|101

From here we can se that the word could be memorized in any of the locations of the set 3 (11)

We have a cache with 4 sets and 8 ways each set: So we have 32 blocks in cache , assuming we start from block 0, we can see that the blocks in set 3 (ii) are

24,25,26,27,28,29,30,31

The question is asking in which locations the word with address 75(octal) could be stored, so it could be stored in one of the blocks from 24 to 31 so the answer to the question b should be: other

I haven't still figured out point c , but would be helpful to know if my reasoning is correct , or , where i am wrong.

• I think the question is bit confusing. Can you post the actual question, please. – Isu Jul 2 '18 at 9:58
• Ok , i will edit the post , leaving only the actual question – user2158666 Jul 2 '18 at 13:09
• Sorry, its fine to have your attempts as part of the question. I got confused by "main memory with 1024 addresses , divided in blocks of 8 words each". – Isu Jul 2 '18 at 14:04
• that part confuses me too , but the question is stated in that way , i will try to explain it in the post , the way i interpreted it , so you can tell me if it is reasonable. – user2158666 Jul 2 '18 at 16:02