Three dependency-free Python microarchitectural simulators for studying classic core questions: branch prediction, cache replacement, and out-of-order execution. Each lab implements the canonical algorithms (the same ones published in ISCA/HPCA papers), validates them with unit tests including exact hand-computed cycle/reference checks, and reports results over synthetic traces with known ground truth.
| # | Lab | Question it answers | What's inside |
|---|---|---|---|
| 1 | branch-predictor-lab | Which dynamic branch predictors earn their complexity? | always-taken, bimodal 2-bit, gshare, tournament chooser, and Jimenez & Lin's perceptron predictor (HPCA 2001) — accuracy tables across loop, biased, correlated and mixed traces |
| 2 | cache-hierarchy-simulator | Which replacement policy survives a smarter workload? | Set-associative multi-level cache (write-back/write-allocate, non-inclusive) with LRU, FIFO, Random, SRRIP, BRRIP (RRIP, ISCA 2010) — L1 miss-rate tables incl. Zipf + hot-set/streaming traces |
| 3 | ooo-core-simulator | How do ROB size and machine width govern IPC? | Cycle-level ROB model: in-order dispatch, oldest-first issue on RAW deps with implicit renaming, fixed latencies, in-order commit — IPC/MLP sweeps (mlp_loop 0.10 → 2.01 IPC from ROB=8→256) |
Traits shared by all three labs:
- Unit tests with exact expected values (e.g. cycle-count exactness for the OoO core, known textbook predictor accuracy, analytic miss-rate cases) — not just "it runs".
- Synthetic traces with known ground truth (loop trip counts, Zipf parameters, pointer-chase serialization) so each experiment's result is interpretable.
- Zero runtime dependencies — every result reproduces with plain Python 3.11+.
# 1. Branch predictors
cd branch-predictor-lab
python -m unittest discover -s tests -t .
python run_experiments.py # accuracy table + results.csv
# 2. Cache hierarchies
cd ../cache-hierarchy-simulator
python -m unittest discover -s tests -t .
python run_experiments.py # miss-rate tables + results.csv
# 3. Out-of-order core
cd ../ooo-core-simulator
python -m unittest discover -s tests -t .
python run_experiments.py # IPC/MLP sweeps + results.csvCI runs all three labs' suites and experiment sweeps on Python 3.11 / 3.12 / 3.13 on every push, uploading each results.csv as an artifact so the numbers in every README are reproducible.
Research/teaching labs written for a portfolio, not production simulators. Synthetic workloads only; no vendor or client data.
MIT, see LICENSE.