title: Have a few questions about caches and cache hits/misses
body: <p>This is a homework problem, but the homework was already due and we were already given the answers, I just have no idea how they actually came up with these answers.</p>
  
  <p>It relates to caches, and I'm just getting a lot of concepts mixed up.</p>
  
  <p>Here is the question: </p>
  
  <p>For a direct-mapped cache design with a 32-bit address, the following bits of the 
  address are used to access the cache.</p>
  
  <p><img src="https://i.stack.imgur.com/IK5Kz.png" alt="enter image description here"></p>
  
  <p><strong>From my understanding, the index bits determine which block in the cache a particular location in memory is mapped to. The lowest log(base2) bits off the address determine the cache block, and here there are 5 index bits, so I know that there will be a total of 2^5 blocks in the cache, or 32.</strong> </p>
  
  <p>What is the cache block size (in words)? </p>
  
  <p><strong>According to the answers given to us, the cache block size is 8. According to some notes given to us by our TA, the block size is 2^(# of offset bits), which in this case would be 5. However, that gives me as an answer 32, so I do not know where the 8 is coming from. Furthermore, nowhere in this book is the term "offset bits" defined, so can somebody tell me exactly what this means?</strong></p>
  
  <p><img src="https://i.stack.imgur.com/P3ty3.png" alt="enter image description here"></p>
  
  <p>**What I'm thinking here is that since the same memory address is never referenced twice, there should be NO hits, since the cache will never already have the data it is looking for within the cache. However, according to the answers, the hit ratio should be .25, so once again I guess I'm not understanding what is going.
  Finally, for the last question it says the answer is as follows:
  </p>
  
  <p>&lt;000001, 0001, mem[1024]></p>
  
  <p>&lt;000001, 0011, mem[16]></p>
  
  <p>&lt;001011, 0000, mem[176]></p>
  
  <p>&lt;001000, 0010, mem[2176]></p>
  
  <p>&lt;001110, 0000, mem[224]></p>
  
  <p>&lt;001010, 0000, mem[160]></p>
  
  <p>Which contains some memory addresses (176, 2176) that weren't even in the original question, so by this point I completely lost about everything. Can somebody help clear some of these things up for me?**</p>