This C++ project simulates a Memory Management Unit (MMU) with a Translation Lookaside Buffer (TLB). It processes virtual memory addresses from a trace file, translating them into physical addresses using a page table and TLB cache mechanism. The project demonstrates concepts like virtual-to-physical address translation, TLB caching, page table lookups, and LRU (Least Recently Used) cache replacement policy.
- C++ compiler (e.g., g++)
- Standard C++ libraries
- Make utility for build automation (optional)
- Ensure that a C++ compiler is installed on your machine.
- Clone or download the project repository.
- Navigate to the project directory and use the Makefile to compile:
make
This will create the executable mmuwithtlb.
Execute the program with the following command, replacing [trace_file] with the path to your trace file, and [bit_counts] with the bit counts for each level in the page table:
./mmuwithtlb [trace_file] [bit_counts...]
TLB.h
&TLB.cpp
: Implements the Translation Lookaside Buffer (TLB).pagetable.h
&pagetable.cpp
: Manages the page table for address translation.vaddr_tracereader.h
&vaddr_tracereader.c
: Reads and processes virtual address traces.print_helpers.h
&print_helpers.c
: Utilities for printing various outputs.main.cpp
: Main driver of the program.Makefile
: Script for compiling the program.
-
TLB (Translation Lookaside Buffer):
- A cache mechanism for speeding up virtual-to-physical address translation.
- Implements LRU (Least Recently Used) policy for cache replacement.
-
Page Table:
- Handles the mapping of virtual addresses to physical frames.
- Supports multi-level page table structure.
-
Address Translation:
- Processes addresses from a trace file.
- Translates virtual addresses to physical addresses using the page table and TLB.
-std=c++11
: Uses the C++11 standard.-Wall
: Enables all compiler's warning messages.-g3
: Includes extra debugging information.
$(PROGRAM)
: Compiles the main program.clean
: Cleans up compiled objects and executable.
- The program can be tested with a trace file containing virtual addresses.
- It will output the physical addresses, TLB and page table hits/misses, and other relevant information.
./mmuwithtlb trace3.tr -p va2pa_tlb_ptwalk 20 2 -c 15