CSCE 614 Spring 2020, Homework 2

Due before the beginning of class, February 13, 2020.

From The Book

From the Chapter 1 Case Studies and Exercises, do the following:
  1. 1.7
  2. 1.9
  3. 1.12
  4. 1.14
  5. 1.15
Work these problems yourself; do not help others or accept help from any other source but your professor. Write up your solutions with a word processor; hand-written assignments will not be graded. Turn in your assignment as a PDF emailed to csce614@gmail.com .

Coding

Write a simple cache simulator. Write your program in C or C++ and call it cache.c (for C) or cache.cc (for C++). The program should work by the following specifications:

Command-Line Parameters

There should be four command line parameters in this order:
  1. nk: the capacity of the cache in kilobytes (an int)
  2. assoc: the associativity of the cache (an int)
  3. blocksize: the size of a single cache block in bytes (an int)
  4. repl: the replacement policy (a char); 'l' means LRU, 'r' means random.

Input

Read traces from the standard input. Each line on the standard input will be a lowercase 'r' (for read) or 'w' (for write) followed by a space and then a 64-bit hexadecimal number giving the address of the memory access. For example, a snippet of a trace file looks like this:
r 56ecd8
r 47f639
r 7ff0001ff
w 47f63e
r 4817ef
r 7d5ab8

Output

The output should be a single line of six numbers separated by spaces. These six numbers are:
  1. The total number of misses,
  2. The percentage of misses (i.e. total misses divided by total accesses),
  3. The total number of read misses,
  4. The percentage of read misses (i.e. total read misses divided by total read accesses),
  5. The total number of write misses,
  6. The percentage of write misses (i.e. total write misses divided by total write accesses).

What to turn in

Turn in your assignment as a PDF and a C++ file emailed to csce614@gmail.com . Your name should appear in comments in the code as we will be grading the files separately from the other elements of the homework. Make your program a single file.

For a successful assignment

Write this code yourself. Do not receive assistance from anyone except for your professor. If you receive assistance, I will catch you and punish you. If I fail to catch you, you will punish yourself by not taking the opportunity to learn computer architecture and coding skills you will need for subsequent assignment.

Late assignments will not be accepted.