# Direct-mapping cache question

Say I have the following memory scheme:

Data bus: 8 bit

Main Memory Store: 256 Byte

Cache Store : 32 Byte

Block Size : 4 Byte

How would I go about listing the assigned bits for tag,offset and block number for location 12?

I think the right answer is 12 is binary is 00001100 since we have 8-bit representation. Then the first 4-bits would be line number and block number and the last 4 would be the offset? Is this correct? If not can anyone explain why?

I got this question wrong on homework and my TA is not responding to my questions.

My line of thinking is that each memory location saved in a cache is made of 3 components, the tag (which is what the cache uses to recognize it), the index (the location in cache that it is stored), the offset(tells the ram which offset hold the value).

Now in tag + index = baselocation and baselocation + offset = the address we want in main mem.

First off to calculate the offset it should 2^b where b = linesize. In direct mapping line size = block size which is 4. So the lower 4 bits are my offset.

Next the index which is the power of 2 that is needed to uniquely address memory. Since the cache total is 32. We need 2^x = 32 which is 5.

Lastly the tag is total# of bits - (offset + index) = -1 because 8 -9 which I know is inherently wrong.

This leads me to my previous answer above for location 12. Since it is 8-bits the lower 4 must be my offset leaving the upper 4 for my tag and index.

Guess that's why I got it wrong. But what is the right answer? And how do you solve these types of problems?

• It is, literally, your TA's job to respond to this kind of question. If they haven't responded within a reasonable amount of time, you need to take this up with the class's teacher. Commented Dec 5, 2016 at 16:06
• I've already sent him an email but I would still like to know why my answer is wrong. Commented Dec 5, 2016 at 16:08
• It is not correct, you should explain how you think you should calculate these numbers so you can be corrected properly. Commented Dec 5, 2016 at 19:19
• @harold thank you. I have done as you've recommended. If you have any more follow up queries let me know and I can edit them in. After typing out my steps verbatim I feel like my index is wrong somehow. Like maybe it should be smaller? Commented Dec 5, 2016 at 19:36
• Possible duplicate of Tag, index and offset of associative cache Commented Feb 2, 2018 at 14:16