restluck.blogg.se

Direct mapped cache hit or miss
Direct mapped cache hit or miss









UnlgTotalLoads++ //record the total amount of loads. VecCache.push_back(lgCacheTag) //push value on the vector in order VecCache.push_back(lgCacheTag) //due to no overflow and a miss do a push onto the vectorīreak //break due to a miss was recorded If(vecCache.size()-1=x & vecCache!=lgCacheTag) //test for reaching the last value of the vector, and a miss VecCache.push_back(lgCacheTag) //push value on to the vector in order of recently usedīreak // break out of loop due to a miss was found VecCache.erase(vecCache.begin()) //erase the least recently used vector value Used to track the most recent used and least recent used vector value. Erase the vector location of the least recently used and push the new value on the bottom of vector. If(vecCache.size()-1 = x & vecCache!=lgCacheTag & vecCache.size()=lgBlocksPerSet) //test for end of vector, maxed out vector, and cache miss VecCache.push_back(lgCacheTag) // place back in line as most recently usedīreak // break out of loop due to hit was successful. VecCache.erase(vecCache.begin()+x) //Realign the most recently used. Used to track the most recent used and least recent used vector hit. Erase the vector location of the hit and push on the bottom of stack. If(vecCache=lgCacheTag) //check to see if the values you are cycling through are a memory hit If (vecCache.size()!=0) // check to see if vector size is 0įor(unsigned long x=0 x direct mapped cache hit or miss

Vector > vecCache //second dimension of the "cache" vectorįor(int i=0 i>lgByteAddress) // read in one line at a time of the load trace file Vector vecAssociativity //first dimension of the "associativity" vector UnlgTotalLoads++ // record the total loadsĮlse //any other associativity is calculated here VecCache=lgCacheTag // store cache address in vector at the cache address LgMiss++ // if not stored in memory we have a miss LgHit++ // if stored in memory we have a hit If(vecCache=lgCacheTag) // check to see if cache tag is stored in memory LgCacheTag = lgBlockAddress/lgNumberOfBlocks //caclulate the cache tag by using division LgCacheAddress = lgBlockAddress%lgNumberOfBlocks // calculate the cache address by using modulo LgBlockAddress = lgByteAddressConverted/lgBlockSize // calculate the lgBlockAddress by using division LgByteAddressConverted=lgByteAddressConverted+lgByteAddress //convert from memory save scheme to byte address While(inTraceFile>lgByteAddress) //read line by line of the load trace file If(!inTraceFile.is_open()) //test to see if the read was successfulĬout vecCache(lgBlocksPerSet) //create a one demensional vector Ifstream inTraceFile(argv, ios::in) //open the file for read only If (argc != 9) //test to see if user passed 9 parameters Unsigned long unlgTotalLoads=0 //store the total of all hits and misses Long lgFullAssociativit圜ount=0 //increment the associativity Long lgSetAddress=0 //store the set address (i.e. Long lgLRUCount=0 //counter for the LRU incrementation Long lgBlockAddress=0 //store the block address (i.e. Long lgCacheAddress=0 //store the cache address (i.e. Long lgMiss=0 //store total misses on the cache Long lgHit=0 //store total hits on the cache Long lgCacheSize=0 //store the cache size Long lgAssociativity=0 //store the passed in associativity

direct mapped cache hit or miss

#Direct mapped cache hit or miss code

Long lgBlockSize=0 //store the block code Long lgByteAddressConverted=0 //store the memory saving byte address Long lgByteAddress=0 //store the byte address after conversion Long lgBlocksPerSet=0 //used to store total blocks per set Long lgNumberOfBlocks=0 //used to store total blocks Int main(int argc, char *argv) // pass in arguments









Direct mapped cache hit or miss