CS 154 Lab 4

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


Due Friday, June 3, 2009.

In this lab, you will write a trace-driven cache simulation program to compare an associative cache with a victim cache arrangement. You will turn in (C or C++) source code and a PC executable called "cachesim." Your executable will take two arguments:

cachesim [tracefile] -[flag]

  • [tracefile] is a list of memory references that you will simulate
  • [flag] is either "victim" or a number (2,4,8) which specifies an associative cache with set size equal to the number given

    For all caches simulated:

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

    The victim buffer will have eight entries.

    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

    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.

    The trace file will contain a series of memory references, each on a new line and represented in ASCII as follows:

    [hex address]

    The first item is a hexadecimal memory address printed in ASCII.

    You will generate one trace file with which to demonstrate your program. The trace will be synthetic (not based upon real programs). The trace should perform equally well on the victim cache as the 4-way set associative cache, but not as well on a 2-way set associative cache. The tracefile should be 1000 references long. I suggest you write a small program to generate each one.

    You will turn in the tracefile, your source code, and your cachesim executable. Please include a Makefile and/or instructions on how to compile your program. The grader will also run his own tracefiles with your simulator.


    Last updated May 25, 2009
    chong@cs.ucsb.edu