AdjustNumBytesAfterECC function added and used in DRAM.h and errormodel.h

This commit is contained in:
Johannes Feldmann
2017-06-21 10:03:56 +02:00
parent efbc723bab
commit d2ea359b50
6 changed files with 29 additions and 35 deletions

View File

@@ -324,3 +324,15 @@ unsigned int Configuration::getBytesPerBurst()
return bytesPerBurst;
}
// Changes the number of bytes depeding on the ECC Controller. This function is needed for modules which get data directly or indirectly from the ECC Controller
unsigned int Configuration::adjustNumBytesAfterECC(unsigned nBytes)
{
// Manipulate the number of bytes only if there is an ECC Controller selected
if(ECCMode == ECCControllerMode::Disabled)
return nBytes;
else
{
assert(pECC != nullptr);
return pECC->AllocationSize(nBytes);
}
}

View File

@@ -45,6 +45,8 @@
#include "thermalSimConfig.h"
#include "../../../common/Utils.h"
#include "../../../error/eccbaseclass.h"
enum class StorageMode{NoStorage, Store, ErrorModel};
enum class EPowerDownMode{NoPowerDown, Staggered, TimeoutPDN, TimeoutSREF};
@@ -84,6 +86,7 @@ struct Configuration
unsigned int NumberOfDevicesOnDIMM = 1;
bool CheckTLM2Protocol = false;
ECCControllerMode ECCMode = ECCControllerMode::Disabled;
ECCBaseClass* pECC = nullptr;
bool gem5 = false;
unsigned long long int AddressOffset = 0;
@@ -104,6 +107,7 @@ struct Configuration
std::uint64_t getSimMemSizeInBytes();
unsigned int getDataBusWidth();
unsigned int getBytesPerBurst();
unsigned int adjustNumBytesAfterECC(unsigned bytes);
void setPathToResources(std::string path);
std::string getPathToResources();

View File

@@ -48,18 +48,6 @@ void ECCHamming::Encode(const unsigned char* pDataIn, const unsigned nDataIn, un
// Save hamming code + parity bit in the last byte
codeword.Copy(&pDataOut[i*(m_nDatawordSize + m_nCodewordSize)+m_nDatawordSize]);
}
cout << "Encode:\r\n";
for(unsigned i = 0; i < nDataIn; i++)
{
cout << setw(2) << setfill('0') << hex << uppercase << (int)pDataIn[i];
}
cout << endl;
for(unsigned i = 0; i < nDataOut; i++)
{
cout << setw(2) << setfill('0') << hex << uppercase << (int)pDataOut[i];
}
cout << endl << endl;
}
void ECCHamming::Decode(const unsigned char* pDataIn, const unsigned nDataIn, unsigned char* pDataOut, const unsigned nDataOut)
@@ -88,9 +76,7 @@ void ECCHamming::Decode(const unsigned char* pDataIn, const unsigned nDataIn, un
ECC::InsertCheckbits(dataword, codeword);
ECC::InsertParityBit(dataword, codeword[7]);
dataword.Print();
// Reset codeword
// Reset codeword
codeword = 0;
// Calculate Checkbits again
@@ -145,16 +131,4 @@ void ECCHamming::Decode(const unsigned char* pDataIn, const unsigned nDataIn, un
// Copy data
memcpy(&pDataOut[i*m_nDatawordSize], &pDataIn[i*(m_nDatawordSize + m_nCodewordSize)], m_nDatawordSize);
}
cout << "Decode:\r\n";
for(unsigned i = 0; i < nDataIn; i++)
{
cout << setw(2) << setfill('0') << hex << uppercase << (int)pDataIn[i];
}
cout << endl;
for(unsigned i = 0; i < nDataOut; i++)
{
cout << setw(2) << setfill('0') << hex << uppercase << (int)pDataOut[i];
}
cout << endl << endl;
}

View File

@@ -50,10 +50,8 @@ void errorModel::init()
numberOfColumns = Configuration::getInstance().memSpec.NumberOfColumns;
bytesPerColumn = xmlAddressDecoder::getInstance().amount["bytes"];
if(Configuration::getInstance().ECCMode != ECCControllerMode::Disabled)
{
bytesPerColumn += bytesPerColumn>>3;
}
// Adjust number of bytes per column dynamically to the selected ecc controller
bytesPerColumn = Configuration::getInstance().adjustNumBytesAfterECC(bytesPerColumn);
numberOfRows = Configuration::getInstance().memSpec.NumberOfRows;
numberOfBitErrorEvents = 0;

View File

@@ -60,7 +60,7 @@ DRAMSys::DRAMSys(sc_module_name __attribute__((unused)) name,
string pathToResources) : tSocket("DRAMSys_tSocket")
{
// Initialize ecc pointer
ecc = 0;
ecc = nullptr;
logo();
@@ -196,13 +196,18 @@ void DRAMSys::instantiateModules(const string &traceName,
ecc = new ECCHamming("ECCHamming");
break;
default:
ecc = 0;
ecc = nullptr;
break;
}
// Save ECC Controller into the configuration struct to adjust it dynamically
Configuration::getInstance().pECC = ecc;
// Create arbiter
arbiter = new Arbiter("arbiter");
arbiter->setTlmRecorders(tlmRecorders);
// Create DRAM
for (size_t i = 0;
i < Configuration::getInstance().NumberOfMemChannels;
i++)
@@ -232,6 +237,7 @@ void DRAMSys::bindSockets()
// If ECC Controller enabled, put it between Trace and arbiter
if(Configuration::getInstance().ECCMode != ECCControllerMode::Disabled)
{
assert(ecc != nullptr);
tSocket.bind(ecc->t_socket);
ecc->i_socket.bind(arbiter->tSocket);
}

View File

@@ -92,8 +92,8 @@ struct Dram : sc_module
SC_CTOR(Dram) : tSocket("socket")
{
if(Configuration::getInstance().ECCMode != ECCControllerMode::Disabled)
bytesPerBurst += bytesPerBurst>>3;
// Adjust number of bytes per burst dynamically to the selected ecc controller
bytesPerBurst = Configuration::getInstance().adjustNumBytesAfterECC(bytesPerBurst);
std::uint64_t memorySize = Configuration::getInstance().getSimMemSizeInBytes();
// allocate and model storage of one DRAM channel using memory map