Skip to content

About

A cycle-accurate C++ direct-mapped cache memory simulator for CPU architectural modeling

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

CPU Cache Memory Simulator (C++)

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.


Key Architectural Features

  • 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 (%).

Memory Address Slicing Mechanics

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 $\log_2(\text{Block Size})$
Index Maps address to a specific cache set/slot $\log_2(\text{Total Slots})$
Tag Unique tag verifying data ownership $\text{Remaining upper bits}$

Quickstart & Execution

Prerequisites

  • Standard C++ Compiler supporting C++11 or higher.
  • Alternatively, run directly in any online C++ compiler (e.g., OnlineGDB).

Compilation & Running Locally

  1. 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

About

A cycle-accurate C++ direct-mapped cache memory simulator for CPU architectural modeling

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages