Coder Social home page Coder Social logo

yadav-sachin / multilevel-cache-controller Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 1.0 14.09 MB

Cache Controller for a multi-level Cache memory using four-way set-associative mapping with write-back, no-write allocate and LRU policy. Implemented on a Basys3 Artix-7 FPGA with proper delays and hit signals.

Verilog 100.00%
cache-control set-associative-cache write-back lru-cache basys3-fpga four-way-set-associative

multilevel-cache-controller's Introduction

Multilevel Cache Controller

Implemented a Cache Controller for two layers of Cache Memory. The L1 Cache Memory is Direct Mapped and the mapping used for L2 Cache is four-way set associative.

In direct mapping, each line in the next memory level ( L2 Cache here) is mapped to a specific line in the Cache (L1 Cache here). Direct Mapping being the simplest mapping policy is easiest to implement but has some disadvantages such as if two memory blocks which map to the same line in Cache are continuously referred, then the two blocks are continuously swapped in the Cache Memory.

Set-Associative Mapping is an enhanced form of Direct Mapping where the disadvantages of direct mapping are removed. Instead of mapping a block on a single line in Cache, it is mapped to a set ( a group of lines). In case the set is full, then the least recently used block in Cache is removed to make space for the next block to be stored in Cache.

Block Diagram

File Structure

.
├── README.md
├── Screenshots
└── src
    ├── constrs
    │   └── Cache_Controller_Constraints.xdc # constraint file
    ├── sim
    │   └── TB_READ.v # simulation test file
    └── sources
        └── CACHE_CONTROLLER.v # main verilog source file

Algorithms and Policies Used:

Write-Back Policy:

In write-back policy,the data is updated ina cache level everytime a write instruction is issued by the processor, but it is written into higher levels of cache or main memory only when the memory block evicts from the lower cache level.

  • Pros
    • Optimizes system speed
  • Cons
    • Risk of data loss

No-Write Allocate Policy:

In no-write allocate policy, when a write miss occurs in a lower level of cache memory, the data is updated in the higher level of cache memory or in main memory (wherever found), but is not loaded into the lower level cache memory.

  • Pros
    • Fewer spurious evictions
  • Cons
    • Slower data read from write location

Least Recently Used (LRU) Replacement Algorithm

LRU Replacement Algorithm works on the idea that a block of memory that has been heavily used in the last few instructions is likely to be used again in the next few instructions. Thus, the memory block lying unused for the longest time is thrown out whenever required.

  • Pros
    • Minimizes unnecessary evictions
  • Cons
    • Time and space consuming

Implementation on Basys3 FPGA

Signal Value Signal
Address 00000000000 (11 bit) Address
Mode 0 (Read)
Output Data 0110 (4 bit)
Wait 0
L1 Hit 1 (Found in L1 Cache)
L2 Hit 0

Implementation 1

Signal Value Signal
Address 00000010000 (11 bit)
Mode 0 (Read)
Output Data 0110 (4 bit)
Wait 1 (Processor in wait state)
L1 Hit 0 (Not Found in L1 Cache)
L2 Hit 0 (Not Found in L2 Cache)

Implementation 2

Synthesis Report

Hardware Usage

Report 1

  • Number of Look Up Tables utilised = 6953
  • Percentage of Look Up Tables utilised = 33.43%
  • Number of Flip Flops Used = 1763
  • Number of F7 Multiplexers used= 220
  • Number of F8 Multiplexers used= 32

Design Time Summary

Report 2

  • Worst Negative Slack = 4.852 ns
  • Worst Hold Slack = 0.265 ns
  • Worst Pulse Width Slack = 4.500 ns

On-Chip Power

Report 3

  • Total On-Chip Power = 0.167 W
  • Junction Temperature = 25.8 O C

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.