This C11 simulator translates 16-bit logical addresses through a page table and a 16-entry translation lookaside buffer (TLB). It loads signed-byte values from a backing store, applies FIFO replacement to both the TLB and physical frames, and records translation statistics for a supplied address trace.
- Configurable page size and physical frame count
- FIFO page replacement with invalidation of stale TLB entries
- FIFO TLB replacement without duplicate insertion on page faults
- Logical-to-physical address translation and signed-byte lookup
- Strict validation for configuration values, address traces, and input files
- Reproducible regression test using the included 1,000-address workload
On Linux or macOS:
make
./mmu 10 32 > output.txtOn Windows with GCC:
gcc -std=c11 -O2 -Wall -Wextra -Wpedantic mmu_simulator.c -o mmu.exe
.\mmu.exe 10 32 > output.txtThe first argument is the number of offset bits, so 10 selects a 1,024-byte page. The second argument is the physical frame count. Running without arguments starts the interactive prompts.
The full command form accepts alternate fixture and output paths:
mmu frame-size-bits number-of-frames addresses-file backing-store statistics-file
The command ./mmu 10 32 processes the included files and writes these values to stat.txt:
| Metric | Result |
|---|---|
| Logical addresses | 1,000 |
| Page faults | 501 |
| Page-fault rate | 0.501000 |
| TLB hits | 234 |
| TLB hit rate | 0.234000 |
Detailed translations are written to standard output. Redirect them to a file when needed; generated executables, output.txt, and stat.txt are ignored by Git.
On Linux or macOS:
make testOn Windows:
python tests/test_mmu.py .\mmu.exeThe test checks the reference statistics, rejects an invalid physical-memory configuration, and rejects a malformed address trace.
mmu_simulator.c MMU simulator implementation
addresses.txt Included logical-address trace
backingstore.bin Included 65,536-byte backing store
tests/test_mmu.py Standard-library regression test
Makefile GCC build and test commands
The simulator models a single process with a 16-bit logical address space. It implements FIFO policies only and does not model dirty pages, write-back, protection bits, multilevel page tables, or concurrent memory accesses.
Source code and documentation are licensed under the MIT License. The supplied workload files are described separately in NOTICE.