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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -