Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 1.36 KB

File metadata and controls

61 lines (48 loc) · 1.36 KB

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.