From 803c2845c22f7817cee6f42ce5ceb271ef040392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 9 Nov 2016 18:10:42 +0100 Subject: [PATCH] Function to get the number of bytes in a burst --- .../controller/core/configuration/Configuration.cpp | 13 ++++++++++++- .../controller/core/configuration/Configuration.h | 1 + DRAMSys/simulator/src/simulation/Dram.h | 5 +---- DRAMSys/simulator/src/simulation/StlPlayer.cpp | 3 +-- DRAMSys/simulator/src/simulation/StlPlayer.h | 1 - 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index ea6cb130..b132f283 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -36,6 +36,8 @@ * Felipe S. Prado */ +#include + #include "Configuration.h" #include "ConfigurationLoader.h" #include "boost/lexical_cast.hpp" @@ -240,7 +242,7 @@ unsigned int Configuration::getSimMemSizeInBytes() 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; - + assert(memorySize > 0); return memorySize; } @@ -254,3 +256,12 @@ unsigned int Configuration::getDataBusWidth() return dataBusWidth; } +// Returns the number of bytes in a burst +unsigned int Configuration::getBytesPerBurst() +{ + // First multiply to get the number of bits in a burst, then divide by 8 to get the value in bytes. The order is important. Think on a single x4 device. + unsigned int bytesPerBurst = (memSpec.BurstLength * getDataBusWidth()) / 8; + assert(bytesPerBurst > 0); + return bytesPerBurst; +} + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 49c32d98..f2a7a463 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -102,6 +102,7 @@ struct Configuration unsigned int getSimMemSizeInBytes(); unsigned int getDataBusWidth(); + unsigned int getBytesPerBurst(); private: Configuration(); diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index a6acf28e..de376ed6 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -65,10 +65,7 @@ using namespace Data; struct Dram : sc_module { - unsigned int burstLength = Configuration::getInstance().memSpec.BurstLength; - unsigned int dataBusWidth = Configuration::getInstance().getDataBusWidth(); - // First multiply to get the number of bits in a burst, then divide by 8 to get the value in bytes (the order is important. Think on a single x4 device) - unsigned int bytesPerBurst = (burstLength * dataBusWidth) / 8; + unsigned int bytesPerBurst = Configuration::getInstance().getBytesPerBurst(); // TLM Related: tlm_utils::simple_target_socket tSocket; diff --git a/DRAMSys/simulator/src/simulation/StlPlayer.cpp b/DRAMSys/simulator/src/simulation/StlPlayer.cpp index 67b09f92..2ed2dd5f 100644 --- a/DRAMSys/simulator/src/simulation/StlPlayer.cpp +++ b/DRAMSys/simulator/src/simulation/StlPlayer.cpp @@ -46,8 +46,7 @@ StlPlayer::StlPlayer(sc_module_name, string pathToTrace, sc_time playerClk, Trac this->playerClk = playerClk; this->burstlength = Configuration::getInstance().memSpec.BurstLength; - this->bytesPerColumn = xmlAddressDecoder::getInstance().amount["bytes"]; - this->dataLength = bytesPerColumn * burstlength; + this->dataLength = Configuration::getInstance().getBytesPerBurst(); this->lineCnt = 0; } diff --git a/DRAMSys/simulator/src/simulation/StlPlayer.h b/DRAMSys/simulator/src/simulation/StlPlayer.h index 4f905a55..b27463bc 100644 --- a/DRAMSys/simulator/src/simulation/StlPlayer.h +++ b/DRAMSys/simulator/src/simulation/StlPlayer.h @@ -58,7 +58,6 @@ private: unsigned int lineCnt; unsigned int burstlength; - unsigned int bytesPerColumn; unsigned int dataLength; sc_time playerClk; // May be different from from the memory clock! };