Skip to content

A Java cache memory simulator that models cache hits, misses, reads, and writes with interactive command-line input. Demonstrates set-associative cache behavior and memory block fetching.

License

Notifications You must be signed in to change notification settings

christalphilip/cache-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Direct-Mapped Cache Simulator

Simulates a direct-mapped, write-back cache with a 16-slot configuration.

Features

  • 2 KB main memory initialized with sample values
  • 16 cache slots, each storing a 16-byte block
  • Supports read, write, and display operations
  • Calculates offset, slot number, and tag for each address
  • Displays cache contents in hex

Getting Started

  1. Clone the repository
    git clone https://github.com/christalphilip/cache-simulator.git
    cd cache-simulator
    
  2. Compile the Java file
    javac CacheSimulator.java

Usage

Run the program:

java CacheSimulator

Choose from:

  • (R) Read from an address (hex input)
  • (W) Write to an address (hex input + data)
  • (D) Display the current cache

Example Output

(R)ead, (W)rite, or (D)isplay Cache? R What address would you like read? 5 At that byte there is the value 05 (Cache Hit)

(R)ead, (W)rite, or (D)isplay Cache? W What address would you like to write to? 14C What data would you like to write at that address? 99 Value 99 has been written to address 14C. (Cache Hit) ...

View full output

Project Structure

cache-simulator/ ├── CacheSimulator.java ├── README.md ├── LICENSE ├── .gitignore └── output.txt

License

This project is licensed under the MIT License.

About

A Java cache memory simulator that models cache hits, misses, reads, and writes with interactive command-line input. Demonstrates set-associative cache behavior and memory block fetching.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages