A simple cache simulator written in Rust programming language.
Run immediately:
- trace 1:
make run config_path=./configs/test.json trace_path=./trace/trace1.txt
- trace 2:
make run config_path=./configs/test.json trace_path=./trace/trace2.txt
Detailed Steps:
- Get Rust toolchain and make sure you could compile Rust codes with
cargo
. - Clone the repository:
git clone https://github.com/xuehaonan27/cache-simulator.git
. - Enter the repository:
cd cache-simulator
. - Prepare a configuration file as described below.
- Prepare a trace file.
- Run test with
make run config_path=</path/to/your/config/file> trace_path=</path/to/your/trace/file>
. - The results will be printed to stdout with pretty format (as least I think it's pretty).
- Add
> /path/to/your/save/file
to save the results to a file.
You can see example configuration files in configs
directory, e.g. test.json
.
A configuration file that could be parsed by the simulator must be a json file, containing a single object with four required fields:
- CPU_GHZ: CPU frequency in Ghz.
- using_latency_as_cycles:
- When set to true:
"hit_latency": 1
or"bus_latency": 1
means 1 cycle. - When set to false:
"hit_latency": 1
or"bus_latency": 1
means 1 nanosecond.
- When set to true:
- memory: configuration describing memory.
- caches: a list of configuration objects describing caches. The
layer
fields must be continuous integers like 1, 2, 3, ..., which mean L1, L2, L3, ... caches.
configs/group_1
contains configuration files for question 1, and so on and so forth. These configuration files are generated bybuild_scripts.py
.sim_results/group_1
contains results for question 1, and so on and so forth. These results are generated by the simulator, and the auto script isrun_scripts.py
.figures/group_1
contains pictures visualizing the results for question 1 and 2. The figures are plotted by withplot_scripts.py
.L1s64Kw8bs64_L2s512Kw8bs64
means:L1
cache totals
ize64K
,w
ays8
(associativity),b
locks
ize64
B.L2
cache totals
ize512K
,w
ays8
(associativity),b
locks
ize64
B.