Giter Site home page Giter Site logo

direct-mapped-cache-python-implementation's Introduction

Direct-Mapped-cache-python-implementation

About project:

Implementaion of direct mapped cache with 256 lines and varying words per line (1->16) using python, where each word is of 32 bits size.

Aim:

To observe and study the change in hit ratio for differing conditions such as number of words per line, number of lines, number of instructions.

mem_gen.py:

In mem_gen.py, we are implementing a main memory file with 1000000 entries (since creating a file with 236 entries will become too big; 11.64 GB to be exact). Hence, we whenever we want to access memory beyond 106, we are doing [integer value of memory address]%106.

memory.dat:

Contains 106 random entries between 0 and 255.

cache.py:

mem list contains entries of main memory cache list is used to find whether the memory instruction is a hit or a miss cache_data list contains data stored in cache after reading all instructions from input trace files gives an output file output.txt.

output.txt:

tells us whether each instruction is a miss or hit and what and where the data is read/stored, i.e. in cache/memory. Sample screenshot of how to output file would look, can be seen below

Alt text

Pre-requisites for running the code:

  1. Keep all files in same directory
  2. Run the code using python3
  3. Run mem_gen.py before running cache.py

Getting the output:

  1. Run cache.py
  2. One shall get two .png files, namely hit_ratio_ni and hit_ratio_wp, saved in the directory
  3. output.txt file, containing details about cache hit/miss is generated in the working directory

Plots:

hit ratio varying with number of instructions plot (words per line of cache fixed as 16)

Alt text

hit ratio varying with number of words per line plot

Alt text

Errors and their possible reasons:

  1. discrepancy of data stored in cache and memory

Possible reason:

we believe, that this discrepancy is arising due to us using %106 of address, thus changing the tag and maybe the index of where the data is going to be stored at. The block and byte offset remain unaffected by this change. This doesn't affect cache hit/miss ratio as we have implemented that seperately, without the need of main memory. The only reason as to why we didn't use a main memory of 232 entries, is because it's size is too big (11.64 GB!!) We believe, that if a proper main memory with 236 entires is used (don't forget to remove %106 in cache.py), then there will not exist any discrepancy between data used and data stored.

Done by:

1. C P Vikram Adithya

2. Parithimalan A

3. Sriram G

direct-mapped-cache-python-implementation's People

Contributors

ausollet avatar

Watchers

 avatar

Forkers

superhakar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.