A cycle-accurate, software-based memory cache simulator built in C++ to model CPU microarchitecture performance trade-offs.
This tool simulates a Direct-Mapped L1 Cache architecture, parsing memory trace streams to analyze hit/miss ratios, address decoding, and cache eviction patterns prior to hardware synthesis.
- Bitwise Address Decoding: Extracts Tag, Index, and Offset fields from raw 32-bit hex memory addresses using configurable bit-masking logic.
- Configurable Parameters: Supports customizable total cache sizes (e.g., 1024 Bytes) and cache line block sizes (e.g., 64 Bytes).
- Performance Metrics: Automatically calculates total memory accesses, hit counts, miss counts, and hit rates (
%).
The simulator processes standard memory addresses by dynamically computing field boundaries based on the total number of cache sets:
| Field | Description | Calculation |
|---|---|---|
| Offset | Pinpoints exact byte within a cache line block | |
| Index | Maps address to a specific cache set/slot | |
| Tag | Unique tag verifying data ownership |
- Standard C++ Compiler supporting C++11 or higher.
- Alternatively, run directly in any online C++ compiler (e.g., OnlineGDB).
- Clone the repository:
git clone [https://github.com/YOUR_USERNAME/cpu-cache-simulator.git](https://github.com/YOUR_USERNAME/cpu-cache-simulator.git) cd cpu-cache-simulator