Recalculate memory size, that take into account of bus width & #chips on a DIMM

This commit is contained in:
Thanh Tran
2016-11-08 00:04:00 +01:00
parent c28c996271
commit 701152e0af

View File

@@ -66,6 +66,8 @@ using namespace Data;
struct Dram : sc_module
{
unsigned int burstLength = Configuration::getInstance().memSpec.BurstLength;
// All DRAM chips on a DIMM operate in lockstep,
// which constituing aggregate data bus width = chip's bus width * # locksteep-operated chips
unsigned int busWidth = Configuration::getInstance().memSpec.BusWidth * Configuration::getInstance().NumberOfDevicesOnDIMM;
unsigned int bytesPerBurst = burstLength * (busWidth / 8);
@@ -94,11 +96,11 @@ struct Dram : sc_module
SC_CTOR(Dram) : tSocket("socket")
{
// calculate memory size
// calculate memory size (in Bytes)
unsigned int banks = Configuration::getInstance().memSpec.NumberOfBanks;
unsigned int rows = Configuration::getInstance().memSpec.NumberOfRows;
unsigned int columns = Configuration::getInstance().memSpec.NumberOfColumns;
unsigned int size = banks * rows * columns;
unsigned int size = banks * rows * columns * (busWidth / 8);
memory = (unsigned char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, -1, 0);
tSocket.register_nb_transport_fw(this, &Dram::nb_transport_fw);