From 8cabd35b2a1b2ac999d2ea6bed6ccfabc1f8d60c Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Tue, 26 May 2020 21:56:25 +0200 Subject: [PATCH] Code formatting. --- DRAMSys/library/src/common/AddressDecoder.cpp | 144 +++++++++++------- DRAMSys/library/src/common/AddressDecoder.h | 49 +++++- DRAMSys/library/src/common/TlmRecorder.cpp | 8 +- DRAMSys/library/src/common/utils.cpp | 103 ++++++------- DRAMSys/library/src/common/utils.h | 4 +- .../src/configuration/Configuration.cpp | 2 + .../library/src/configuration/Configuration.h | 2 + .../src/configuration/ConfigurationLoader.cpp | 25 ++- .../src/configuration/ConfigurationLoader.h | 4 +- .../src/configuration/TemperatureSimConfig.h | 1 + .../src/controller/checker/CheckerDDR3.cpp | 2 +- .../src/controller/checker/CheckerDDR4.cpp | 2 +- .../src/controller/checker/CheckerGDDR5.cpp | 2 +- .../src/controller/checker/CheckerGDDR5X.cpp | 2 +- .../src/controller/checker/CheckerGDDR6.cpp | 2 +- .../src/controller/checker/CheckerHBM2.cpp | 2 +- .../src/controller/checker/CheckerLPDDR4.cpp | 2 +- .../src/controller/checker/CheckerWideIO.cpp | 2 +- .../src/controller/checker/CheckerWideIO2.cpp | 2 +- DRAMSys/library/src/simulation/DRAMSys.cpp | 2 - DRAMSys/library/src/simulation/Setup.cpp | 3 +- DRAMSys/library/src/simulation/TraceSetup.cpp | 40 +++-- DRAMSys/simulator/main.cpp | 1 + DRAMSys/traceAnalyzer/scripts/memUtil.py | 1 - DRAMSys/traceAnalyzer/scripts/metrics.py | 1 + 25 files changed, 237 insertions(+), 171 deletions(-) diff --git a/DRAMSys/library/src/common/AddressDecoder.cpp b/DRAMSys/library/src/common/AddressDecoder.cpp index cdb906f3..b454cec6 100644 --- a/DRAMSys/library/src/common/AddressDecoder.cpp +++ b/DRAMSys/library/src/common/AddressDecoder.cpp @@ -1,86 +1,128 @@ +/* + * Copyright (c) 2018, 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: + * Johannes Feldmann + * Lukas Steiner + * Luiza Correa + */ #include #include + #include "AddressDecoder.h" #include "utils.h" - #include "../configuration/Configuration.h" + using json = nlohmann::json; unsigned int AddressDecoder::getUnsignedAttrFromJson(nlohmann::json obj, std::string strName) { - - if (!obj[strName].empty()){ - if (obj[strName].is_number_unsigned()){ - return obj[strName]; + if (!obj[strName].empty()) + { + if (obj[strName].is_number_unsigned()) + { + return obj[strName]; } - else { - reportFatal("AddressDecoder", - "Attribute " + strName + " is not a number."); - return (unsigned)(-1); + else + { + SC_REPORT_FATAL("AddressDecoder", ("Attribute " + strName + " is not a number.").c_str()); + return (unsigned)(-1); } } - else { - reportFatal("AddressDecoder", - "Attribute " + strName + " is empty or not found"); - return (unsigned)(-1); + else + { + SC_REPORT_FATAL("AddressDecoder", ("Attribute " + strName + " is empty or not found.").c_str()); + return (unsigned)(-1); } } - std::vector AddressDecoder::getAttrToVectorFromJson(nlohmann::json obj, - std::string strName) +std::vector AddressDecoder::getAttrToVectorFromJson(nlohmann::json obj, std::string strName) { std::vector vParameter; - if (!obj[strName].empty()){ - for ( auto it: obj[strName].items() ){ - auto valor = it.value(); - if (valor.is_number_unsigned()) - vParameter.push_back(it.value()); - else { - reportFatal("AddressDecoder", - "Attribute " + strName + " is not a number."); - } - } - } - return vParameter; - + if (!obj[strName].empty()) + { + for (auto it : obj[strName].items()) + { + auto valor = it.value(); + if (valor.is_number_unsigned()) + vParameter.push_back(it.value()); + else + SC_REPORT_FATAL("AddressDecoder", ("Attribute " + strName + " is not a number.").c_str()); + } + } + return vParameter; } AddressDecoder::AddressDecoder(std::string pathToAddressMapping) { - json AddrFile = parseJSON(pathToAddressMapping); - json j; - if (AddrFile["CONGEN"].empty()) - reportFatal("AddressDecorder", - "Root node name differs from \"CONGEN\". File format not supported."); + json addrFile = parseJSON(pathToAddressMapping); + json mapping; + if (addrFile["CONGEN"].empty()) + SC_REPORT_FATAL("AddressDecorder", "Root node name differs from \"CONGEN\". File format not supported."); // Load address mapping - if (!AddrFile["CONGEN"]["SOLUTION"].empty()) { - for ( auto it: AddrFile["CONGEN"]["SOLUTION"].items()){ - if (getUnsignedAttrFromJson(it.value(), "ID") == 0){ - ID=true; - j = it.value(); + if (!addrFile["CONGEN"]["SOLUTION"].empty()) + { + bool foundID0 = false; + for (auto it : addrFile["CONGEN"]["SOLUTION"].items()) + { + if (getUnsignedAttrFromJson(it.value(), "ID") == 0) + { + foundID0 = true; + mapping = it.value(); + break; } } - if (ID != true) + if (!foundID0) SC_REPORT_FATAL("AddressDecoder", "No mapping with ID 0 was found."); - } - else - j = AddrFile["CONGEN"]; + } + else + mapping = addrFile["CONGEN"]; - for ( auto xorItem: j["XOR"].items() ){ + for (auto xorItem : mapping["XOR"].items()) + { auto value = xorItem.value(); if (!value.empty()) vXor.push_back(std::pair(getUnsignedAttrFromJson(value, "FIRST"), getUnsignedAttrFromJson(value, "SECOND"))); - } - vChannelBits = getAttrToVectorFromJson(j,"CHANNEL_BIT"); - vRankBits = getAttrToVectorFromJson(j,"RANK_BIT"); - vBankGroupBits = getAttrToVectorFromJson(j,"BANKGROUP_BIT"); - vBankBits = getAttrToVectorFromJson(j,"BANK_BIT"); - vRowBits = getAttrToVectorFromJson(j,"ROW_BIT"); - vColumnBits = getAttrToVectorFromJson(j,"COLUMN_BIT"); - vByteBits = getAttrToVectorFromJson(j,"BYTE_BIT"); + } + + vChannelBits = getAttrToVectorFromJson(mapping,"CHANNEL_BIT"); + vRankBits = getAttrToVectorFromJson(mapping,"RANK_BIT"); + vBankGroupBits = getAttrToVectorFromJson(mapping,"BANKGROUP_BIT"); + vBankBits = getAttrToVectorFromJson(mapping,"BANK_BIT"); + vRowBits = getAttrToVectorFromJson(mapping,"ROW_BIT"); + vColumnBits = getAttrToVectorFromJson(mapping,"COLUMN_BIT"); + vByteBits = getAttrToVectorFromJson(mapping,"BYTE_BIT"); unsigned channels = pow(2.0, vChannelBits.size()); unsigned ranks = pow(2.0, vRankBits.size()); diff --git a/DRAMSys/library/src/common/AddressDecoder.h b/DRAMSys/library/src/common/AddressDecoder.h index 8f07ea55..c49c8214 100644 --- a/DRAMSys/library/src/common/AddressDecoder.h +++ b/DRAMSys/library/src/common/AddressDecoder.h @@ -1,5 +1,42 @@ -#ifndef ADRESSDECODER_H -#define ADRESSDECODER_H +/* + * Copyright (c) 2018, 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: + * Johannes Feldmann + * Lukas Steiner + * Luiza Correa + */ + +#ifndef ADDRESSDECODER_H +#define ADDRESSDECODER_H #include #include @@ -38,18 +75,14 @@ public: void print(); private: - - std::vector getAttrToVectorFromJson(nlohmann::json obj, - std::string strName); - unsigned int getUnsignedAttrFromJson(nlohmann::json obj, - std::string strName); + std::vector getAttrToVectorFromJson(nlohmann::json obj, std::string strName); + unsigned int getUnsignedAttrFromJson(nlohmann::json obj, std::string strName); unsigned banksPerGroup; unsigned bankgroupsPerRank; uint64_t maximumAddress; - bool ID; // This container stores for each used xor gate a pair of address bits, the first bit is overwritten with the result std::vector> vXor; std::vector vChannelBits; diff --git a/DRAMSys/library/src/common/TlmRecorder.cpp b/DRAMSys/library/src/common/TlmRecorder.cpp index 46a8bedb..4f36ce23 100644 --- a/DRAMSys/library/src/common/TlmRecorder.cpp +++ b/DRAMSys/library/src/common/TlmRecorder.cpp @@ -428,10 +428,10 @@ void TlmRecorder::insertPhaseInDB(std::string phaseName, const sc_time &begin, void TlmRecorder::executeSqlStatement(sqlite3_stmt *statement) { int errorCode = sqlite3_step(statement); - if (errorCode != SQLITE_DONE) { - reportFatal("Error in TraceRecorder", - std::string("Could not execute statement. Error code: ") + std::to_string(errorCode)); - } + if (errorCode != SQLITE_DONE) + SC_REPORT_FATAL("Error in TraceRecorder", + (std::string("Could not execute statement. Error code: ") + std::to_string(errorCode)).c_str()); + sqlite3_reset(statement); } diff --git a/DRAMSys/library/src/common/utils.cpp b/DRAMSys/library/src/common/utils.cpp index 966a6ae7..f7368a7e 100644 --- a/DRAMSys/library/src/common/utils.cpp +++ b/DRAMSys/library/src/common/utils.cpp @@ -33,6 +33,7 @@ * Janik Schlemminger * Robert Gernhardt * Matthias Jung + * Luiza Correa */ #include "utils.h" @@ -63,11 +64,6 @@ sc_time getDistance(sc_time a, sc_time b) return b - a; } -void reportFatal(std::string sender, std::string message) -{ - SC_REPORT_FATAL(sender.c_str(), message.c_str()); -} - std::string phaseNameToString(tlm_phase phase) { std::ostringstream oss; @@ -76,55 +72,50 @@ std::string phaseNameToString(tlm_phase phase) return str; } - unsigned int uIntParameter(nlohmann::json obj, std::string name) { - using json = nlohmann::json; - if (!obj.empty()){ - if (obj.is_number_unsigned()){ - return obj; - } - else throw std::invalid_argument("Expected type for '" + name + "': unsigned int"); + if (!obj.empty()) + { + if (obj.is_number_unsigned()) + return obj; + else + throw std::invalid_argument("Expected type for '" + name + "': unsigned int"); } - else reportFatal("Query json", "Parameter '" + name + "' does not exist."); + else + SC_REPORT_FATAL("Query json", ("Parameter '" + name + "' does not exist.").c_str()); } - double doubleParameter(nlohmann::json obj, std::string name) { - - if (!obj.empty()){ - if (obj.is_number() & obj>0){ - return obj; - } - else { - throw std::invalid_argument("Expected type for " + name + ": positive double"); - } - } - else {reportFatal("Query json", "Parameter '" + name + "' does not exist."); - return 0; + if (!obj.empty()) + { + if (obj.is_number() && (obj > 0)) + return obj; + else + throw std::invalid_argument("Expected type for " + name + ": positive double"); } + else + SC_REPORT_FATAL("Query json", ("Parameter '" + name + "' does not exist.").c_str()); } - -std::string stringParameter(nlohmann::json obj) +std::string stringParameter(nlohmann::json obj, std::string name) { - if (!obj.empty()){ - if (obj.is_string()){ - return obj; - } - else throw std::invalid_argument("Expected type for parameter string"); + if (!obj.empty()) + { + if (obj.is_string()) + return obj; + else + throw std::invalid_argument("Expected type for " + name + ": string"); } - else reportFatal("Query json", "Parameter does not exist."); - return 0; + else + SC_REPORT_FATAL("Query json", ("Parameter '" + name + "' does not exist.").c_str()); } - std::string loadTextFileContents(std::string filename) { - ifstream in(filename.c_str(), ios::in | ios::binary); - if (in) { + if (in) + { std::string contents; in.seekg(0, ios::end); contents.resize(in.tellg()); @@ -132,25 +123,28 @@ std::string loadTextFileContents(std::string filename) in.read(&contents[0], contents.size()); in.close(); return (contents); - } else { - reportFatal("Error loading file", "Could not load textfile from " + filename); + } + else + { + SC_REPORT_FATAL("Error loading file", ("Could not load textfile from " + filename).c_str()); return ""; } } -nlohmann::json parseJSON(std::string path){ +nlohmann::json parseJSON(std::string path) +{ try - { - // parsing input with a syntax error - nlohmann::json j = nlohmann::json::parse(std::ifstream(path)); - return j; - } - catch (nlohmann::json::parse_error& e) - { - // output exception information - std::cout << "Error while trying to parse file: " << path << '\n' - << "message: " << e.what() << std::endl; - } + { + // parsing input with a syntax error + nlohmann::json j = nlohmann::json::parse(std::ifstream(path)); + return j; + } + catch (nlohmann::json::parse_error& e) + { + // output exception information + std::cout << "Error while trying to parse file: " << path << '\n' + << "message: " << e.what() << std::endl; + } } void setUpDummy(tlm_generic_payload &payload, Rank rank, Bank bank) @@ -173,14 +167,13 @@ std::string getFileName(std::string uri) // Remove directory if present. // Do this before extension removal incase directory has a period character. const size_t last_slash_idx = uri.find_last_of("\\/"); - if (std::string::npos != last_slash_idx) { + if (std::string::npos != last_slash_idx) uri.erase(0, last_slash_idx + 1); - } // Remove extension if present. const size_t period_idx = uri.rfind('.'); - if (std::string::npos != period_idx) { + if (std::string::npos != period_idx) uri.erase(period_idx); - } + return uri; } diff --git a/DRAMSys/library/src/common/utils.h b/DRAMSys/library/src/common/utils.h index ed17bb3d..b85de69d 100644 --- a/DRAMSys/library/src/common/utils.h +++ b/DRAMSys/library/src/common/utils.h @@ -33,6 +33,7 @@ * Robert Gernhardt * Matthias Jung * Eder F. Zulian + * Luiza Correa */ #ifndef UTILS_H @@ -134,7 +135,6 @@ static inline void loadbar(unsigned int x, } //TODO : Move to debug manager -void reportFatal(std::string sender, std::string message); std::string phaseNameToString(tlm::tlm_phase phase); @@ -144,7 +144,7 @@ std::string loadTextFileContents(std::string filename); unsigned int uIntParameter(nlohmann::json obj, std::string name); double doubleParameter(nlohmann::json obj, std::string name); -std::string stringParameter(nlohmann::json obj); +std::string stringParameter(nlohmann::json obj, std::string name); nlohmann::json parseJSON(std::string path); diff --git a/DRAMSys/library/src/configuration/Configuration.cpp b/DRAMSys/library/src/configuration/Configuration.cpp index ed947d5f..7ef11c0f 100644 --- a/DRAMSys/library/src/configuration/Configuration.cpp +++ b/DRAMSys/library/src/configuration/Configuration.cpp @@ -34,6 +34,8 @@ * Matthias Jung * Éder F. Zulian * Felipe S. Prado + * Lukas Steiner + * Luiza Correa */ #include diff --git a/DRAMSys/library/src/configuration/Configuration.h b/DRAMSys/library/src/configuration/Configuration.h index 40529f6d..44029e03 100644 --- a/DRAMSys/library/src/configuration/Configuration.h +++ b/DRAMSys/library/src/configuration/Configuration.h @@ -34,6 +34,8 @@ * Matthias Jung * Eder F. Zulian * Felipe S. Prado + * Lukas Steiner + * Luiza Correa */ #ifndef CONFIGURATION_H diff --git a/DRAMSys/library/src/configuration/ConfigurationLoader.cpp b/DRAMSys/library/src/configuration/ConfigurationLoader.cpp index 225dc429..5f11fb05 100644 --- a/DRAMSys/library/src/configuration/ConfigurationLoader.cpp +++ b/DRAMSys/library/src/configuration/ConfigurationLoader.cpp @@ -62,9 +62,8 @@ void ConfigurationLoader::loadConfigJson(Configuration &config, json::object_t *configNode) { json j = *configNode; - for (auto& x : j.items()) { + for (auto& x : j.items()) config.setParameter(x.key(), x.value()); - } } @@ -92,18 +91,19 @@ void ConfigurationLoader::loadMemSpec(Configuration &config, using json = nlohmann::json; json j = *memspec; auto memoryType = j["memoryType"]; - if (memoryType == "DDR4") - { - Configuration::getInstance().memSpec = new MemSpecDDR4(); - loadCommons(config, memspec); - loadDDR4(config, memspec); - } - else if (memoryType == "DDR3") + + if (memoryType == "DDR3") { Configuration::getInstance().memSpec = new MemSpecDDR3(); loadCommons(config, memspec); loadDDR3(config, memspec); } + else if (memoryType == "DDR4") + { + Configuration::getInstance().memSpec = new MemSpecDDR4(); + loadCommons(config, memspec); + loadDDR4(config, memspec); + } else if (memoryType == "LPDDR4") { Configuration::getInstance().memSpec = new MemSpecLPDDR4(); @@ -147,16 +147,15 @@ void ConfigurationLoader::loadMemSpec(Configuration &config, loadGDDR6(config, memspec); } else - reportFatal("ConfigurationLoader", "Unsupported DRAM type"); + SC_REPORT_FATAL("ConfigurationLoader", "Unsupported DRAM type"); } void ConfigurationLoader::loadCommons(Configuration &config, json::object_t *jsonSpec) { MemSpec *memSpec = config.memSpec; json j = *jsonSpec; - memSpec->memoryId = stringParameter(j["memoryId"]); - memSpec->memoryType = stringParameter(j["memoryType"]); - + memSpec->memoryId = stringParameter(j["memoryId"], "memoryId"); + memSpec->memoryType = stringParameter(j["memoryType"], "memoryType"); // MemArchitecture memSpec->burstLength = uIntParameter( j["memarchitecturespec"]["burstLength"],"burstLength"); diff --git a/DRAMSys/library/src/configuration/ConfigurationLoader.h b/DRAMSys/library/src/configuration/ConfigurationLoader.h index fad6c7f5..85f7be69 100644 --- a/DRAMSys/library/src/configuration/ConfigurationLoader.h +++ b/DRAMSys/library/src/configuration/ConfigurationLoader.h @@ -33,6 +33,7 @@ * Janik Schlemminger * Matthias Jung * Lukas Steiner + * Luiza Correa */ #ifndef CONFIGURATIONLOADER_H @@ -56,11 +57,8 @@ class ConfigurationLoader { public: - - static void loadMCConfig(Configuration &config, std::string amconfigUri); - static void loadSimConfig(Configuration &config, std::string simconfigUri); static void loadMemSpec(Configuration &config, std::string memspecUri); diff --git a/DRAMSys/library/src/configuration/TemperatureSimConfig.h b/DRAMSys/library/src/configuration/TemperatureSimConfig.h index 1c45a7e5..c494443a 100644 --- a/DRAMSys/library/src/configuration/TemperatureSimConfig.h +++ b/DRAMSys/library/src/configuration/TemperatureSimConfig.h @@ -32,6 +32,7 @@ * Authors: * Eder F. Zulian * Matthias Jung + * Luiza Correa */ #ifndef TEMPERATURESIMCONFIG_H diff --git a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp index 1a6c7b9c..20e5c4e4 100644 --- a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp @@ -404,7 +404,7 @@ sc_time CheckerDDR3::timeToSatisfyConstraints(Command command, Rank rank, BankGr earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKESR); } else - reportFatal("CheckerDDR3", "Unknown command!"); + SC_REPORT_FATAL("CheckerDDR3", "Unknown command!"); earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerDDR4.cpp b/DRAMSys/library/src/controller/checker/CheckerDDR4.cpp index b3b9110e..faa5bde8 100644 --- a/DRAMSys/library/src/controller/checker/CheckerDDR4.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerDDR4.cpp @@ -435,7 +435,7 @@ sc_time CheckerDDR4::timeToSatisfyConstraints(Command command, Rank rank, BankGr earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKESR); } else - reportFatal("CheckerDDR4", "Unknown command!"); + SC_REPORT_FATAL("CheckerDDR4", "Unknown command!"); earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerGDDR5.cpp b/DRAMSys/library/src/controller/checker/CheckerGDDR5.cpp index 2edeb6a5..962f6795 100644 --- a/DRAMSys/library/src/controller/checker/CheckerGDDR5.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerGDDR5.cpp @@ -516,7 +516,7 @@ sc_time CheckerGDDR5::timeToSatisfyConstraints(Command command, Rank rank, BankG earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKE); } else - reportFatal("CheckerGDDR5", "Unknown command!"); + SC_REPORT_FATAL("CheckerGDDR5", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerGDDR5X.cpp b/DRAMSys/library/src/controller/checker/CheckerGDDR5X.cpp index 6e8a2a86..5ae1adbb 100644 --- a/DRAMSys/library/src/controller/checker/CheckerGDDR5X.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerGDDR5X.cpp @@ -516,7 +516,7 @@ sc_time CheckerGDDR5X::timeToSatisfyConstraints(Command command, Rank rank, Bank earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKE); } else - reportFatal("CheckerGDDR5X", "Unknown command!"); + SC_REPORT_FATAL("CheckerGDDR5X", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerGDDR6.cpp b/DRAMSys/library/src/controller/checker/CheckerGDDR6.cpp index b14d99a5..38ef3555 100644 --- a/DRAMSys/library/src/controller/checker/CheckerGDDR6.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerGDDR6.cpp @@ -537,7 +537,7 @@ sc_time CheckerGDDR6::timeToSatisfyConstraints(Command command, Rank rank, BankG earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKESR); } else - reportFatal("CheckerGDDR6", "Unknown command!"); + SC_REPORT_FATAL("CheckerGDDR6", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerHBM2.cpp b/DRAMSys/library/src/controller/checker/CheckerHBM2.cpp index 31c3a810..17d8a355 100644 --- a/DRAMSys/library/src/controller/checker/CheckerHBM2.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerHBM2.cpp @@ -482,7 +482,7 @@ sc_time CheckerHBM2::timeToSatisfyConstraints(Command command, Rank rank, BankGr earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnRasBus + memSpec->tCK); } else - reportFatal("CheckerHBM2", "Unknown command!"); + SC_REPORT_FATAL("CheckerHBM2", "Unknown command!"); return earliestTimeToStart; } diff --git a/DRAMSys/library/src/controller/checker/CheckerLPDDR4.cpp b/DRAMSys/library/src/controller/checker/CheckerLPDDR4.cpp index 09a372d9..09adc6d1 100644 --- a/DRAMSys/library/src/controller/checker/CheckerLPDDR4.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerLPDDR4.cpp @@ -487,7 +487,7 @@ sc_time CheckerLPDDR4::timeToSatisfyConstraints(Command command, Rank rank, Bank earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tSR); } else - reportFatal("CheckerLPDDR4", "Unknown command!"); + SC_REPORT_FATAL("CheckerLPDDR4", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerWideIO.cpp b/DRAMSys/library/src/controller/checker/CheckerWideIO.cpp index 034c76c6..4b40ecf4 100644 --- a/DRAMSys/library/src/controller/checker/CheckerWideIO.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerWideIO.cpp @@ -376,7 +376,7 @@ sc_time CheckerWideIO::timeToSatisfyConstraints(Command command, Rank rank, Bank earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKESR); } else - reportFatal("CheckerWideIO", "Unknown command!"); + SC_REPORT_FATAL("CheckerWideIO", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastScheduled + memSpec->tCK); diff --git a/DRAMSys/library/src/controller/checker/CheckerWideIO2.cpp b/DRAMSys/library/src/controller/checker/CheckerWideIO2.cpp index 59f37315..357f6615 100644 --- a/DRAMSys/library/src/controller/checker/CheckerWideIO2.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerWideIO2.cpp @@ -454,7 +454,7 @@ sc_time CheckerWideIO2::timeToSatisfyConstraints(Command command, Rank rank, Ban earliestTimeToStart = std::max(earliestTimeToStart, lastCommandStart + memSpec->tCKESR); } else - reportFatal("CheckerWideIO2", "Unknown command!"); + SC_REPORT_FATAL("CheckerWideIO2", "Unknown command!"); // Check if command bus is free earliestTimeToStart = std::max(earliestTimeToStart, lastCommandOnBus + memSpec->tCK); diff --git a/DRAMSys/library/src/simulation/DRAMSys.cpp b/DRAMSys/library/src/simulation/DRAMSys.cpp index 33dad862..ccf83de3 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.cpp +++ b/DRAMSys/library/src/simulation/DRAMSys.cpp @@ -123,10 +123,8 @@ DRAMSys::DRAMSys(sc_module_name name, if (!simulationdoc["simulation"]["simulationid"].empty()) { std::string sid = simulationdoc["simulation"]["simulationid"]; simName = sid + '_' + Configuration::getInstance().simulationName; - } - // Instantiate all internal DRAMSys modules: instantiateModules(simName, pathToResources, amconfig); // Connect all internal DRAMSys modules: diff --git a/DRAMSys/library/src/simulation/Setup.cpp b/DRAMSys/library/src/simulation/Setup.cpp index 4eaa8aa0..7ab3e66a 100644 --- a/DRAMSys/library/src/simulation/Setup.cpp +++ b/DRAMSys/library/src/simulation/Setup.cpp @@ -31,6 +31,7 @@ * * Authors: * Matthias Jung + * Luiza Correa */ #include "Setup.h" @@ -47,7 +48,7 @@ Setup::Setup(std::string uri, nlohmann::json simulationdoc = parseJSON(uri); if (simulationdoc["simulation"].empty()) - reportFatal("SimulationManager", + SC_REPORT_FATAL("SimulationManager", "Cannot load simulation: simulation node expected"); diff --git a/DRAMSys/library/src/simulation/TraceSetup.cpp b/DRAMSys/library/src/simulation/TraceSetup.cpp index 5458131c..a560f0d6 100644 --- a/DRAMSys/library/src/simulation/TraceSetup.cpp +++ b/DRAMSys/library/src/simulation/TraceSetup.cpp @@ -31,6 +31,7 @@ * * Authors: * Matthias Jung + * Luiza Correa */ #include "TraceSetup.h" @@ -42,29 +43,29 @@ TraceSetup::TraceSetup(std::string uri, // Load Simulation: nlohmann::json simulationdoc = parseJSON(uri); - if (simulationdoc["simulation"].empty()) - reportFatal("traceSetup", + SC_REPORT_FATAL("traceSetup", "Cannot load simulation: simulation node expected"); // Load TracePlayers: - for ( auto it: simulationdoc["simulation"]["tracesetup"].items() ){ + for (auto it : simulationdoc["simulation"]["tracesetup"].items()) + { auto value = it.value(); - if (!value.empty()){ - sc_time playerClk; - unsigned int frequencyMHz = value["clkMhz"]; + if (!value.empty()) + { + sc_time playerClk; + unsigned int frequencyMHz = value["clkMhz"]; if (frequencyMHz == 0) - reportFatal("traceSetup", "No Frequency Defined"); + SC_REPORT_FATAL("traceSetup", "No Frequency Defined"); else playerClk = sc_time(1.0 / frequencyMHz, SC_US); std::string name = value["name"]; size_t pos = name.rfind('.'); - if (pos == std::string::npos) { + if (pos == std::string::npos) throw std::runtime_error("Name of the trace file does not contain a valid extension."); - } // Get the extension and make it lower case std::string ext = name.substr(pos + 1); @@ -77,23 +78,20 @@ TraceSetup::TraceSetup(std::string uri, std::replace(moduleName.begin(), moduleName.end(), '.', '_'); TracePlayer *player; - if (ext == "stl") { + if (ext == "stl") player = new StlPlayer(moduleName.c_str(), stlFile, playerClk, this); - } else if (ext == "rstl") { + else if (ext == "rstl") player = new StlPlayer(moduleName.c_str(), stlFile, playerClk, this); - } else { - std::string error = "Unsupported file extension in " + name; - throw std::runtime_error(error); - } + else + throw std::runtime_error("Unsupported file extension in " + name); + devices->push_back(player); - if (Configuration::getInstance().simulationProgressBar) { + if (Configuration::getInstance().simulationProgressBar) totalTransactions += player->getNumberOfLines(stlFile); - } } } - remainingTransactions = totalTransactions; numberOfTracePlayers = devices->size(); } @@ -102,9 +100,8 @@ void TraceSetup::tracePlayerTerminates() { finishedTracePlayers++; - if (finishedTracePlayers == numberOfTracePlayers) { + if (finishedTracePlayers == numberOfTracePlayers) sc_stop(); - } } void TraceSetup::transactionFinished() { @@ -112,7 +109,6 @@ void TraceSetup::transactionFinished() loadbar(totalTransactions - remainingTransactions, totalTransactions); - if (remainingTransactions == 0) { + if (remainingTransactions == 0) std::cout << std::endl; - } } diff --git a/DRAMSys/simulator/main.cpp b/DRAMSys/simulator/main.cpp index d966e174..598e8c0e 100644 --- a/DRAMSys/simulator/main.cpp +++ b/DRAMSys/simulator/main.cpp @@ -32,6 +32,7 @@ * Authors: * Robert Gernhardt * Matthias Jung + * Luiza Correa */ #include diff --git a/DRAMSys/traceAnalyzer/scripts/memUtil.py b/DRAMSys/traceAnalyzer/scripts/memUtil.py index 1e016ff8..26048686 100755 --- a/DRAMSys/traceAnalyzer/scripts/memUtil.py +++ b/DRAMSys/traceAnalyzer/scripts/memUtil.py @@ -118,4 +118,3 @@ def get_total_time_in_phase(connection, phase): if (totalTime is None): totalTime = 0.0 return totalTime - diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index e915afb8..cc4e8e5e 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -484,6 +484,7 @@ def time_in_power_down_states_percent(connection): mcconfig = MCConfig(connection) #bankwiseLogic = mcconfig.getValue("BankwiseLogic") bankwiseLogic = "0" + if bankwiseLogic == "0": totalTimeAllBanks = trace_length_in_ns(connection) else: