Associative cache
<p>I've given an assignment where I need to simulate an associative cache with Java.
We're given a set of byte addresses, we need to find whether each address is a hit or a miss.
The cache consists of 32 blocks and each block is 8 bytes</p>

<p>So the scheme is like the following:</p>

<ul>
<li>Calculate the group address from the address (Group address is the address divided by the size of each block in the cache. For example group address for address 950 will be 950/8)</li>
<li>Use the entire group address as the tag</li>
<li>Scan the entire cache and see if the tag is already in the cache</li>
<li>If the tag is found, record a hit</li>
<li>If the tag is not found, record a miss, and store the tag in the first available block </li>
<li>If there are no spaces available, remove the LEAST recently used (LRU) block from the cache</li>
<li>Update the cache so the new tag is stored (if there was a miss) and remember this block is the MOST recently used.</li>
<li>Set valid bit to true, store tag in block, remember which address was used originally.</li>
</ul>

<p>The problem I'm having is doing the Least Recently Used bit. The way we're asked to implement the LRU is by keeping the blocks in order from most recently used to least recently used, and when we need to replace a block we remove the old one from the end and add the new onto the beginning. Then when we get a hit we move the hit to the beginning of the cache. </p>
