/* * Copyright (c) 2015, University of Kaiserslautern * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: * Janik Schlemminger * Matthias Jung */ #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); 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); } }