# How to calculate the size of main memory if the cache is 4-way set associative memory, cache memory size is 256KB and number of tag bits is 8

I'm trying to calculate the main memory size, and the only information given is the size of the cache, which is 256 KB, and the number of tag bits, which is 8. Cache is a 4-way set associative memory.

I'm wondering why block size information is missing in this question, because without it, I'm not able to calculate the number of blocks, number of sets, block offset, etc., which will eventually help me calculate the size of main memory.

Is there any way that I could find the block size with the given information above? I'm thinking that the cache size and number of tag bits do give something important, but I'm stuck. Any help will be appreciated.

## 1 Answer

I'm not able to calculate the number of blocks, number of sets, block offset, etc., which will eventually help me calculate the size of main memory.

None of that is required.

Your cache size is $$256KB$$, which means it can store sequence of $$\log_2(2^8.2^{10}) = 18$$ bits (assuming it is byte addressable). You will need $$\log_2 4 = 2$$ of these bits to access a particular block in the $$4$$-way set. Hence, set number and block offset together take $$16$$ bits and as mentioned in your question, tag takes $$8$$ bits; which makes the total address space consist of $$24$$ bits.

Therefore, main memory size is $$2^{8+16}B = 2^{24}B = 16MB$$.