CS 154 Lab 4

Prof. Fred Chong
Department of Computer Science
University of California at Santa Barbara


In this lab, you will write cache simulation program to compare several caches on a strided memory access. You will turn in (C or C++) source code and a PC executable called "cachesim." Your executable will take the following arguments:

cachesim [start] [numaccesses] [stride] -[flag]

  • [start] is the address of the first memory access
  • [numaccesses] is the number of memory accesses to simulate
  • [stride] is the distance between memory accesses
  • [flag] is either "a", "b", or "c" where:

  • Option a: is a direct-mapped cache
  • Option b: is a 2-way set-associative cache
  • Option c: is a direct-mapped cache with a 4-entry fully-associative victim cache

    For example:

    cachesim 0 1000 4 -a

    Simulates 1000 accesses starting at location 0 and proceeding to 4, 8, 12, until 1000; on the direct mapped cache (a).

    For all caches simulated:

  • blocksize = 16 bytes
  • total cache size = 256 Kbytes
  • addresses are 32 bits
  • LRU replacement policy (you can implement ideal LRU since you are using a simulator)
  • byte addressable

    Your program will report:

  • The number of references simulated
  • The miss rate (a hit in the victim cache does not count as a miss)
  • The percentage of misses due to conflict misses (hitting in the victim cache is not a conflict miss, and assume no capacity misses)
  • The number of references that went to the victim cache

    The victim cache should swap any data item found there into the direct-mapped cache.

    You will also output a file called "misses" which will contain a list of line numbers (each on a new line) that correspond to the line number of every reference from the tracefile that caused a miss.

    You will also turn in a file called "labreport", which will be a text file which contains the following:

  • A set of input parameters for which cache (a) is just as good as (b) and (c)
  • A set of input parameters for which cache (b) is best
  • A set of input parameters for which cache (c) is best

    "good" or "best" means lower or lowest miss rate.

    Include a Makefile to compile your program.


    Last updated May 2007
    chong@cs.ucsb.edu