c# - Index of an address in Associative Mapped Cache -


while calculating index of memory trace adddress in associative maping, using folllowing code:

address trace address read memory trace file.  block_shift=5 // fro 32bit block size cache_size=1024 associativity=4 // why m dividing index 2, 2^2=4 associativity  long index = ((address >> block_shift) & (cache_size - 1)) / 2;  int tag = address >> block_shift; // high order bits tag                     /* in line above want high bits (can include index bits) uniquely identify contents of cache-block */  if (tags[index] != tag)  {   // compare see if our data or other data mapped same location in    cache    misses++;    tags[index] = tag;    }    references++; 

but code giving wrong number of misses, method of calculating index of associative mapped cache correct.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -