Polished error model
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
#include "errormodel.h"
|
||||
#include "../common/DebugManager.h"
|
||||
#include <random>
|
||||
#include <chrono>
|
||||
#include <bitset>
|
||||
@@ -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<DecodedAddress, unsigned char*>(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; i<n; i++)
|
||||
{
|
||||
// Check if Bit has marked as flipped yet, if yes mark it as flipped
|
||||
if(weakCells[i].flipped == false && weakCells[i].row == row)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "Maked weakCell[" << i << "] as flipped" << std::endl;
|
||||
DebugManager::getInstance().printDebugMessage(name, msg.str());
|
||||
|
||||
weakCells[i].flipped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void errorModel::refresh(unsigned int row)
|
||||
{
|
||||
// A refresh is internally composed of ACT and PRE that are executed
|
||||
@@ -227,29 +263,14 @@ void errorModel::refresh(unsigned int row)
|
||||
|
||||
void errorModel::activate(unsigned int row)
|
||||
{
|
||||
// Check wich bits have flipped during the last access and mark them as flipped:
|
||||
markBitFlips();
|
||||
|
||||
// The Activate command is responsible that an retention error is manifested.
|
||||
|
||||
// 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);
|
||||
|
||||
// Mark the the first n Bits in the list of weak cells as flipped:
|
||||
for (unsigned int i=0; i<n; i++)
|
||||
{
|
||||
// Check if Bit has marked as flipped yet, if yes mark it as flipped
|
||||
if(weakCells[i].flipped == false)
|
||||
{
|
||||
//std::cout << "Maked weakCell[" << i << "] as flipped" << std::endl;
|
||||
weakCells[i].flipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Flip the bit in the data structure if it is marked as flipped
|
||||
// Therefore, Flip the bit in the data structure if it is marked as flipped
|
||||
// and if it is a one. Transisitons from 0 to 1 are only happening
|
||||
// in DRAM with anticells. This behavior is not implemented yet.
|
||||
for (unsigned int i=0; i<n; i++)
|
||||
for (unsigned int i=0; i < maxNumberOfWeakCells; i++)
|
||||
{
|
||||
if(weakCells[i].flipped == true && weakCells[i].row == row)
|
||||
{
|
||||
@@ -268,7 +289,7 @@ void errorModel::activate(unsigned int row)
|
||||
// Bit position in byte:
|
||||
unsigned int bitInByte = weakCells[i].bit % 8;
|
||||
|
||||
// Check if the bit is 1 (onlue 1->0 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<maxNumberOfWeakCells; i++)
|
||||
{
|
||||
std::cout << "row=" << weakCells[i].row
|
||||
<< "\tcol=" << weakCells[i].col
|
||||
<< "\tbit=" << weakCells[i].bit
|
||||
<< "\tflip=" << weakCells[i].flipped
|
||||
<< "\tdep=" << weakCells[i].dependent << std::endl;
|
||||
std::stringstream msg;
|
||||
msg << "row=" << weakCells[i].row
|
||||
<< " col=" << weakCells[i].col
|
||||
<< " bit=" << weakCells[i].bit
|
||||
<< " flip=" << weakCells[i].flipped
|
||||
<< " dep=" << weakCells[i].dependent;
|
||||
DebugManager::getInstance().printDebugMessage(name, msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,17 +710,19 @@ unsigned int errorModel::getNumberOfFlips(double temp, sc_time time)
|
||||
|
||||
errors e = errorMap[nearestTemperature][nearestTime];
|
||||
|
||||
// Find nearest time:
|
||||
/*
|
||||
std::cout << "ACT/REF temp:" << temp
|
||||
<< " time:" << time
|
||||
<< " nearestTemp:" << nearestTemperature
|
||||
<< " nearestTime:" << nearestTime
|
||||
<< " ind:" << e.independent
|
||||
<< " dep:" << e.dependent << std::endl;
|
||||
*/
|
||||
//std::stringstream msg;
|
||||
//msg << "ACT/REF temp:" << temp
|
||||
// << " time:" << time
|
||||
// << " nearestTemp:" << nearestTemperature
|
||||
// << " nearestTime:" << nearestTime
|
||||
// << " ind:" << e.independent
|
||||
// << " dep:" << e.dependent;
|
||||
|
||||
//DebugManager::getInstance().printDebugMessage(name, msg.str());
|
||||
|
||||
return e.independent + e.dependent;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void errorModel::setContext(DecodedAddress addr)
|
||||
|
||||
@@ -71,6 +71,7 @@ class errorModel
|
||||
// Private Methods:
|
||||
void parseInputData();
|
||||
void prepareWeakCells();
|
||||
void markBitFlips();
|
||||
unsigned int getNumberOfFlips(double temp, sc_time time);
|
||||
void setContext(DecodedAddress addr);
|
||||
unsigned int getBit(DecodedAddress key, unsigned int byte, unsigned int bitInByte);
|
||||
|
||||
Reference in New Issue
Block a user