Skip to content

Simulate cache behavior with this CacheSimulator, exploring cache policies, performance, and related concepts.

License

Notifications You must be signed in to change notification settings

Wanghley/cache-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn Buy Me a Coffee


Logo

Cache Simulator

Simulate cache behavior, explore cache policies, and analyze performance.
Explore the code »

Table of Contents
  1. About The Project
  2. Built With
  3. Getting Started
  4. Usage
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgments

About The Project

The Cache Simulator project allows you to simulate cache behavior, analyze various cache policies, and evaluate performance. Use this tool to gain insights into caching strategies and optimize memory access patterns. This is an implementation of a write-through write-no-allocate cache policy for testing and educational purposes.

(back to top)

Built With

csharp csharp csharp

(back to top)

Getting Started

To get started with the Cache Simulator, follow the instructions below:

Prerequisites

Installation

  1. Clone the repo
    git clone https://github.com/wanghley/cache-simulator.git
  2. Compile the code
    gcc -g -o cachesim cachesim.c
  3. Run the code
    ./cachesim <trace file.txt> <cache size in kB> <Associativity> <Block size in B>
    

(back to top)

Usage

This C program serves as a single-level cache simulator, providing a means to understand and analyze the behavior of a cache and the underlying memory system. It can be utilized in various scenarios to explore cache performance. The usage instructions and scenarios are outlined below:

How to Run

To run the cache simulator, use the following command in the terminal:

./cachesim <filename> <cache size kB> <associativity> <block size B>

Example:

./cachesim trace.txt 32 1 32

Input Format

  • <filename>: The name of the file containing memory access traces.
  • <cache size kB>: Cache size in kilobytes.
  • <associativity>: Cache associativity (number of ways).
  • <block size B>: Block size in bytes.

Scenarios and Features

  1. Memory Configuration:

    • Addresses are 24 bits (3 bytes).
    • Addressable memory ranges from 0 to 2^24 - 1 (16 MB).
    • The machine is byte-addressable and big-endian.
  2. Cache Configuration:

    • Cache size, associativity, and block size are powers of 2.
    • Cache size is limited to 2MB, block size is limited to 1024B.
    • No access is larger than the block size, and no access spans multiple blocks.
  3. Cache Operation:

    • Cache is write-through and write-no-allocate.
    • The cache is initially empty.
  4. Cache Access:

    • For each memory access, the simulator outputs whether it's a cache hit or miss.
    • If a miss occurs, the simulator loads the data from main memory.
  5. Supported Operations:

    • load: Reads data from cache or main memory.
    • store: Writes data to cache or main memory.

Use Cases

  • Cache Performance Analysis:

    • Evaluate the impact of different cache configurations on hit/miss rates.
    • Understand how changes in cache size, associativity, and block size affect performance.
  • Memory Access Pattern Study:

    • Analyze the behavior of the cache under different memory access patterns.
    • Identify scenarios where cache locality is high or low.
  • Cache Replacement Policy Testing:

    • Observe the impact of cache replacement policies by analyzing cache hit/miss patterns.
  • Teaching and Learning:

    • Serve as an educational tool for students learning about computer architecture and cache systems.

Notes

  • The program assumes a specific memory organization and cache policy, making it suitable for educational and analytical purposes.
  • The debug mode (DEBUG) can be enabled for additional output during execution.

Feel free to explore and modify the code to suit specific learning or analysis requirements.

(back to top)

Roadmap

  • Implement basic cache simulation
  • Add support for different cache policies
  • Optimize code for performance
  • Explore additional features based on user feedback

See the open issues for a full list of proposed features and known issues.

(back to top)

Contributing

Contributions are welcome! If you have suggestions, improvements, or bug fixes, feel free to open an issue or submit a pull request.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Wanghley Soares Martins - @wanghley - wanghley@wanghley.com

Project Link: https://github.com/your_username/CacheSimulator

(back to top)

Acknowledgments

(back to top)

About

Simulate cache behavior with this CacheSimulator, exploring cache policies, performance, and related concepts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published