A processor cache simulator for the MIPS instruction set architecture
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Remove compliance tests; add pycodestyle to Travis Apr 7, 2018
.coveragerc Use glob for include list in coveragerc Mar 5, 2018
.gitignore Ignore build directories and extra coverage files Jul 9, 2016
.python-version Explicitly declare minimum required Python version Aug 8, 2016
.travis.yml Add Python 3.6 to CI pipeline Apr 8, 2018
LICENSE.txt Update copyright year to 2018 Mar 5, 2018
README.md Reflow README paragraphs Mar 12, 2018
examples.txt Update README and examples to use command name Jul 9, 2016
setup.py Prepare v2.0.1 release May 29, 2018


Cache Simulator

Copyright 2015-2018 Caleb Evans
Released under the MIT license

Build Status Coverage Status

This program simulates a processor cache for the MIPS instruction set architecture. It can simulate all three fundamental caching schemes: direct-mapped, n-way set associative, and fully associative.

The program must be run from the command line and requires Python 3.4+ to run. Executing the program will run the simulation and print an ASCII table containing the details for each supplied word address, as well as the final contents of the cache.

To see example input and output, see examples.txt.


You can install Cache Simulator via pip (ideally globally):

pip install cache-simulator

Command-line parameters

Required parameters


The size of the cache in words (recall that one word is four bytes in MIPS).


One or more word addresses (separated by spaces), where each word address is a base-10 positive integer.

Optional parameters


The program internally represents all cache schemes using a set associative cache. A value of 1 for this parameter (the default) implies a direct-mapped cache. A value other than 1 implies either a set associative or fully associative cache.


The number of words to store for each block in the cache; the default value is 1.


The number of bits used to represent each given word address; this value is reflected in the BinAddr column in the reference table. If omitted, the default value is the number of bits needed to represent the largest of the given word addresses.


The replacement policy to use for the cache. Accepted values are lru (Least Recently Used; the default) and mru (Most Recently Used).