diff --git a/DRAMSys/dramSys/dramSys.pro b/DRAMSys/dramSys/dramSys.pro index a57f7cc7..22c0e37a 100644 --- a/DRAMSys/dramSys/dramSys.pro +++ b/DRAMSys/dramSys/dramSys.pro @@ -68,8 +68,6 @@ SOURCES += \ src/controller/RowBufferStates.cpp \ src/controller/scheduler/IScheduler.cpp \ src/controller/scheduler/FifoStrict.cpp \ - src/error/nest_map.cpp \ - src/error/flip_memory.cpp \ src/error/errormodel.cpp HEADERS += \ @@ -129,7 +127,5 @@ HEADERS += \ src/controller/scheduler/FifoStrict.h \ src/controller/IController.h \ src/controller/core/configuration/ConfigurationLoader.h \ - src/error/nest_map.h \ - src/error/flip_memory.h \ src/error/errormodel.h diff --git a/DRAMSys/dramSys/src/error/error_new.csv b/DRAMSys/dramSys/src/error/error.csv similarity index 96% rename from DRAMSys/dramSys/src/error/error_new.csv rename to DRAMSys/dramSys/src/error/error.csv index 3e8bb6d2..22e0d502 100644 --- a/DRAMSys/dramSys/src/error/error_new.csv +++ b/DRAMSys/dramSys/src/error/error.csv @@ -1,7 +1,7 @@ 75 64 0 0 0 0 80 64 0 0 0 0 85 64 0 0 0 0 -89 64 80 2 20 1 +89 64 0 0 0 0 75 127 0 0 0 0 80 127 0 0 0 0 85 127 0 0 0 0 diff --git a/DRAMSys/dramSys/src/error/flip_memory.cpp b/DRAMSys/dramSys/src/error/flip_memory.cpp deleted file mode 100644 index cd07f346..00000000 --- a/DRAMSys/dramSys/src/error/flip_memory.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 2015, University of Kaiserslautern - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: - * Matthias Jung - * Patrick Andres - * Peter Ehses - */ - -#include "flip_memory.h" -#include -// Console out -#include -#include -// String conversion (debugging) -#include -#include -#include - -#include "../common/third_party/DRAMPower/src/MemorySpecification.h" -#include "../common/third_party/DRAMPower/src/MemCommand.h" -#include "../controller/core/configuration/Configuration.h" - - -using namespace std; - -void flip_memory::setBank(unsigned int b) -{ - accordingBank = b; -} - -flip_memory::flip_memory() -{ - // Initialize Random generator with current system time - // Only do this once in a simulation - //srand(time(NULL)); - srand(Configuration::getInstance().ErrorChipSeed); // ErrorChipSeed constant, so that errors allways at the same address - - // Fixed values for development process - TEMPERATURE = 90; - - // Initialize number of bit errors - BIT_ERR = 0; - - // path of csv file - errormap = new nest_map(Configuration::getInstance().ErrorCSVFile); - - // Constants for address calculations - ROWS_PER_BANK = Configuration::getInstance().memSpec.NumberOfRows; //8192 - COLS_PER_ROW = Configuration::getInstance().memSpec.NumberOfColumns; //changed later to variable 128 - BYTES_PER_COL = 16; //TODO changed later to variable, wie genau, mit config file oder im programm selbst - BITS_PER_ROW = COLS_PER_ROW * BYTES_PER_COL * 8; - - // Fill array with random addresses - initWeakCells(); - - for(unsigned int i = 0; i < ROWS_PER_BANK; i++) - { - refr[i] = SC_ZERO_TIME; - } -} - -flip_memory::~flip_memory() -{ - cout << endl << endl << endl << "Bit-Fehler: " << BIT_ERR << endl << endl << endl; -} - -DecodedAddress flip_memory::getUnifiedNode(unsigned int addr) -{ - DecodedAddress n = xmlAddressDecoder::getInstance().decodeAddress(addr); - n.channel = 0; - n.bank = 0; - return n; -} -//TODO: here get map createt on which address errors will occur, so insert here errormap from board. -// dont forget to delete this line -// Decide which Cells will be weak cells -void flip_memory::initWeakCells() -{ - unsigned int maxWeakCells = errormap->getMaxWeakCells(); - - weakCells = new unsigned int*[maxWeakCells]; - - for (unsigned int i=0; igetMaxDependentCells(); i++) - { - unsigned int r = (rand()%maxWeakCells); - - if(weakCells[r][4] == 1) - { - i--; - } - else - { - weakCells[r][4] = 1; - } - - } - - // Debug - for (unsigned int i=0; igetMaxWeakCells(); - - for (unsigned int i=0; i v; - for (unsigned int n = 0; n < BYTES_PER_COL; n++) v.push_back(*(t_ptr + i + n)); - - // Switch to next column if necessary - if (i > 0) no.column++; - - // Swap around if more columns addressed than exist - if (no.column>(COLS_PER_ROW - 1)) no.column -= BURSTLENGTH*BYTES_PER_COL; - - unsigned int addr = xmlAddressDecoder::getInstance().encodeAddress(no); - //cout << "ADDRESSE=" << addr << endl; - - mem.insert(pair >(addr, v)); - - // Reset weak cells; they have reliable data now till next check - resetCell(no); - } - - //cout << "STORE:" << endl; - //debugMap(); - - trans.set_response_status(TLM_OK_RESPONSE); -} - - -void flip_memory::load(tlm::tlm_generic_payload &trans) -{ - unsigned int t_addr, t_len; - unsigned char* t_ptr; - - t_addr = trans.get_address(); - t_len = trans.get_data_length(); - t_ptr = trans.get_data_ptr(); - - // Generate XML Node - DecodedAddress no; - no = getUnifiedNode(t_addr); - - - if (mem.count(t_addr) > 0) - { - for (unsigned int i = 0; i < t_len; i += BYTES_PER_COL) - { - // Switch to next column if necessary - if (i > 0) no.column++; - - // Swap around if more columns addressed than exist - if (no.column>(COLS_PER_ROW - 1)) no.column -= BURSTLENGTH*BYTES_PER_COL; - - unsigned int addr = xmlAddressDecoder::getInstance().encodeAddress(no); - - // Write out data - for (unsigned int n = 0; n < BYTES_PER_COL; n++) - { - *(t_ptr + i + n) = mem[addr][n]; - } - } - - } - - trans.set_response_status(TLM_OK_RESPONSE); -} - - -// Function to trigger row refresh externally; errors are manifested -void flip_memory::refresh(unsigned int row) -{ - // How many Bits have flipped? - //cout << "TEST=" << refr[row] << endl; - sc_time deltaT = sc_time_stamp() - refr[row]; - - unsigned int n = errormap->getFlipRate(TEMPERATURE, deltaT); - - //cout << sc_time_stamp() << ": deltaT=" << deltaT << " n=" << n << endl; - //cout << "Flip_Memory::refresh" << endl; - // Flip the first n Bits in array - for (unsigned int i=0; i 0) - { - char memBefore = mem[addr][byte]; - //cout << "Flip1?" << endl; - - if(getBit(no.row,no.column,byte,bit) == 1) // flip only if it is really a one - { - //cout << "Flip2?" << endl; - if(weakCells[i][4] == 1) // data dependent weak cell - { - // 0 1 2 - // 3 4 5 - // 6 7 8 - - unsigned int grid[9]; - - grid[0] = getBit(no.row-1,no.column,byte,bit-1); - grid[1] = getBit(no.row-1,no.column,byte,bit ); - grid[2] = getBit(no.row-1,no.column,byte,bit+1); - - grid[3] = getBit(no.row ,no.column,byte,bit-1); - grid[4] = getBit(no.row ,no.column,byte,bit ); - grid[5] = getBit(no.row ,no.column,byte,bit+1); - - grid[6] = getBit(no.row+1,no.column,byte,bit-1); - grid[7] = getBit(no.row+1,no.column,byte,bit ); - grid[8] = getBit(no.row+1,no.column,byte,bit+1); - - unsigned int sum = 0; - for(int s = 0; s < 9; s++) - { - sum += grid[s]; - } - - if(sum <= 4) - { - mem[addr][byte] &= mask; - weakCells[i][3] = 1; - cout << sc_time_stamp() << ": Bit flipped dependent at address=" << addr << " in byte=" << byte << "sum=" << sum << endl; - cout << grid[0] << grid[1] << grid[2] < -#include -#include "../common/xmlAddressdecoder.h" -#include "../common/third_party/DRAMPower/src/MemorySpecification.h" -#include "../common/third_party/DRAMPower/src/MemCommand.h" -#include "../controller/core/configuration/Configuration.h" - - -using namespace tlm; -using namespace std; - -class flip_memory -{ - private: - // Remember to adjust this value by hand when editing in simulation - unsigned int BUSWIDTH = Configuration::getInstance().memSpec.BusWidth; //static const unsigned int BUSWIDTH=128; - unsigned int BURSTLENGTH = Configuration::getInstance().memSpec.BurstLength; //static const unsigned int BURSTLENGTH = 2; but in wideIO.xml its 4 - - nest_map *errormap; - map > mem; - map refr; - unsigned int **weakCells; - - // This will be an input from ICE 3D - unsigned int TEMPERATURE; - - unsigned int ROWS_PER_BANK; - unsigned int COLS_PER_ROW; - unsigned int BYTES_PER_COL; - unsigned int BITS_PER_ROW; - unsigned int accordingBank; - - // Generates an XML node which is tied to one memory class instance - DecodedAddress getUnifiedNode(unsigned int addr); - - // Decide randomly which cells are weak - void initWeakCells(); - - // Reset "HasFlipped"-Flag, set Refresh-Timestamp - void resetCell(DecodedAddress n); - - public: - // Compute number of generated bit errors - unsigned int BIT_ERR; - - flip_memory(); - ~flip_memory(); - void setBank(unsigned int b); - void store(tlm::tlm_generic_payload &trans); - void load(tlm::tlm_generic_payload &trans); - // Trigger row refresh externally; errors are manifested - void refresh(unsigned int row); - unsigned int getBit(int r, int c, int y, int b); - - void debugMap() - { - typedef map >::const_iterator MapIterator; - for (MapIterator iter = mem.begin(); iter != mem.end(); iter++) - { - cout << "Key: " << iter->first << endl << "Values: 0x"; - typedef vector::const_iterator vectorIterator; - for (vectorIterator list_iter = iter->second.begin(); list_iter != iter->second.end(); list_iter++) - { - cout << " " << hex << int(*list_iter); - } - cout << endl; - } - } - -}; -#endif diff --git a/DRAMSys/dramSys/src/error/nest_map.cpp b/DRAMSys/dramSys/src/error/nest_map.cpp deleted file mode 100644 index 8355c684..00000000 --- a/DRAMSys/dramSys/src/error/nest_map.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2015, University of Kaiserslautern - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: - * Matthias Jung - * Patrick Andres - * Peter Ehses - */ - -#include "nest_map.h" -#include -#include -#include - -nest_map::nest_map(string fn) -{ - initMap(fn); -} - -nest_map::~nest_map(void) -{ - delete tr; -} - -// Read data from CSV file with filename "fn" and store it inside the errormap instance -void nest_map::initMap(string fn) -{ - unsigned int noOfLines = 0; - maxWeakCells = 0; - maxDependentCells=0; - string line; - - ifstream input; - input.open(fn.c_str(), ios::in); - - if (input.is_open()) - { - // Count number of entries in CSV file - while (getline(input, line)) - { - ++noOfLines; - } - input.clear(); - input.seekg(0, ios::beg); - - // Knowing the size, allocate the errormap - size = noOfLines; - tr = new quadrupel[noOfLines]; - - // Copy entries from CSV to errormap - for (unsigned int i = 0; i < noOfLines; i++) - { - getline(input, line); - - // "split" returns a matrix with 6 columns with temperature, retention time, number of data indipendent errors, sigma, number of data dependent errors, sigma (this order) - vector tmp = split(line, *","); - - tr[i].T = atoi(tmp[0].c_str()); - // Don't forget to set right unit for times from CSV here - tr[i].t = sc_time(atoi(tmp[1].c_str()), SC_MS); - - double mean = atoi(tmp[2].c_str()); - - double sigma = atoi(tmp[3].c_str()); //(mean/100)*1.5 saved in csv file - - unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); - - std::default_random_engine generator(seed); - std::normal_distribution distribution(mean,sigma); - - tr[i].n = ceil(distribution(generator)); //calculate normal distribution of # of independent errors - - double mean2 = atoi(tmp[4].c_str()); //data dependent errors from file reading - double sigma2 = atoi(tmp[5].c_str()); //(mean/100)*3 from csv file - std::default_random_engine generator2(seed); - std::normal_distribution distribution2(mean2,sigma2); - tr[i].d = ceil(distribution2(generator2)); // calculate normal distribution of # of dependent errors - - //print normal distribution of csv file - //cout << "T=\t" << tr[i].T << "\t t=" << tr[i].t << "\t n=" << tr[i].n << "\t s=" << sigma << "\t d=" << tr[i].d << "\t s=" << sigma2 << endl; - - // Search the largest entry of n in list - if ((tr[i].n + tr[i].d)> maxWeakCells) - { - maxWeakCells = (tr[i].n + tr[i].d); - } - - if (tr[i].d > maxDependentCells) - { - maxDependentCells = tr[i].d; - } - } - - input.close(); - } - else cout << "Fehler beim Oeffnen der Daten" << endl; -} - - -// Retrieve number of flipping bits which fits best to temperature input and time since last refresh -unsigned int nest_map::getFlipRate(unsigned int T_in, sc_time t_in) -{ - unsigned int temperatureClosest = 0; - unsigned int noOfWeakCells = 0; - sc_time timeLowerBound = sc_time(0,SC_SEC); - - // Search all entries in LUT for temperature closest to T_in - for (unsigned int i = 0; i < size; i++) - { - if (abs((double)tr[i].T-(double)T_in) timeLowerBound.value()) && (t_in.value() >= tr[i].t.value())) - { - timeLowerBound = tr[i].t; - noOfWeakCells = tr[i].n + tr[i].d; - } - } - } - return noOfWeakCells; -} - - -unsigned int nest_map::getMaxWeakCells() -{ - return maxWeakCells; -} - -unsigned int nest_map::getMaxDependentCells() -{ - return maxDependentCells; -} - - - -// Remove all spaces out of a string and split it at every occurance of char c -vector nest_map::split(string str, char c) -{ - vector tmp_v; - string tmp_str = str; - - // Remove spaces - while (true) - { - size_t posSpace = tmp_str.find_first_of(" "); - if (posSpace == string::npos) - { - break; - } - tmp_str.erase(posSpace, 1); - } - - // Split string at every occurance of char c - while (true) - { - size_t pos_del = tmp_str.find_first_of(c); - if (pos_del == string::npos) - { - tmp_v.push_back(tmp_str); - break; - } - - tmp_v.push_back(tmp_str.substr(0, pos_del)); - tmp_str.erase(0, pos_del + 1); - } - - return tmp_v; -} diff --git a/DRAMSys/dramSys/src/error/nest_map.h b/DRAMSys/dramSys/src/error/nest_map.h deleted file mode 100644 index 2b1f1047..00000000 --- a/DRAMSys/dramSys/src/error/nest_map.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2015, University of Kaiserslautern - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: - * Matthias Jung - * Patrick Andres - * Peter Ehses - */ - -#ifndef _NEST_MAP_H -#define _NEST_MAP_H - -#include -#include -#include -#include -#include -#include - -using namespace std; - -class nest_map -{ - private: - // Helper class to store 6 values of temperature, (retention) time, # of independent errors, sigma, # of dependent errors, sigma - struct quadrupel - { - unsigned int T; //Temperature - sc_time t; //retention time - unsigned int n; //data independent errors - unsigned int d; //data dependent errors - }; - - // Array of "6 values" with dynamic size - quadrupel *tr; - - // Number of entrys in tr[] - unsigned int size; - - // Largest value of n in tr[] - unsigned int maxWeakCells; - unsigned int maxDependentCells; - - // Default CSV filename - const string def_fn; - - void initMap(string fn); - vector split(string str, char c); - - public: - nest_map(string fn); - ~nest_map(); - - // Retrieve number of flipping bits which fits best to temperature input and time since last refresh - unsigned int getFlipRate(unsigned int T, sc_time t); - - unsigned int getMaxWeakCells(); - unsigned int getMaxDependentCells(); -}; -#endif