Skip to content

Instantly share code, notes, and snippets.

@angusb
Created April 10, 2010 22:09
Show Gist options
  • Save angusb/362330 to your computer and use it in GitHub Desktop.
Save angusb/362330 to your computer and use it in GitHub Desktop.
int whichSet = -1;
int wordBase = word;
int i;
int hit = 0;
while(1) {
if (wordBase % cache->blockSizeInWords == 0)
break;
wordBase--;
}
whichSet = (wordBase / cache->blockSizeInWords) % cache->numSets;
/* Determine if the requested instruction/word is a hit */
for (i=0; i<cache->blocksPerSet; i++) {
int blockWord = cache->cacheElt[whichSet][i].addr;
if (wordBase == blockWord && cache->cacheElt[whichSet][i].valid) {
hit = 1;
cache->cacheElt[whichSet][i].LRUnum = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment