/* * Configuration.cpp * * Created on: Apr 7, 2014 * Author: jonny */ #include "Configuration.h" #include "ConfigurationLoader.h" #include "boost/lexical_cast.hpp" using namespace std; string Configuration::memspecUri = ""; string Configuration::memconfigUri = ""; Configuration::Configuration() { } int string2bool(string s) { try { bool x = boost::lexical_cast( s ); return x; } catch( boost::bad_lexical_cast const& ) { SC_REPORT_FATAL("Configuration", ("Could not convert to bool: " + s).c_str()); throw; } } int string2int(string s) { try { int x = boost::lexical_cast( s ); return x; } catch( boost::bad_lexical_cast const& ) { SC_REPORT_FATAL("Configuration", ("Could not convert to int: " + s).c_str()); throw; } } EPowerDownMode string2PDNMode(string s) { if(s == "NoPowerDown") return EPowerDownMode::NoPowerDown; else if(s == "Staggered") return EPowerDownMode::Staggered; else if (s == "TimeoutPDN") return EPowerDownMode::TimeoutPDN; else if (s == "TimeoutSREF") return EPowerDownMode::TimeoutSREF; else { SC_REPORT_FATAL("Configuration", ("Unknown PowerDownMode: " + s).c_str()); throw; } } void Configuration::setParameter(std::string name, std::string value) { if(name == "BankwiseLogic") BankwiseLogic = string2bool(value); else if(name == "OpenPagePolicy") OpenPagePolicy = string2bool(value); else if(name == "MaxNrOfTransactions") MaxNrOfTransactions = string2int(value); else if(name == "Scheduler") Scheduler = value; else if(name == "Capsize") Capsize = string2int(value); else if(name == "PowerDownTimeout") powerDownTimeoutInClk = string2int(value); else if(name == "PowerDownMode") PowerDownMode = string2PDNMode(value); else if(name == "Buswidth") Buswidth = string2int(value); else if(name == "ReadWriteGrouping") ReadWriteGrouping = string2bool(value); //removed because of Peters error model TODO clean up! //else if(name == "ModelStorage") // ModelStorage = string2bool(value); //else if(name == "ModelErrorInjection") // ModelErrorInjection = string2bool(value); else if(name == "ReorderBuffer") ReorderBuffer = string2bool(value); //SimConfig------------------------------------------------ else if(name == "DatabaseRecording") DatabaseRecording = string2bool(value); else if(name == "PowerAnalysis") PowerAnalysis = string2bool(value); else if(name == "Debug") Debug = string2bool(value); // Specification for ErrorChipSeed, ErrorCSVFile path and ErrorStoreMode else if(name == "ErrorChipSeed") ErrorChipSeed = string2int(value); else if(name == "ErrorCSVFile") ErrorCSVFile = value; else if(name == "ErrorStoreMode") ErrorStoreMode = StringToEnum(value); else { SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str()); throw; } } void Configuration::setParameters(std::map parameterMap) { for(auto item : parameterMap) { setParameter(item.first, item.second); } }