Cache specifications

  • Read only – like an instruction cache. (It’s bad to allow users to write to the instructions)
  • This cache has 8 sets with 1 line each, and 32 bytes of data per line.
  • Please find the struct defining this cache at the top of cache.c

Getting Started

  • Watch the lecture videos about cache memories.
  • Read Section 6.1-6.4 of the CSAPP book.

Project Specification

  • Complete the function in cache.c that reads a single character from the cache. If the data in the cache is not valid then the cache goes to the next level down and reads the data into the cache (a function to put the data on the system bus is provided).
  • Write additional tests in main. Only one very simple test is provided to demonstrate how to use the cache.
  • You may find it useful to write a function to print the entire contents of the cache for debugging.
  • A struct describing the cache is included for you at the top of the file. Do not modify these structs.
  • Global counters track cache hits and misses. Increment these in your code to collect performance data.
  • We will be testing your function with a separte main function and text file. We will be testing with the struct and the Read_Data_From_Ram function provided.
  • Caches are built into hardware and not changed after manufactured. You may hardcode any data pertaining cache sizes.


bit shift, bitwise ‘and’, integer division and modulus operators can be really useful for extracting the tag, set, and byte data.


  • cache_template.c (https://canvas.wisc.edu/courses/280031/files/26017993/download?download_frd=1) – rename this to cache.c
  • alice_in_wonderland.txt (https://canvas.wisc.edu/courses/280031/files/26017995/download?download_frd=1)

Turn in

  • Upload you cache.c file to Canvas
  • You may submit as many times as you wish
  • Make sure you do your own work – we use Moss to identify academic misconduct

Style Guide

style_guide.pdf (https://canvas.wisc.edu/courses/280031/files/24252423/download?