0
$\begingroup$

Thank you for looking into this, I have a problem regarding direct cache mapping, My problem really though is with the question formation itself and the problem I am about to present seems to have inconsistency and has unclear description. So the problem is as follows ( I am presenting exactly as given )

32 bit architecture
Main memory size = 8GB
cache size = 512KB
Block size = 32 words

To Find

  1. Number of bits required for Byte Offset = ?
  2. Number of bits required for main memory address = ?
  3. Number of bits required for main memory block number = ?
  4. Cache Index bits = ?
  5. Tag-bits = ?
  6. Size of Tag Directory = ?

Now My Interpretation of the solution is as follows

As it is 32 bit architecture which means Word size is 4 Byte ( I am confused about this part the most as the question states cache block size in Words but expects to calculate Byte offset ) but for the sake of this problem, moving on main memory size is 8GB that's 233Bytes, cache size ( blocks only, this does not include tag directory which is part of cache controller ) Block size of 32 Words or 128 Bytes, now If you agree with me on this much, or else this is probably where I am wrong so please correct me right here. Now assuming I am correct so far, I will first calculate main memory address bits, that will be, first let's calculate it's size then let's do binary log, that will be 233Bytes / 4 Bytes per word this comes out to be 231 Words means 31 bits for memory address and our second answer, next I calculate number of main memory blocks that will be 233Bytes / 128 Bytes per block this comes out to be 226 Blocks of main memory so the number of bits required for main memory block number would be 26 bits, so this gives our third answer, moving forward as I assume a single cache/main memory block to be of 128 Bytes and not Words. So for byte offset within a block it must be 7 bits ( Point of highest concern ) and this should be our first answer according to the question. Now let's calculate number of cache blocks that will be 219Bytes / 128 Bytes per block which is 212 Blocks so cache index size will be 12 bits which is our fourth answer, we're almost done ! Now Tag bits should be and since it's direct mapped it should be memory address size - ( cache index + Word or Byte offset ) that is ( 31 - (12 + 7)) = 12 bits that is our fifth answer and finally size of tag directory will be 212Cache Blocks * 12bits per tag, Now not going into exact answer in KB's is this approach right or have I made a mistake or is the problem formulation incorrect ( as I think the mistake must be with cache blocks being in bytes or words ) ?

$\endgroup$
3
  • 1
    $\begingroup$ What's your question? If you think the exercise you were set is confusing or inconsistent, you should contact whoever set that exercise for you, not us; we can't resolve that for you. If you're asking us to check whether your solution is correct, we discourage those kinds of questions. Our mission is to build up questions and answers that will be useful to others in the future - is there a conceptual question you can ask that will be useful even to others who aren't looking at that exact exercise? $\endgroup$
    – D.W.
    Jan 23, 2021 at 3:46
  • $\begingroup$ @D.W. What I am asking here is, is my interpretation of solution right? Or am I making a mistake somewhere, also I can't ask the one who gave exercise no matter how much I want to. $\endgroup$ Jan 23, 2021 at 12:53
  • 1
    $\begingroup$ Please credit the original source of all copied material. We discourage "is my solution correct?" questions, as they are unlikely to be of any use to anyone else in the future. $\endgroup$
    – D.W.
    Feb 3, 2021 at 0:53

1 Answer 1

1
$\begingroup$

I am going to talk about the cache - related questions:

  1. Block size is $$32 \text{words} = 2^5$$ . That, means that you need, 5 bits for offset.
  2. $$\#\text{blocks}=\frac{2^{19}}{2^5}=2^{14}$$, so you need 14 bits for the index ( to indentify which block in cache is going to represent your wanted memory adresss )
  3. For a 32 - bit adress, tag is the rest : $$32 - 14- 5 = 13$$ bits.
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.