diff --git a/dram/dramSys/dramSys.pro b/dram/dramSys/dramSys.pro
index d4ccf183..2a6a23bb 100644
--- a/dram/dramSys/dramSys.pro
+++ b/dram/dramSys/dramSys.pro
@@ -72,7 +72,9 @@ SOURCES += \
../src/controller/ControllerState.cpp \
../src/controller/RowBufferStates.cpp \
../src/controller/scheduler/IScheduler.cpp \
- ../src/controller/scheduler/FifoStrict.cpp
+ ../src/controller/scheduler/FifoStrict.cpp \
+ ../src/error/nest_map.cpp \
+ ../src/error/flip_memory.cpp
HEADERS += \
../src/common/third_party/tinyxml2.h \
@@ -128,6 +130,8 @@ HEADERS += \
../src/controller/core/powerdown/IPowerDownManager.h \
../src/controller/scheduler/IScheduler.h \
../src/controller/scheduler/FifoStrict.h \
- ../src/controller/IController.h
- ../src/controller/core/configuration/ConfigurationLoader.h
+ ../src/controller/IController.h \
+ ../src/controller/core/configuration/ConfigurationLoader.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 781f4d1e..76d14bac 100755
--- a/dram/resources/configs/amconfigs/am_wideio.xml
+++ b/dram/resources/configs/amconfigs/am_wideio.xml
@@ -1,4 +1,3 @@
-
@@ -6,4 +5,14 @@
+
+
diff --git a/dram/resources/configs/memconfigs/fifo.xml b/dram/resources/configs/memconfigs/fifo.xml
index 35395479..094a261e 100644
--- a/dram/resources/configs/memconfigs/fifo.xml
+++ b/dram/resources/configs/memconfigs/fifo.xml
@@ -1,9 +1,13 @@
-
-
+
+
-
+
+
+
+
+
diff --git a/dram/resources/configs/memconfigs/fifoStrict.xml b/dram/resources/configs/memconfigs/fifoStrict.xml
index 35395479..64424430 100644
--- a/dram/resources/configs/memconfigs/fifoStrict.xml
+++ b/dram/resources/configs/memconfigs/fifoStrict.xml
@@ -1,9 +1,13 @@
-
+
+
+
+
+
diff --git a/dram/resources/configs/memconfigs/fr_fcfs.xml b/dram/resources/configs/memconfigs/fr_fcfs.xml
index d2605c7e..546b3223 100644
--- a/dram/resources/configs/memconfigs/fr_fcfs.xml
+++ b/dram/resources/configs/memconfigs/fr_fcfs.xml
@@ -6,11 +6,16 @@
+
+
+
+
-
\ No newline at end of file
+
diff --git a/dram/src/common/xmlAddressdecoder.cpp b/dram/src/common/xmlAddressdecoder.cpp
index 7cb20b4a..1fb7aa26 100644
--- a/dram/src/common/xmlAddressdecoder.cpp
+++ b/dram/src/common/xmlAddressdecoder.cpp
@@ -60,6 +60,17 @@ DecodedAddress xmlAddressDecoder::decodeAddress(sc_dt::uint64 addr)
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"];
+}
+
void xmlAddressDecoder::print()
{
cout << "Used addressmapping:" << endl;
diff --git a/dram/src/common/xmlAddressdecoder.h b/dram/src/common/xmlAddressdecoder.h
index 29823346..383e436c 100755
--- a/dram/src/common/xmlAddressdecoder.h
+++ b/dram/src/common/xmlAddressdecoder.h
@@ -54,6 +54,8 @@ static tinyxml2::XMLElement* addressmapping;
}
DecodedAddress decodeAddress(sc_dt::uint64 addr);
+ sc_dt::uint64 encodeAddress(DecodedAddress n);
+
void print();
private:
diff --git a/dram/src/controller/core/configuration/Configuration.cpp b/dram/src/controller/core/configuration/Configuration.cpp
index 5d46c639..d073900c 100644
--- a/dram/src/controller/core/configuration/Configuration.cpp
+++ b/dram/src/controller/core/configuration/Configuration.cpp
@@ -78,10 +78,11 @@ void Configuration::setParameter(std::string name, std::string value)
Buswidth = string2int(value);
else if(name == "ReadWriteGrouping")
ReadWriteGrouping = string2bool(value);
- else if(name == "ModelStorage")
- ModelStorage = string2bool(value);
- else if(name == "ModelErrorInjection")
- ModelErrorInjection = string2bool(value);
+ //removed because of Peters error model TODO clean up!
+ //else if(name == "ModelStorage")
+ // ModelStorage = string2bool(value);
+ //else if(name == "ModelErrorInjection")
+ // ModelErrorInjection = string2bool(value);
else if(name == "ReorderBuffer")
ReorderBuffer = string2bool(value);
@@ -92,6 +93,13 @@ void Configuration::setParameter(std::string name, std::string value)
PowerAnalysys = string2bool(value);
else if(name == "Debug")
Debug = string2bool(value);
+ //Specification for Chipseed, csvfile path and StorageMode
+ else if(name == "Chipseed")
+ Chipseed = string2int(value);
+ else if(name == "csvfile")
+ csvfile = value;
+ else if(name == "StorMo")
+ StorMode = string2int(value);
else
{
SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str());
diff --git a/dram/src/controller/core/configuration/Configuration.h b/dram/src/controller/core/configuration/Configuration.h
index 5383dbdb..3a5b15d4 100644
--- a/dram/src/controller/core/configuration/Configuration.h
+++ b/dram/src/controller/core/configuration/Configuration.h
@@ -51,6 +51,11 @@ struct Configuration
void setParameter(std::string name, std::string value);
void setParameters(std::map parameterMap);
+ //Configs for Seed, csv file and StorageMode
+ unsigned int Chipseed;
+ std::string csvfile ="not defined.";
+ unsigned int StorMode;
+
private:
Configuration();
unsigned int powerDownTimeoutInClk = 3;
diff --git a/dram/src/controller/core/configuration/ConfigurationLoader.cpp b/dram/src/controller/core/configuration/ConfigurationLoader.cpp
index aaa4e4aa..897a1b2b 100644
--- a/dram/src/controller/core/configuration/ConfigurationLoader.cpp
+++ b/dram/src/controller/core/configuration/ConfigurationLoader.cpp
@@ -47,7 +47,6 @@ void ConfigurationLoader::loadConfig(Configuration& config, XMLElement* configNo
void ConfigurationLoader::loadMemSpec(Configuration& config, string memspecUri)
{
tinyxml2::XMLDocument doc;
-
loadXML(memspecUri, doc);
XMLElement* memspec = doc.FirstChildElement("memspec");
loadMemSpec(config, memspec);
@@ -114,6 +113,7 @@ void ConfigurationLoader::loadDDR4(Configuration& config, XMLElement* memspec)
config.memSpec.DataRate = queryUIntParameter(architecture, "dataRate");
config.memSpec.NumberOfRows = queryUIntParameter(architecture, "nbrOfRows");
config.memSpec.NumberOfColumns = queryUIntParameter(architecture, "nbrOfColumns");
+ config.memSpec.BusWidth = queryUIntParameter(architecture, "width");
//MemTimings
XMLElement* timings = memspec->FirstChildElement("memtimingspec");
@@ -165,6 +165,7 @@ void ConfigurationLoader::loadWideIO(Configuration& config, XMLElement* memspec)
config.memSpec.DataRate = queryUIntParameter(architecture, "dataRate");
config.memSpec.NumberOfRows = queryUIntParameter(architecture, "nbrOfRows");
config.memSpec.NumberOfColumns = queryUIntParameter(architecture, "nbrOfColumns");
+ config.memSpec.BusWidth = queryUIntParameter(architecture, "width");
//MemTimings
XMLElement* timings = memspec->FirstChildElement("memtimingspec");
diff --git a/dram/src/controller/core/configuration/MemSpec.h b/dram/src/controller/core/configuration/MemSpec.h
index ddbfc9b6..3412c38c 100644
--- a/dram/src/controller/core/configuration/MemSpec.h
+++ b/dram/src/controller/core/configuration/MemSpec.h
@@ -53,6 +53,7 @@ struct MemSpec
unsigned int DataRate;
unsigned int NumberOfRows;
unsigned int NumberOfColumns;
+ unsigned int BusWidth;
sc_time clk;
sc_time tRP; //precharge-time (pre -> act same bank)
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
new file mode 100644
index 00000000..adeeb580
--- /dev/null
+++ b/dram/src/error/flip_memory.cpp
@@ -0,0 +1,402 @@
+/*
+ * 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;
+
+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().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;
+
+ // path of csv file
+ errormap = new nest_map(Configuration::getInstance().csvfile);
+
+ // 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