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
- Number of bits required for Byte Offset = ?
- Number of bits required for main memory address = ?
- Number of bits required for main memory block number = ?
- Cache Index bits = ?
- Tag-bits = ?
- 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 cache 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 ) ?