#include "replacement_state.h" #include //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // // This file is distributed as part of the Cache Replacement Championship // // workshop held in conjunction with ISCA'2010. // // // // // // Everyone is granted permission to copy, modify, and/or re-distribute // // this software. // // // // Please contact Aamer Jaleel should you have any // // questions // // // //////////////////////////////////////////////////////////////////////////////// /* ** This file implements the cache replacement state. Users can enhance the code ** below to develop their cache replacement ideas. ** */ //////////////////////////////////////////////////////////////////////////////// // The replacement state constructor: // // Inputs: number of sets, associativity, and replacement policy to use // // Outputs: None // // // // DO NOT CHANGE THE CONSTRUCTOR PROTOTYPE // // // //////////////////////////////////////////////////////////////////////////////// CACHE_REPLACEMENT_STATE::CACHE_REPLACEMENT_STATE( UINT32 _sets, UINT32 _assoc, UINT32 _pol ) { numsets = _sets; assoc = _assoc; replPolicy = _pol; mytimer = 0; InitReplacementState(); } //////////////////////////////////////////////////////////////////////////////// // // // This function initializes the replacement policy hardware by creating // // storage for the replacement state on a per-line/per-cache basis. // // // //////////////////////////////////////////////////////////////////////////////// void CACHE_REPLACEMENT_STATE::InitReplacementState() { // Create the state for sets, then create the state for the ways repl = new LINE_REPLACEMENT_STATE* [ numsets ]; // ensure that we were able to create replacement state assert(repl); // Create the state for the sets for(UINT32 setIndex=0; setIndex