From 9820ac497fa2f11f93be1a4dc9436653ea15b268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 17 Dec 2015 01:25:23 -0200 Subject: [PATCH] Coherence check for the configuration field NumberofMemChannels. The number of bits reserved to describe the channel within the address determines the maximum number of memory channels allowed. The program will be aborted if the number of memory channels in the configuration exceeds the maximum number of memory channels supported based on the number of bits reserved in the address mapping configuration file. --- .../src/controller/core/configuration/Configuration.cpp | 9 ++++++++- DRAMSys/simulator/src/simulation/Simulation.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 69315241..19d8ca75 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -38,6 +38,7 @@ #include "Configuration.h" #include "ConfigurationLoader.h" #include "boost/lexical_cast.hpp" +#include "../../../common/xmlAddressdecoder.h" using namespace std; @@ -139,8 +140,14 @@ void Configuration::setParameter(std::string name, std::string value) Debug = string2bool(value); else if (name == "NumberOfTracePlayers") NumberOfTracePlayers = string2int(value); - else if (name == "NumberOfMemChannels") + else if (name == "NumberOfMemChannels") { NumberOfMemChannels = string2int(value); + unsigned int maxNumberofMemChannels = xmlAddressDecoder::getInstance().amount["channel"]; + if (NumberOfMemChannels > maxNumberofMemChannels) { + SC_REPORT_FATAL("Configuration", ("Invalid value for parameter " + name + ". Value is out of range. The maximum value according to the address mapping configuration file is " + std::to_string(maxNumberofMemChannels) + ".").c_str()); + throw; + } + } else if (name == "ControllerCoreDisableRefresh") ControllerCoreDisableRefresh = string2bool(value); else if (name == "DynamicTemperatureSimulation") diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index 9b84334b..55bd4c0d 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -57,11 +57,14 @@ Simulation::Simulation(sc_module_name __attribute__((unused)) name, string pathT { SC_THREAD(stop); + // XXX: The xmlAddressDecoder MUST be initialized before calling the + // ConfigurationLoader because some information from the xmlAddressDecoder + // is needed to assure the coherence of the configuration. xmlAddressDecoder::Initialize(setup.addressmapping); xmlAddressDecoder::getInstance().print(); - ConfigurationLoader::loadMemConfig(Configuration::getInstance(), setup.memconfig);//pathToResources + string("configs/memconfigs/") + setup.memconfig); - ConfigurationLoader::loadMemSpec(Configuration::getInstance(), setup.memspec);//pathToResources + string("configs/memspecs/") + setup.memspec); + ConfigurationLoader::loadMemConfig(Configuration::getInstance(), setup.memconfig); + ConfigurationLoader::loadMemSpec(Configuration::getInstance(), setup.memspec); ConfigurationLoader::loadSimConfig(Configuration::getInstance(), setup.simconfig); ConfigurationLoader::loadTemperatureSimConfig(Configuration::getInstance(), setup.temperature_simconfig);