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?
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)
We know that in set associative cache , the main memory address is divided into
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:
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
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.