Set Associative Cache: calculate tag size?

I'm trying to solve this issue, I looked around, but all of these issues are more advanced than mine, using magazines, they are more advanced than we did in our class. Here's the question:

Suppose you have a 4-way set associative cache which has in total 4096 bytes of cache memory and each cache line is 128 bytes. How many sets are there is this cache? If memory is byte addressable and addresses are 16 bits then how many bytes are used for the tag?

Here is what I still have:

4096/128 = num lines

4096/128/4 = 8 = num sets (each set is 4 lines in 4-way set assoiative)

So, need 3 bits to choose set (2^3=8)

We have 16-3 = 13 bits left for the tag and word.

Since the question says that the memory is addressed by bytes, I think this means that this word is 8 bits long (= 1 byte), and therefore the tag is 16-3-8 = 5 bits.

Although I'm not quite sure about this. Can anyone solve this problem?

Thanks.

+8
caching
source share
1 answer

If memory is addressed by byte

This statement simply states that the main memory is the address of the byte addressed, i.e. architectures to which data can be accessed 8 bits at a time, regardless of the data bus width and address.

This does not affect the number of bits the tag has.

Decision:

4-way associative association

Total cache = 4096 bytes

Block size (cache line) = 128 bytes

Number of cache lines = 4096/128 = 32 lines

The number of sets in the cache = 32/4 = 8 sets

 ╔════════════════════════════╗ β•‘ 16 bit address β•‘ ╠══════════╀════════╀════════╣ β•‘ tag bit? β”‚ 3 bits β”‚ 7 bits β•‘ β•šβ•β•β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β• 

Word offset = log 2 8 = 3 bits

Set offset = log 2 128 = 7 bits

Answer:

Label bit = 16 - (3 + 7) = 6 bits

 ╔══════════════════════════╗ β•‘ 16 bit address β•‘ ╠════════╀════════╀════════╣ β•‘ 6 bits β”‚ 3 bits β”‚ 7 bits β•‘ β•šβ•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β•§β•β•β•β•β•β•β•β•β• 
+6
source share

All Articles