diff --git a/dram/dramSys/dramSys.pro b/dram/dramSys/dramSys.pro
index 1b3163b3..35a52edf 100644
--- a/dram/dramSys/dramSys.pro
+++ b/dram/dramSys/dramSys.pro
@@ -68,7 +68,9 @@ SOURCES += \
../src/simulation/main.cpp \
../src/controller/core/RowBufferStates.cpp \
../src/controller/scheduler/Scheduler.cpp \
- ../src/controller/scheduler/readwritegrouper.cpp
+ ../src/controller/scheduler/readwritegrouper.cpp \
+ ../src/error/nest_map.cpp \
+ ../src/error/flip_memory.cpp
HEADERS += \
../src/common/third_party/tinyxml2.h \
@@ -123,5 +125,7 @@ HEADERS += \
../src/controller/core/RowBufferStates.h \
../src/controller/scheduler/readwritegrouper.h \
../src/simulation/ReorderBuffer.h \
- ../src/controller/core/configuration/MemSpec.h
+ ../src/controller/core/configuration/MemSpec.h \
+ ../src/error/nest_map.h \
+ ../src/error/flip_memory.h
diff --git a/dram/resources/configs/amconfigs/am_wideio.xml b/dram/resources/configs/amconfigs/am_wideio.xml
index fc29d918..85ec0876 100755
--- a/dram/resources/configs/amconfigs/am_wideio.xml
+++ b/dram/resources/configs/amconfigs/am_wideio.xml
@@ -10,6 +10,7 @@
-->
+
+
+
+
+
+
+
+
+
+
diff --git a/dram/resources/configs/memconfigs/fr_fcfs.xml b/dram/resources/configs/memconfigs/fr_fcfs.xml
index 8aa70731..0cb3b908 100644
--- a/dram/resources/configs/memconfigs/fr_fcfs.xml
+++ b/dram/resources/configs/memconfigs/fr_fcfs.xml
@@ -7,8 +7,11 @@
-
-
-
+
+
+
+
+
+
diff --git a/dram/src/common/xmlAddressdecoder.cpp b/dram/src/common/xmlAddressdecoder.cpp
index 67eb278c..03aadf0e 100644
--- a/dram/src/common/xmlAddressdecoder.cpp
+++ b/dram/src/common/xmlAddressdecoder.cpp
@@ -40,3 +40,14 @@ DecodedAddress xmlAddressDecoder::decodeAddress(sc_dt::uint64 addr)
result.bytes = (addr & masks["bytes"]) >> shifts["bytes"];
return result;
}
+
+sc_dt::uint64 xmlAddressDecoder::encodeAddress(DecodedAddress n)
+{
+ return n.channel << shifts["channel"] |
+ n.rank << shifts["rank"] |
+ n.bankgroup << shifts["bankgroup"] |
+ n.row << shifts["row"] |
+ n.bank << shifts["bank"] |
+ n.column << shifts["column"] |
+ n.bytes << shifts["bytes"];
+}
diff --git a/dram/src/common/xmlAddressdecoder.h b/dram/src/common/xmlAddressdecoder.h
index 3cd3d6fe..9cb71734 100755
--- a/dram/src/common/xmlAddressdecoder.h
+++ b/dram/src/common/xmlAddressdecoder.h
@@ -47,6 +47,8 @@ public:
}
DecodedAddress decodeAddress(sc_dt::uint64 addr);
+ sc_dt::uint64 encodeAddress(DecodedAddress n);
+
private:
xmlAddressDecoder(std::string URI);
diff --git a/dram/src/controller/core/configuration/Configuration.h b/dram/src/controller/core/configuration/Configuration.h
index feefaf3b..609671e6 100644
--- a/dram/src/controller/core/configuration/Configuration.h
+++ b/dram/src/controller/core/configuration/Configuration.h
@@ -46,6 +46,11 @@ struct Configuration
//Simulation Configuration
bool databaseRecordingEnabled = true;
+ //Configs for Seed, csv file and StorageMode
+ unsigned int Chipseed;
+ std::string csvfile ="not defined.";
+ unsigned int StorMode;
+
private:
Configuration();
};
diff --git a/dram/src/controller/core/configuration/MemSpec.h b/dram/src/controller/core/configuration/MemSpec.h
index 9a47ce35..87e29b40 100644
--- a/dram/src/controller/core/configuration/MemSpec.h
+++ b/dram/src/controller/core/configuration/MemSpec.h
@@ -51,6 +51,7 @@ struct MemSpec
unsigned int nActivate;
unsigned int DataRate;
unsigned int NumberOfRows;
+ unsigned int NumberOfColumns;
sc_time clk;
sc_time tRP; //precharge-time (pre -> act same bank)
diff --git a/dram/src/controller/core/configuration/MemSpecLoader.cpp b/dram/src/controller/core/configuration/MemSpecLoader.cpp
index de3fd88a..44cc5b97 100644
--- a/dram/src/controller/core/configuration/MemSpecLoader.cpp
+++ b/dram/src/controller/core/configuration/MemSpecLoader.cpp
@@ -56,6 +56,12 @@ void MemSpecLoader::loadMemConfig(Configuration& config, XMLElement* memconfig)
config.powerDownTimeout = queryUIntParameter(configuration, "powerDownTimeout") * config.memSpec.clk;
config.databaseRecordingEnabled = queryBoolParameter(configuration, "databaseRecordingEnabled");
+
+ //Specification for Chipseed, csvfile path and StorageMode
+ config.Chipseed = queryUIntParameter(configuration, "Chipseed");
+ config.csvfile = queryStringParameter(configuration, "csvfile");
+ config.StorMode = queryUIntParameter(configuration, "StorMo");
+
}
void MemSpecLoader::loadMemSpec(Configuration& config, XMLElement* memspec)
@@ -88,6 +94,7 @@ void MemSpecLoader::loadDDR4(Configuration& config, XMLElement* memspec)
config.memSpec.nActivate = 4;
config.memSpec.DataRate = queryUIntParameter(architecture, "dataRate");
config.memSpec.NumberOfRows = queryUIntParameter(architecture, "nbrOfRows");
+ config.memSpec.NumberOfColumns = queryUIntParameter(architecture, "nbrOfColumns");
//MemTimings
XMLElement* timings = memspec->FirstChildElement("memtimingspec");
@@ -137,6 +144,7 @@ void MemSpecLoader::loadWideIO(Configuration& config, XMLElement* memspec)
config.memSpec.nActivate = 2;
config.memSpec.DataRate = queryUIntParameter(architecture, "dataRate");
config.memSpec.NumberOfRows = queryUIntParameter(architecture, "nbrOfRows");
+ config.memSpec.NumberOfColumns = queryUIntParameter(architecture, "nbrOfColumns");
//MemTimings
XMLElement* timings = memspec->FirstChildElement("memtimingspec");
diff --git a/dram/src/error/error_new.csv b/dram/src/error/error_new.csv
new file mode 100644
index 00000000..7f50ae2c
--- /dev/null
+++ b/dram/src/error/error_new.csv
@@ -0,0 +1,20 @@
+75,127,0,0,0,0
+80,127,0,0,0,0
+85,127,0,0,0,0
+89,127,2,0.03,2,0.06
+75,145,0,0,0,0
+80,145,0,0,0,0
+85,145,0,0,1,0.03
+89,145,13,0.195,3,0.09
+75,164,0,0,0,0
+80,164,0,0,0,0
+85,164,8,0.12,2,0.06
+89,164,24,0.36,4,0.12
+75,182,0,0,0,0
+80,182,0,0,1,0.03
+85,182,16,0.24,2,0.06
+89,182,41,0.615,8,0.24
+75,200,0,0,0,0
+80,200,5,0.075,3,0.09
+85,200,24,0.36,4,0.12
+89,200,67,1.005,15,0.45
diff --git a/dram/src/error/flip_memory.cpp b/dram/src/error/flip_memory.cpp
index 9b2b5071..3662c524 100644
--- a/dram/src/error/flip_memory.cpp
+++ b/dram/src/error/flip_memory.cpp
@@ -1,133 +1,200 @@
+/*
+ * Created on: Juli, 2014
+ * Author: patrick, peter
+ */
+
#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;
+using namespace core;
-flip_memory::flip_memory() {
+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));
-
- // Fixed values for development process
+ //srand(time(NULL));
+ srand(Configuration::getInstance().Chipseed); // Chipseed constant, so that errors allways at the same address
+
+ // Fixed values for development process
TEMPERATURE = 90;
-
+
// Initialize number of bit errors
BIT_ERR = 0;
-
- errormap = new nest_map("errors.csv");
- xade = new xmlAddressDecoder("config.xml");
-
+
+ // path of csv file
+ errormap = new nest_map(Configuration::getInstance().csvfile);
+ //xade = new xmlAddressDecoder("config.xml");
+
// Constants for address calculations
- ROWS_PER_BANK = xade->getRowSize();
- COLS_PER_ROW = xade->getColumSize();
- BYTES_PER_COL = xade->getBytesSize();
+ ROWS_PER_BANK = Configuration::getInstance().memSpec.NumberOfRows; //8192
+ COLS_PER_ROW = Configuration::getInstance().memSpec.NumberOfColumns; //changed later to variable 128
+ BYTES_PER_COL = 16; //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
+
+ // Fill array with random addresses
initWeakCells();
}
-flip_memory::~flip_memory() {
+flip_memory::~flip_memory()
+{
cout << endl << endl << endl << "Bit-Fehler: " << BIT_ERR << endl << endl << endl;
}
-void flip_memory::getUnifiedNode(unsigned int addr, node *n) {
- xade->getNode(addr, n);
- n->channel = 0;
- n->bank = 0;
+DecodedAddress flip_memory::getUnifiedNode(unsigned int addr)
+{
+ DecodedAddress n = xmlAddressDecoder::getInstance().decodeAddress(addr);
+ //xade->getNode(addr, n);
+ n.channel = 0;
+ n.bank = 0;
+ return n;
}
// 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; igetMaxWeakCells();
+
+ 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; igetMaxWeakCells();
- refr[n.row] = sc_time_stamp();
+ 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.colum++;
+ if (i > 0) no.column++;
// Swap around if more columns addressed than exist
- if (no.colum>(COLS_PER_ROW - 1)) no.colum -= BURSTLENGTH*BYTES_PER_COL;
+ if (no.column>(COLS_PER_ROW - 1)) no.column -= BURSTLENGTH*BYTES_PER_COL;
- unsigned int addr = xade->getAddress(&no);
+ 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_generic_payload &trans) {
+void flip_memory::load(tlm::tlm_generic_payload &trans)
+{
unsigned int t_addr, t_len;
unsigned char* t_ptr;
@@ -136,20 +203,21 @@ void flip_memory::load(tlm_generic_payload &trans) {
t_ptr = trans.get_data_ptr();
// Generate XML Node
- node no;
- getUnifiedNode(t_addr, &no);
-
-
+ DecodedAddress no;
+ no = getUnifiedNode(t_addr);
+
+
if (mem.count(t_addr) > 0)
{
- for (unsigned int i = 0; i < t_len; i += BYTES_PER_COL) {
+ for (unsigned int i = 0; i < t_len; i += BYTES_PER_COL)
+ {
// Switch to next column if necessary
- if (i > 0) no.colum++;
+ if (i > 0) no.column++;
// Swap around if more columns addressed than exist
- if (no.colum>(COLS_PER_ROW - 1)) no.colum -= BURSTLENGTH*BYTES_PER_COL;
+ if (no.column>(COLS_PER_ROW - 1)) no.column -= BURSTLENGTH*BYTES_PER_COL;
- unsigned int addr = xade->getAddress(&no);
+ unsigned int addr = xmlAddressDecoder::getInstance().encodeAddress(no);
// Write out data
for (unsigned int n = 0; n < BYTES_PER_COL; n++)
@@ -157,7 +225,7 @@ void flip_memory::load(tlm_generic_payload &trans) {
*(t_ptr + i + n) = mem[addr][n];
}
}
-
+
}
trans.set_response_status(TLM_OK_RESPONSE);
@@ -165,44 +233,166 @@ void flip_memory::load(tlm_generic_payload &trans) {
// Function to trigger row refresh externally; errors are manifested
-void flip_memory::refresh(unsigned int row) {
+void flip_memory::refresh(unsigned int row)
+{
// How many Bits have flipped?
- sc_time deltaT = sc_time_stamp() - refr[row];
- unsigned int n = errormap->getFlipRate(TEMPERATURE, deltaT);
-
- // Flip the first n Bits in array
- for (unsigned int i=0; igetAddress(&no);
- unsigned int byte = weakCells[i][2] / 8; // Byte position in column
- unsigned int bit = weakCells[i][2] % 8; // Bit position in byte
-
- unsigned char mask = pow(2, bit); // 1 Byte long character
- mask = ~mask; // invert mask (only one 0) and AND it later
+ sc_time deltaT = sc_time_stamp() - refr[row];
+
+
+ unsigned int n = errormap->getFlipRate(TEMPERATURE, deltaT);
+
+ //cout << sc_time_stamp() << ": deltaT=" << deltaT << " n=" << n << 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