Function to get the mem. size in bytes
This commit is contained in:
@@ -226,3 +226,21 @@ void Configuration::setParameters(std::map<std::string, std::string> parameterMa
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the total memory size in bytes
|
||||
unsigned int Configuration::getSimMemSizeInBytes()
|
||||
{
|
||||
// 1. Get number of banks, rows, columns and data width in bits for one die (or chip)
|
||||
unsigned int banks = memSpec.NumberOfBanks;
|
||||
unsigned int rows = memSpec.NumberOfRows;
|
||||
unsigned int columns = memSpec.NumberOfColumns;
|
||||
unsigned int bitWidth = memSpec.bitWidth;
|
||||
// 2. Calculate size of one DRAM chip in bits
|
||||
unsigned int chipBitSize = banks * rows * columns * bitWidth;
|
||||
// 3. Calculate size of one DRAM chip in bytes
|
||||
unsigned int chipSize = chipBitSize / 8;
|
||||
// 4. Total memory size in Bytes of one DIMM (with only support of 1 rank on a DIMM)
|
||||
unsigned int memorySize = chipSize * NumberOfDevicesOnDIMM;
|
||||
|
||||
return memorySize;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,8 @@ struct Configuration
|
||||
// Temperature Simulation related
|
||||
TemperatureSimConfig temperatureSim;
|
||||
|
||||
unsigned int getSimMemSizeInBytes();
|
||||
|
||||
private:
|
||||
Configuration();
|
||||
unsigned int powerDownTimeoutInClk = 3;
|
||||
|
||||
@@ -98,19 +98,7 @@ struct Dram : sc_module
|
||||
|
||||
SC_CTOR(Dram) : tSocket("socket")
|
||||
{
|
||||
// calculate memory size (in Bytes)
|
||||
// 1. Get number of banks, rows, columns and data width in bits
|
||||
unsigned int banks = Configuration::getInstance().memSpec.NumberOfBanks;
|
||||
unsigned int rows = Configuration::getInstance().memSpec.NumberOfRows;
|
||||
unsigned int columns = Configuration::getInstance().memSpec.NumberOfColumns;
|
||||
unsigned int bitWidth = Configuration::getInstance().memSpec.bitWidth;
|
||||
// 2. Calculate size of one DRAM chip in bits
|
||||
unsigned int chipBitSize = banks * rows * columns * bitWidth;
|
||||
// 3. Calculate size of one DRAM chip in bytes
|
||||
unsigned int chipSize = chipBitSize / 8;
|
||||
// 4. Total memory size in Bytes of one DIMM (with only support of 1 rank on a DIMM)
|
||||
unsigned int memorySize = chipSize * Configuration::getInstance().NumberOfDevicesOnDIMM;
|
||||
|
||||
unsigned int memorySize = Configuration::getInstance().getSimMemSizeInBytes();
|
||||
// allocate and model storage of one DRAM channel using memory map
|
||||
memory = (unsigned char *)mmap(NULL, memorySize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user