From dbf3f7158966fb536ddcd44bb1b72a577988cdee Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Wed, 5 Aug 2015 09:16:31 +0200 Subject: [PATCH] Polished error model --- DRAMSys/dramSys/src/error/errormodel.cpp | 188 ++++++++++++++--------- DRAMSys/dramSys/src/error/errormodel.h | 1 + 2 files changed, 114 insertions(+), 75 deletions(-) diff --git a/DRAMSys/dramSys/src/error/errormodel.cpp b/DRAMSys/dramSys/src/error/errormodel.cpp index 3097ae4a..477adfbb 100644 --- a/DRAMSys/dramSys/src/error/errormodel.cpp +++ b/DRAMSys/dramSys/src/error/errormodel.cpp @@ -34,6 +34,7 @@ */ #include "errormodel.h" +#include "../common/DebugManager.h" #include #include #include @@ -95,11 +96,13 @@ errorModel::errorModel() // X X X // X 1 1 // X 1 1 - //setTemperature(89); //weakCells[0].bit = 0; //weakCells[0].col = 0; //weakCells[0].row = 0; //weakCells[0].dependent = true; + + setTemperature(89); + markBitFlips(); } errorModel::~errorModel() @@ -121,7 +124,7 @@ errorModel::~errorModel() // Clean list of weak cells: delete [] weakCells; - // If an access happened to a bank the numner of errors should be shown: + // If an access happened to a bank the numner of error events should be shown: if(myChannel != -1 && myBank != -1 && myBankgroup != -1 && myRank != -1 ) { std::cout << name @@ -132,6 +135,9 @@ errorModel::~errorModel() void errorModel::store(tlm::tlm_generic_payload &trans) { + // Check wich bits have flipped during the last access and mark them as flipped: + markBitFlips(); + // Get the key for the dataMap from the transaction's address: DecodedAddress key = xmlAddressDecoder::getInstance().decodeAddress(trans.get_address()); @@ -161,6 +167,7 @@ void errorModel::store(tlm::tlm_generic_payload &trans) memcpy(data, trans.get_data_ptr()+i, bytesPerColumn); // Save part of the burst in the dataMap + // TODO: Check if we can have double entries, is key unique? dataMap.insert(std::pair(key,data)); // Reset flipped weak cells in this area, since they are rewritten now @@ -183,12 +190,14 @@ void errorModel::store(tlm::tlm_generic_payload &trans) // Check that there is no column overfow: assert(key.column <= numberOfColumns); - } } void errorModel::load(tlm::tlm_generic_payload &trans) { + // Check wich bits have flipped during the last access and mark them as flipped: + markBitFlips(); + // Get the key for the dataMap from the transaction's address: DecodedAddress key = xmlAddressDecoder::getInstance().decodeAddress(trans.get_address()); @@ -218,6 +227,33 @@ void errorModel::load(tlm::tlm_generic_payload &trans) } } +void errorModel::markBitFlips() +{ + for(unsigned int row = 0; row < Configuration::getInstance().memSpec.NumberOfRows; row++) + { + // Get the time interval between now and the last acivate/refresh + sc_time interval = sc_time_stamp() - lastRowAccess[row]; + + // Obtain the number of bit flips for the current temperature and the time interval: + unsigned int n = getNumberOfFlips(temperature, interval); + + // Check if the current row is in the range of bit flips for this interval + // and temperature, if yes mark it as flipped: + for (unsigned int i=0; i0 transitions are supported) + // Check if the bit is 1 (only 1->0 transitions are supported) // DRAMs based on anti cells are not supported yet by this model if(getBit(key,byte,bitInByte) == 1) { @@ -287,11 +308,13 @@ void errorModel::activate(unsigned int row) // Flip the bit: tempByte = (tempByte & mask); - std::cout << "--- Bit Flipped:" - << " row: " << key.row - << " col: " << key.column - << " bit: " << weakCells[i].bit - << " ---"<< std::endl; + // Output on the Console: + std::stringstream msg; + msg << "Bit Flipped!" + << " row: " << key.row + << " col: " << key.column + << " bit: " << weakCells[i].bit; + DebugManager::getInstance().printDebugMessage(name, msg.str()); numberOfBitErrorEvents++; @@ -338,24 +361,31 @@ void errorModel::activate(unsigned int row) // Copy the modified byte back to the dataMap: memcpy(dataMap[key]+byte, &tempByte, 1); - std::cout << "--- Dependent Bit Flipped:" - << " row: " << key.row - << " col: " << key.column - << " bit: " << weakCells[i].bit - << " sum: " << sum - << " ---"<< std::endl; - std::cout << grid[0] << grid[1] << grid[2] << std::endl; - std::cout << grid[3] << grid[4] << grid[5] << std::endl; - std::cout << grid[6] << grid[7] << grid[8] << std::endl; + // Output on the Console: + std::stringstream msg; + msg << "Dependent Bit Flipped!" + << " row: " << key.row + << " col: " << key.column + << " bit: " << weakCells[i].bit + << " sum: " << sum << std::endl + << grid[0] << grid[1] << grid[2] << std::endl + << grid[3] << grid[4] << grid[5] << std::endl + << grid[6] << grid[7] << grid[8]; + DebugManager::getInstance().printDebugMessage(name, msg.str()); } else { - std::cout << "--- Dependent Bit NOT Flipped:" - << " row: " << key.row - << " col: " << key.column - << " bit: " << weakCells[i].bit - << " sum: " << sum - << " ---"<< std::endl; + // Output on the Console: + std::stringstream msg; + msg << "Dependent Bit NOT Flipped!" + << " row: " << key.row + << " col: " << key.column + << " bit: " << weakCells[i].bit + << " sum: " << sum << std::endl + << grid[0] << grid[1] << grid[2] << std::endl + << grid[3] << grid[4] << grid[5] << std::endl + << grid[6] << grid[7] << grid[8]; + DebugManager::getInstance().printDebugMessage(name, msg.str()); } } } @@ -382,10 +412,15 @@ unsigned int errorModel::getBit(DecodedAddress key, unsigned int byteInColumn, u unsigned char mask = pow(2, bitInByte); unsigned int result = (tempByte & mask) >> bitInByte; std::bitset<8> x(mask); - std::cout << "mask = " << x - << " bitInByte = " << bitInByte - << " tempByte = " << (unsigned int)tempByte - << " result = " << result << std::endl; + + std::stringstream msg; + msg << "mask = " << x + << " bitInByte = " << bitInByte + << " tempByte = " << (unsigned int)tempByte + << " result = " << result; + + DebugManager::getInstance().printDebugMessage(name, msg.str()); + return result; } } @@ -447,7 +482,7 @@ unsigned int errorModel::getBit(int row, int column, int byteInColumn, int bitIn key.column = column; key.row = row; - getBit(key, byteInColumn, bitInByte); + return getBit(key, byteInColumn, bitInByte); } void errorModel::setTemperature(double t) @@ -460,8 +495,6 @@ void errorModel::parseInputData() std::string fileName = Configuration::getInstance().ErrorCSVFile; std::ifstream inputFile(fileName); - std::cout << std::endl << name <<", Parsing Error File: " << fileName << std::endl; - if(inputFile.is_open()) { std::string line; @@ -483,7 +516,7 @@ void errorModel::parseInputData() >> str_mu_dependent >> str_sigma_dependent; - double temperature = std::stod(str_temperature.c_str(), 0); + double temp = std::stod(str_temperature.c_str(), 0); sc_time retentionTime = sc_time(std::stod(str_retentionTime.c_str(),0),SC_MS); unsigned int mu_independent = std::stod(str_mu_independent.c_str(),0); @@ -506,16 +539,16 @@ void errorModel::parseInputData() e.dependent = ceil(distribution2(generator2)); // Store parsed data to the errorMap: - errorMap[temperature][retentionTime] = e; + errorMap[temp][retentionTime] = e; - std::cout << "Temperature = " << temperature - << " Time = " << retentionTime - << " independent = " << errorMap[temperature][retentionTime].independent - << " dependent = " << errorMap[temperature][retentionTime].dependent - << std::endl; + std::stringstream msg; + msg << "Temperature = " << temp + << " Time = " << retentionTime + << " independent = " << errorMap[temp][retentionTime].independent + << " dependent = " << errorMap[temp][retentionTime].dependent; + + DebugManager::getInstance().printDebugMessage(name, msg.str()); } - - std::cout << std::endl; inputFile.close(); } else @@ -594,7 +627,8 @@ void errorModel::prepareWeakCells() } } // If a cell was already choosen as weak we have to roll the dice again: - if(found == true) { + if(found == true) + { i--; } else @@ -627,11 +661,13 @@ void errorModel::prepareWeakCells() // Debug output where the weak cells are located: for (unsigned int i=0; i