Finding the tag ID for 16-bit architecture

  • Context: Comp Sci 
  • Thread starter Thread starter ver_mathstats
  • Start date Start date
  • Tags Tags
    Architecture Tag
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
7 replies · 2K views
ver_mathstats
Messages
258
Reaction score
21
Homework Statement
Given a DMMC 16-bit architecture, the cache holds 8 blocks of memory each being 32 bytes long, how many bits to represent the tag of each block?
Relevant Equations
offset, index, tag
I'm not sure if I am doing this right so if someone could check over my work that would be appreciated. Would we begin with 25=32 where 5 is the number of bits for the offset, then for the index it would be 256 bytes total meaning 28 so 8 bits for the index and then for the tag it would be 16-8-5=3

Is this correct? Thank you
 
Physics news on Phys.org
ver_mathstats said:
Homework Statement:: Given a DMMC 16-bit architecture, the cache holds 8 blocks of memory each being 32 bytes long, how many bits to represent the tag of each block?
Relevant Equations:: offset, index, tag

I'm not sure if I am doing this right so if someone could check over my work that would be appreciated. Would we begin with 25=32 where 5 is the number of bits for the offset, then for the index it would be 256 bytes total meaning 28 so 8 bits for the index and then for the tag it would be 16-8-5=3

Is this correct? Thank you
Please tell us a little about the DMMC 16-bit architecture, and specifically about what the tag represents. I doubt that very many people at this site know about it.

If the tag represents the particular block in the cache, then only 3 bits are needed. But then again, I don't know what the tag is supposed to represent.
 
Reply
  • Like
Likes   Reactions: ver_mathstats
Mark44 said:
Please tell us a little about the DMMC 16-bit architecture, and specifically about what the tag represents. I doubt that very many people at this site know about it.

If the tag represents the particular block in the cache, then only 3 bits are needed. But then again, I don't know what the tag is supposed to represent.
A direct mapped memory cache has data stored in blocks so here we have 8 blocks. Blocks contain multiple words of data, here each block is 32 bytes long. Each block is selected by an index, the tag is the “remaining” part of the address. Index: the lower bits which is used to determine where to put the data in the cache Tag: the upper bits, this is entered into the tag field of the cache entry. Now for the formulas of how to find each: example that I found online: "A cache is direct-mapped and has 64 KB data. Each block contains 32 bytes. The address is 32 bits wide. What are the sizes of the tag, index, and block offset fields? # bits in block offset = 5 (since each block contains 2^5 bytes) # blocks in cache = 64×1024 / 32 = 2048 blocks – So # bits in index field = 11 (since there are 2^11 blocks) # bits in tag field = 32 - 5 - 11 = 16 (the rest!)"

So for my example I did the block offset as 5 because 2^5=32. As for the index I understand the example, but it throws me off in my own problem. Bc I am using this formula "Number of cache blocks = Cache size / Block size" so then 2^3 = x/2^5 solving for x we get 2^8 as for tag it is 16 (bc it is a 16 bit architecture) minus the block offset and the index. So then it would be 16-5-3=8, 8 bits for the tag after revising my answer?

I think the second time after revising my answer is the correct way to do it.
 
This is a classic case of distracting with extraneous information. Read the question part again: "how many bits to represent the tag of each block?"

How many blocks are there?
 
ver_mathstats said:
for the index it would be 256 bytes total
How do you know that?

You have the right answer in #1 but I can't see how you got there: did you cheat?
 
pbuk said:
How do you know that?

You have the right answer in #1 but I can't see how you got there: did you cheat?
Ouch no I did not cheat, I got the first one because I did 2^5=32 again that is the block offset, 256 bytes total I got because I did 8x32, 8 blocks of 32 bytes each, so 256 bytes total then 2^8=256 which is how I got the index here then I did 16-8-5=3. This is how I did it the first time. Then I saw more examples and got confused.
 
ver_mathstats said:
Ouch no I did not cheat, I got the first one because I did 2^5=32 again that is the block offset, 256 bytes total I got because I did 8x32, 8 blocks of 32 bytes each, so 256 bytes total then 2^8=256 which is how I got the index here then I did 16-8-5=3. This is how I did it the first time. Then I saw more examples and got confused.
Ah, I think you got it by luck then! Follow:
"I did 2^5=32 again that is the block offset" - yes,
"256 bytes total I got because I did 8x32, 8 blocks of 32 bytes each, so 256 bytes total" - yes (note 3 + 5 bits)
"then 2^8=256 which is how I got the index here" - but how do you know the index has 8 bits? You don't, you have to work backwards: if the address bus is 16 bits then the total memory is 2^16 bits and the cache size is 2^(3 + 5) bits then the index must 2^(16 - (3 + 5)) bits
"then I did 16-8-5=3" - yes

But what you have ended up with is 16 - (16 - (3 + 5)) - 5 = 3. Much easier to say "the cache holds 8 blocks of memory so I need 3 bits for the tag".
 
Reply
  • Like
Likes   Reactions: ver_mathstats
pbuk said:
Ah, I think you got it by luck then! Follow:
"I did 2^5=32 again that is the block offset" - yes,
"256 bytes total I got because I did 8x32, 8 blocks of 32 bytes each, so 256 bytes total" - yes (note 3 + 5 bits)
"then 2^8=256 which is how I got the index here" - but how do you know the index has 8 bits? You don't, you have to work backwards: if the address bus is 16 bits then the total memory is 2^16 bits and the cache size is 2^(3 + 5) bits then the index must 2^(16 - (3 + 5)) bits
"then I did 16-8-5=3" - yes

But what you have ended up with is 16 - (16 - (3 + 5)) - 5 = 3. Much easier to say "the cache holds 8 blocks of memory so I need 3 bits for the tag".
hm interesting but I see now how it works, thank you