# Associative cache finding the tag and word number

An associative cache has a block size of 16 words. The capacity of the cache is 32 Kbytes and main memory can store 4 Mbytes. The word (the addressable unit) size is 2 bytes.

I'm unsure how to find the tag and word number and was wondering if someone could describe how the main memory address is divided into the tag and word number and how to find the number of bits for each.

Also in the answer, I have for this question the tag and word together equaLS 21 bits. From my understating is should be 22 as 2^22 = 4Mbytes. So an explanation as to why it's 21, not 22 would be very helpful.

## migrated from stackoverflow.comJan 12 at 10:01

This question came from our site for professional and enthusiast programmers.

• The addressable unit is 2 bytes, therefore each unique address identifies a unique 2-byte memory location of main memory, which contains 2^21 words. Since there are 16 words in a block, the size of the word number is log2(16) bits. The rest of the bits would constitute the tag. Real architectures like x86 usually have an addressable unit of 1 byte. So for a 4Mbyes main memory, the size of an address would be effectively 2^22. – Hadi Brais Jan 9 at 17:15