From b13cf5845c71265b2dc3b56c4fcd3e87f1447a81 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Wed, 22 Feb 2023 10:53:20 +0100 Subject: [PATCH] Remove unused files, make includes consistent. --- src/configuration/CMakeLists.txt | 31 +-- .../DRAMSys/config/DRAMSysConfiguration.cpp | 6 +- .../DRAMSys/config/DRAMSysConfiguration.h | 1 - .../DRAMSys/config/ThermalConfig.cpp | 121 --------- .../DRAMSys/config/ThermalConfig.h | 118 --------- src/libdramsys/DRAMSys/common/TlmRecorder.cpp | 6 +- src/libdramsys/DRAMSys/controller/Command.h | 4 +- .../DRAMSys/controller/ControllerIF.h | 1 + .../controller/checker/CheckerDDR3.cpp | 2 + .../controller/checker/CheckerDDR4.cpp | 2 + .../controller/checker/CheckerGDDR5.cpp | 2 + .../controller/checker/CheckerGDDR5X.cpp | 2 + .../controller/checker/CheckerGDDR6.cpp | 2 + .../controller/checker/CheckerHBM2.cpp | 2 + .../controller/checker/CheckerLPDDR4.cpp | 2 + .../controller/checker/CheckerSTTMRAM.cpp | 2 + .../controller/checker/CheckerWideIO.cpp | 2 + .../controller/checker/CheckerWideIO2.cpp | 2 + src/libdramsys/DRAMSys/simulation/Arbiter.cpp | 1 + src/simulator/CMakeLists.txt | 2 +- src/simulator/simulator/ExampleInitiator.h | 238 ------------------ src/simulator/simulator/LengthConverter.cpp | 238 ------------------ src/simulator/simulator/LengthConverter.h | 233 ----------------- src/simulator/simulator/MemoryManager.cpp | 3 +- src/simulator/simulator/MemoryManager.h | 1 - src/simulator/simulator/StlPlayer.cpp | 2 +- src/simulator/simulator/StlPlayer.h | 24 +- src/simulator/simulator/TraceSetup.cpp | 8 +- src/simulator/simulator/TraceSetup.h | 7 +- src/simulator/simulator/TrafficGenerator.cpp | 3 +- src/simulator/simulator/TrafficGenerator.h | 6 +- src/simulator/simulator/TrafficInitiator.cpp | 2 +- src/simulator/simulator/TrafficInitiator.h | 11 +- src/simulator/simulator/main.cpp | 22 +- src/util/DRAMSys/util/json.h | 2 +- 35 files changed, 74 insertions(+), 1037 deletions(-) delete mode 100644 src/configuration/DRAMSys/config/ThermalConfig.cpp delete mode 100644 src/configuration/DRAMSys/config/ThermalConfig.h delete mode 100644 src/simulator/simulator/ExampleInitiator.h delete mode 100644 src/simulator/simulator/LengthConverter.cpp delete mode 100644 src/simulator/simulator/LengthConverter.h diff --git a/src/configuration/CMakeLists.txt b/src/configuration/CMakeLists.txt index aba86882..1cec593a 100644 --- a/src/configuration/CMakeLists.txt +++ b/src/configuration/CMakeLists.txt @@ -38,35 +38,8 @@ project(DRAMSys_Configuration) -#file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) -#file(GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS *.h;*.hpp) - -set(SOURCE_FILES - DRAMSys/config/AddressMapping.cpp - DRAMSys/config/AddressMapping.h - DRAMSys/config/DRAMSysConfiguration.cpp - DRAMSys/config/DRAMSysConfiguration.h - DRAMSys/config/McConfig.cpp - DRAMSys/config/McConfig.h - DRAMSys/config/memspec/MemArchitectureSpec.cpp - DRAMSys/config/memspec/MemArchitectureSpec.h - DRAMSys/config/memspec/MemPowerSpec.cpp - DRAMSys/config/memspec/MemPowerSpec.h - DRAMSys/config/memspec/MemSpec.cpp - DRAMSys/config/memspec/MemSpec.h - DRAMSys/config/memspec/MemTimingSpec.cpp - DRAMSys/config/memspec/MemTimingSpec.h - DRAMSys/config/SimConfig.cpp - DRAMSys/config/SimConfig.h - DRAMSys/config/ThermalConfig.cpp - DRAMSys/config/ThermalConfig.h - DRAMSys/config/TraceSetup.cpp - DRAMSys/config/TraceSetup.h - DRAMSys/config/ConfigUtil.cpp - DRAMSys/config/ConfigUtil.h - - "${DRAMSYS_TESTS_DIR}/tests_configuration/CMakeLists.txt" -) +file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) +file(GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS *.h;*.hpp) add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES} ${HEADER_FILES}) diff --git a/src/configuration/DRAMSys/config/DRAMSysConfiguration.cpp b/src/configuration/DRAMSys/config/DRAMSysConfiguration.cpp index a3baeac8..c93f9002 100644 --- a/src/configuration/DRAMSys/config/DRAMSysConfiguration.cpp +++ b/src/configuration/DRAMSys/config/DRAMSysConfiguration.cpp @@ -47,8 +47,7 @@ std::string Configuration::resourceDirectory; void to_json(json_t &j, const Configuration &c) { j = json_t{{"addressmapping", c.addressMapping}, {"mcconfig", c.mcConfig}, {"memspec", c.memSpec}, - {"simulationid", c.simulationId}, {"simconfig", c.simConfig}, {"thermalconfig", c.thermalConfig}, - {"tracesetup", c.traceSetup}}; + {"simulationid", c.simulationId}, {"simconfig", c.simConfig}, {"tracesetup", c.traceSetup}}; remove_null_values(j); } @@ -61,9 +60,6 @@ void from_json(const json_t &j, Configuration &c) j.at("simulationid").get_to(c.simulationId); j.at("simconfig").get_to(c.simConfig); - if (j.contains("thermalconfig")) - j.at("thermalconfig").get_to(c.thermalConfig); - if (j.contains("tracesetup")) j.at("tracesetup").get_to(c.traceSetup); } diff --git a/src/configuration/DRAMSys/config/DRAMSysConfiguration.h b/src/configuration/DRAMSys/config/DRAMSysConfiguration.h index e44cf44f..2f2e4e52 100644 --- a/src/configuration/DRAMSys/config/DRAMSysConfiguration.h +++ b/src/configuration/DRAMSys/config/DRAMSysConfiguration.h @@ -39,7 +39,6 @@ #include "DRAMSys/config/AddressMapping.h" #include "DRAMSys/config/McConfig.h" #include "DRAMSys/config/SimConfig.h" -#include "DRAMSys/config/ThermalConfig.h" #include "DRAMSys/config/TraceSetup.h" #include "DRAMSys/config/memspec/MemSpec.h" #include "DRAMSys/config/ConfigUtil.h" diff --git a/src/configuration/DRAMSys/config/ThermalConfig.cpp b/src/configuration/DRAMSys/config/ThermalConfig.cpp deleted file mode 100644 index 5a68a59f..00000000 --- a/src/configuration/DRAMSys/config/ThermalConfig.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2021, Technische Universität 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: - * Derek Christ - */ - -#include "ThermalConfig.h" - -namespace DRAMSys::Config -{ - -void to_json(json_t &j, const ThermalConfig &c) -{ - j = json_t{{"TemperatureScale", c.temperatureScale}, - {"StaticTemperatureDefaultValue", c.staticTemperatureDefaultValue}, - {"ThermalSimPeriod", c.thermalSimPeriod}, - {"ThermalSimUnit", c.thermalSimUnit}, - {"PowerInfoFile", c.powerInfo}, - {"IceServerIp", c.iceServerIp}, - {"IceServerPort", c.iceServerPort}, - {"SimPeriodAdjustFactor", c.simPeriodAdjustFactor}, - {"NPowStableCyclesToIncreasePeriod", c.nPowStableCyclesToIncreasePeriod}, - {"GenerateTemperatureMap", c.generateTemperatureMap}, - {"GeneratePowerMap", c.generatePowerMap}}; -} - -void from_json(const json_t &j, ThermalConfig &c) -{ - json_t j_thermalsim = get_config_json(j, thermalConfigPath, "thermalsimconfig"); - - j_thermalsim.at("TemperatureScale").get_to(c.temperatureScale); - j_thermalsim.at("StaticTemperatureDefaultValue").get_to(c.staticTemperatureDefaultValue); - j_thermalsim.at("ThermalSimPeriod").get_to(c.thermalSimPeriod); - j_thermalsim.at("ThermalSimUnit").get_to(c.thermalSimUnit); - j_thermalsim.at("PowerInfoFile").get_to(c.powerInfo); - j_thermalsim.at("IceServerIp").get_to(c.iceServerIp); - j_thermalsim.at("IceServerPort").get_to(c.iceServerPort); - j_thermalsim.at("SimPeriodAdjustFactor").get_to(c.simPeriodAdjustFactor); - j_thermalsim.at("NPowStableCyclesToIncreasePeriod").get_to(c.nPowStableCyclesToIncreasePeriod); - j_thermalsim.at("GenerateTemperatureMap").get_to(c.generateTemperatureMap); - j_thermalsim.at("GeneratePowerMap").get_to(c.generatePowerMap); -} - -void to_json(json_t &j, const DramDieChannel &c) -{ - j = json_t{{"init_pow", c.init_pow}, {"threshold", c.threshold}}; -} - -void from_json(const json_t &j, DramDieChannel &c) -{ - j.at("init_pow").get_to(c.init_pow); - j.at("threshold").get_to(c.threshold); -} - -void to_json(json_t &j, const PowerInfo &c) -{ - j = json_t{}; - - for (const auto &channel : c.channels) - { - j.emplace(channel.identifier, channel); - } -} - -void from_json(const json_t &j, PowerInfo &c) -{ - json_t j_powerinfo = get_config_json(j, thermalConfigPath, "powerInfo"); - - for (const auto &entry : j_powerinfo.items()) - { - DramDieChannel channel; - j_powerinfo.at(entry.key()).get_to(channel); - channel.identifier = entry.key(); - - c.channels.push_back(channel); - } -} - -void from_dump(const std::string &dump, ThermalConfig &c) -{ - json_t json_thermalconfig = json_t::parse(dump).at("thermalconfig"); - json_thermalconfig.get_to(c); -} - -std::string dump(const ThermalConfig &c, unsigned int indentation) -{ - json_t json_thermalconfig; - json_thermalconfig["thermalconfig"] = c; - return json_thermalconfig.dump(indentation); -} - -} // namespace DRAMSys::Config diff --git a/src/configuration/DRAMSys/config/ThermalConfig.h b/src/configuration/DRAMSys/config/ThermalConfig.h deleted file mode 100644 index f7baea55..00000000 --- a/src/configuration/DRAMSys/config/ThermalConfig.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021, Technische Universität 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: - * Derek Christ - */ - -#ifndef DRAMSYSCONFIGURATION_THERMALCONFIG_H -#define DRAMSYSCONFIGURATION_THERMALCONFIG_H - -#include "DRAMSys/config/ConfigUtil.h" - -namespace DRAMSys::Config -{ -const std::string thermalConfigPath = "configs/thermalsim"; - -enum class TemperatureScale -{ - Celsius, - Fahrenheit, - Kelvin, - Invalid = -1, -}; - -NLOHMANN_JSON_SERIALIZE_ENUM(TemperatureScale, {{TemperatureScale::Invalid, nullptr}, - {TemperatureScale::Celsius, "Celsius"}, - {TemperatureScale::Fahrenheit, "Fahrenheit"}, - {TemperatureScale::Kelvin, "Kelvin"}}) - -enum class ThermalSimUnit -{ - Seconds, - Milliseconds, - Microseconds, - Nanoseconds, - Picoseconds, - Femtoseconds, - Invalid = -1, -}; - -NLOHMANN_JSON_SERIALIZE_ENUM(ThermalSimUnit, {{ThermalSimUnit::Invalid, nullptr}, - {ThermalSimUnit::Seconds, "s"}, - {ThermalSimUnit::Milliseconds, "ms"}, - {ThermalSimUnit::Microseconds, "us"}, - {ThermalSimUnit::Nanoseconds, "ns"}, - {ThermalSimUnit::Picoseconds, "ps"}, - {ThermalSimUnit::Femtoseconds, "fs"}}) - -struct DramDieChannel -{ - std::string identifier; - double init_pow; - double threshold; -}; - -void to_json(json_t &j, const DramDieChannel &c); -void from_json(const json_t &j, DramDieChannel &c); - -struct PowerInfo -{ - std::vector channels; -}; - -void to_json(json_t &j, const PowerInfo &c); -void from_json(const json_t &j, PowerInfo &c); - -struct ThermalConfig -{ - TemperatureScale temperatureScale; - int staticTemperatureDefaultValue; - double thermalSimPeriod; - ThermalSimUnit thermalSimUnit; - PowerInfo powerInfo; - std::string iceServerIp; - unsigned int iceServerPort; - unsigned int simPeriodAdjustFactor; - unsigned int nPowStableCyclesToIncreasePeriod; - bool generateTemperatureMap; - bool generatePowerMap; -}; - -void to_json(json_t &j, const ThermalConfig &c); -void from_json(const json_t &j, ThermalConfig &c); - -void from_dump(const std::string &dump, ThermalConfig &c); -std::string dump(const ThermalConfig &c, unsigned int indentation = -1); - -} // namespace Configuration - -#endif // DRAMSYSCONFIGURATION_THERMALCONFIG_H diff --git a/src/libdramsys/DRAMSys/common/TlmRecorder.cpp b/src/libdramsys/DRAMSys/common/TlmRecorder.cpp index 55bb66ef..e1e6d5b4 100644 --- a/src/libdramsys/DRAMSys/common/TlmRecorder.cpp +++ b/src/libdramsys/DRAMSys/common/TlmRecorder.cpp @@ -426,13 +426,13 @@ void TlmRecorder::insertGeneralInfo() void TlmRecorder::insertCommandLengths() { - const MemSpec& memSpec = *config.memSpec; + const MemSpec& _memSpec = *config.memSpec; - auto insertCommandLength = [this, &memSpec](Command command) { + auto insertCommandLength = [this, &_memSpec](Command command) { auto commandName = command.toString(); sqlite3_bind_text(insertCommandLengthsStatement, 1, commandName.c_str(), commandName.length(), nullptr); - sqlite3_bind_double(insertCommandLengthsStatement, 2, memSpec.getCommandLengthInCycles(command)); + sqlite3_bind_double(insertCommandLengthsStatement, 2, _memSpec.getCommandLengthInCycles(command)); executeSqlStatement(insertCommandLengthsStatement); }; diff --git a/src/libdramsys/DRAMSys/controller/Command.h b/src/libdramsys/DRAMSys/controller/Command.h index 0d6055eb..635f527a 100644 --- a/src/libdramsys/DRAMSys/controller/Command.h +++ b/src/libdramsys/DRAMSys/controller/Command.h @@ -126,8 +126,8 @@ private: public: Command() = default; - explicit Command(Type type); - explicit Command(tlm::tlm_phase phase); + Command(Type type); + Command(tlm::tlm_phase phase); [[nodiscard]] std::string toString() const; [[nodiscard]] tlm::tlm_phase toPhase() const; diff --git a/src/libdramsys/DRAMSys/controller/ControllerIF.h b/src/libdramsys/DRAMSys/controller/ControllerIF.h index 8a7f5ce0..cc80c655 100644 --- a/src/libdramsys/DRAMSys/controller/ControllerIF.h +++ b/src/libdramsys/DRAMSys/controller/ControllerIF.h @@ -38,6 +38,7 @@ #define CONTROLLERIF_H #include "DRAMSys/configuration/Configuration.h" +#include "DRAMSys/common/DebugManager.h" #include #include diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerDDR3.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerDDR3.cpp index 10838df6..81585509 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerDDR3.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerDDR3.cpp @@ -34,6 +34,8 @@ #include "CheckerDDR3.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerDDR4.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerDDR4.cpp index 8801d5b1..ff2a56c9 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerDDR4.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerDDR4.cpp @@ -34,6 +34,8 @@ #include "CheckerDDR4.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5.cpp index 55b1ba8d..5fc7d80c 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5.cpp @@ -34,6 +34,8 @@ #include "CheckerGDDR5.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5X.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5X.cpp index b8956d96..68bbcecb 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5X.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR5X.cpp @@ -34,6 +34,8 @@ #include "CheckerGDDR5X.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR6.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR6.cpp index 684de357..1be0ccb5 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR6.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerGDDR6.cpp @@ -34,6 +34,8 @@ #include "CheckerGDDR6.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerHBM2.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerHBM2.cpp index 120e2c23..ebe67169 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerHBM2.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerHBM2.cpp @@ -34,6 +34,8 @@ #include "CheckerHBM2.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerLPDDR4.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerLPDDR4.cpp index f417d870..e7f164e8 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerLPDDR4.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerLPDDR4.cpp @@ -34,6 +34,8 @@ #include "CheckerLPDDR4.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerSTTMRAM.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerSTTMRAM.cpp index 3b38d746..a087f9c2 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerSTTMRAM.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerSTTMRAM.cpp @@ -34,6 +34,8 @@ #include "CheckerSTTMRAM.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO.cpp index 281f1b79..4b9df385 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO.cpp @@ -34,6 +34,8 @@ #include "CheckerWideIO.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO2.cpp b/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO2.cpp index 3cfc58b2..525382ad 100644 --- a/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO2.cpp +++ b/src/libdramsys/DRAMSys/controller/checker/CheckerWideIO2.cpp @@ -34,6 +34,8 @@ #include "CheckerWideIO2.h" +#include "DRAMSys/common/DebugManager.h" + #include using namespace sc_core; diff --git a/src/libdramsys/DRAMSys/simulation/Arbiter.cpp b/src/libdramsys/DRAMSys/simulation/Arbiter.cpp index 692cc0fe..6e56b92c 100644 --- a/src/libdramsys/DRAMSys/simulation/Arbiter.cpp +++ b/src/libdramsys/DRAMSys/simulation/Arbiter.cpp @@ -41,6 +41,7 @@ #include "DRAMSys/simulation/AddressDecoder.h" #include "DRAMSys/configuration/Configuration.h" +#include "DRAMSys/common/DebugManager.h" #include "DRAMSys/config/DRAMSysConfiguration.h" diff --git a/src/simulator/CMakeLists.txt b/src/simulator/CMakeLists.txt index 7a798552..e37a01ec 100644 --- a/src/simulator/CMakeLists.txt +++ b/src/simulator/CMakeLists.txt @@ -43,7 +43,7 @@ project(DRAMSys_Simulator) file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp) file(GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS *.h;*.hpp) -add_executable(DRAMSys ${SOURCE_FILES} ${HEADER_FILES} ) +add_executable(DRAMSys ${SOURCE_FILES} ${HEADER_FILES}) target_include_directories(DRAMSys PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../library/src/simulation/DRAMSysRecordable.cpp) diff --git a/src/simulator/simulator/ExampleInitiator.h b/src/simulator/simulator/ExampleInitiator.h deleted file mode 100644 index 8325f3ed..00000000 --- a/src/simulator/simulator/ExampleInitiator.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2016, Technische Universität 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: - * Eder F. Zulian - */ - -#ifndef EXAMPLEINITIATOR_H -#define EXAMPLEINITIATOR_H - -#include -#include - -#include -#include "MemoryManager.h" -#include "common/dramExtensions.h" -#include "TracePlayer.h" - -struct ExampleInitiator : sc_core::sc_module -{ - // TLM-2 socket, defaults to 32-bits wide, base protocol - tlm_utils::simple_initiator_socket socket; - - SC_CTOR(ExampleInitiator) - : socket("socket"), - request_in_progress(nullptr), - m_peq(this, &ExampleInitiator::peq_cb) - { - socket.register_nb_transport_bw(this, &ExampleInitiator::nb_transport_bw); - SC_THREAD(thread_process); - } - - void thread_process() - { - tlm::tlm_generic_payload *trans; - tlm::tlm_phase phase; - sc_core::sc_time delay; - - dump_mem(); - init_mem(); - dump_mem(); - - for (unsigned char &i : data) - i = 0x55; - - // Generate 2 write transactions - for (int i = 0; i < 2; i++) { - int adr = i * 64; - - tlm::tlm_command cmd = tlm::TLM_WRITE_COMMAND; - - // Grab a new transaction from the memory manager - trans = m_mm.allocate(); - trans->acquire(); - - trans->set_command(cmd); - trans->set_address(adr); - trans->set_data_ptr(reinterpret_cast(&data[0])); - trans->set_data_length(64); - trans->set_streaming_width(4); - trans->set_byte_enable_ptr(nullptr); - trans->set_dmi_allowed(false); - trans->set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); - - // ExampleInitiator must honor BEGIN_REQ/END_REQ exclusion rule - if (request_in_progress) - wait(end_request_event); - request_in_progress = trans; - phase = tlm::BEGIN_REQ; - - // Timing annotation models processing time of initiator prior to call - delay = sc_core::sc_time(100000, sc_core::SC_PS); - - std::cout << "Address " << std::hex << adr << " new, cmd=" << (cmd ? "write" : "read") - << ", data=" << std::hex << data[0] << " at time " << sc_core::sc_time_stamp() - << " in " << name() << std::endl; - - GenerationExtension *genExtension = new GenerationExtension(sc_core::sc_time_stamp()); - trans->set_auto_extension(genExtension); - - - // Non-blocking transport call on the forward path - tlm::tlm_sync_enum status; - status = socket->nb_transport_fw( *trans, phase, delay ); - - // Check value returned from nb_transport_fw - if (status == tlm::TLM_UPDATED) { - // The timing annotation must be honored - m_peq.notify( *trans, phase, delay ); - } else if (status == tlm::TLM_COMPLETED) { - // The completion of the transaction necessarily ends the BEGIN_REQ phase - request_in_progress = nullptr; - - // The target has terminated the transaction - check_transaction( *trans ); - - // Allow the memory manager to free the transaction object - trans->release(); - } - - sc_core::wait(sc_core::sc_time(500, sc_core::SC_NS)); - - dump_mem(); - } - - sc_core::wait(sc_core::sc_time(500, sc_core::SC_NS)); - sc_core::sc_stop(); - } - - static void init_mem() - { - unsigned char buffer[64]; - for (unsigned char &i : buffer) - i = 0xff; - - for (int addr = 0; addr < 128; addr += 64) { - tlm::tlm_generic_payload trans; - trans.set_command( tlm::TLM_WRITE_COMMAND ); - trans.set_address( addr ); - trans.set_data_ptr( buffer ); - trans.set_data_length( 64 ); - - socket->transport_dbg( trans ); - } - } - - static void dump_mem() - { - for (int addr = 0; addr < 128; addr += 64) { - unsigned char buffer[64]; - tlm::tlm_generic_payload trans; - trans.set_command( tlm::TLM_READ_COMMAND ); - trans.set_address( addr ); - trans.set_data_ptr( buffer ); - trans.set_data_length( 64 ); - - socket->transport_dbg( trans ); - - std::cout << "\nMemory dump\n"; - for (int i = 0; i < 64; i++) - std::cout << "mem[" << addr + i << "] = " << std::hex << (int)buffer[i] << std::endl; - } - } - - // TLM-2 backward non-blocking transport method - - virtual tlm::tlm_sync_enum nb_transport_bw( tlm::tlm_generic_payload &trans, - tlm::tlm_phase &phase, sc_core::sc_time &delay ) - { - m_peq.notify( trans, phase, delay ); - return tlm::TLM_ACCEPTED; - } - - // Payload event queue callback to handle transactions from target - // Transaction could have arrived through return path or backward path - - void peq_cb(tlm::tlm_generic_payload &trans, const tlm::tlm_phase &phase) - { - if (phase == tlm::END_REQ || (&trans == request_in_progress - && phase == tlm::BEGIN_RESP)) { - // The end of the BEGIN_REQ phase - request_in_progress = nullptr; - end_request_event.notify(); - } else if (phase == tlm::BEGIN_REQ || phase == tlm::END_RESP) - SC_REPORT_FATAL("TLM-2", "Illegal transaction phase received by initiator"); - - if (phase == tlm::BEGIN_RESP) { - check_transaction( trans ); - - // Send final phase transition to target - tlm::tlm_phase fw_phase = tlm::END_RESP; - sc_core::sc_time delay = sc_core::sc_time(60000, sc_core::SC_PS); - socket->nb_transport_fw( trans, fw_phase, delay ); - // Ignore return value - - // Allow the memory manager to free the transaction object - trans.release(); - } - } - - // Called on receiving BEGIN_RESP or TLM_COMPLETED - void check_transaction(tlm::tlm_generic_payload &trans) - { - if ( trans.is_response_error() ) { - char txt[100]; - sprintf(txt, "Transaction returned with error, response status = %s", - trans.get_response_string().c_str()); - SC_REPORT_ERROR("TLM-2", txt); - } - - tlm::tlm_command cmd = trans.get_command(); - uint64_t adr = trans.get_address(); - int *ptr = reinterpret_cast( trans.get_data_ptr() ); - - std::cout << std::hex << adr << " check, cmd=" << (cmd ? "write" : "read") - << ", data=" << std::hex << *ptr << " at time " << sc_core::sc_time_stamp() - << " in " << sc_core::name() << std::endl; - - if (cmd == tlm::TLM_READ_COMMAND) - assert( *ptr == -int(adr) ); - } - - MemoryManager m_mm; - unsigned char data[64]; - tlm::tlm_generic_payload *request_in_progress; - sc_core::sc_event end_request_event; - tlm_utils::peq_with_cb_and_phase m_peq; -}; - -#endif // EXAMPLEINITIATOR_H diff --git a/src/simulator/simulator/LengthConverter.cpp b/src/simulator/simulator/LengthConverter.cpp deleted file mode 100644 index 288bf458..00000000 --- a/src/simulator/simulator/LengthConverter.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2022, Technische Universität 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: - * Lukas Steiner - */ - -#include "LengthConverter.h" - -using namespace sc_core; -using namespace tlm; - -// TODO: return status, TLM_INCOMPLETE_RESPONSE, acquire + release - -LengthConverter::LengthConverter(const sc_module_name &name, unsigned maxOutputLength, bool storageEnabled) : - sc_module(name), payloadEventQueue(this, &LengthConverter::peqCallback), storageEnabled(storageEnabled), - memoryManager(storageEnabled, maxOutputLength), maxOutputLength(maxOutputLength) -{ - iSocket.register_nb_transport_bw(this, &LengthConverter::nb_transport_bw); - tSocket.register_nb_transport_fw(this, &LengthConverter::nb_transport_fw); - tSocket.register_transport_dbg(this, &LengthConverter::transport_dbg); -} - -tlm_sync_enum LengthConverter::nb_transport_fw(tlm_generic_payload& trans, - tlm_phase& phase, sc_time& fwDelay) -{ - if (phase == BEGIN_REQ) - trans.acquire(); - - payloadEventQueue.notify(trans, phase, fwDelay); - return TLM_ACCEPTED; -} - -tlm_sync_enum LengthConverter::nb_transport_bw(tlm_generic_payload &payload, - tlm_phase &phase, sc_time &bwDelay) -{ - payloadEventQueue.notify(payload, phase, bwDelay); - return TLM_ACCEPTED; -} - -unsigned int LengthConverter::transport_dbg(tlm_generic_payload &trans) -{ - return iSocket->transport_dbg(trans); -} - -void LengthConverter::peqCallback(tlm_generic_payload &cbTrans, const tlm_phase &cbPhase) -{ - if (cbPhase == BEGIN_REQ) // from initiator - { - if (cbTrans.get_data_length() <= maxOutputLength) - { - // pipe transaction through - tlm_phase fwPhase = BEGIN_REQ; - sc_time fwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = iSocket->nb_transport_fw(cbTrans, fwPhase, fwDelay); - // TODO: END_REQ/BEGIN_RESP shortcut - } - else - { - // split transaction up into multiple sub-transactions - createChildTranses(&cbTrans); - tlm_generic_payload* firstChildTrans = cbTrans.get_extension()->getNextChildTrans(); - tlm_phase fwPhase = BEGIN_REQ; - sc_time fwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = iSocket->nb_transport_fw(*firstChildTrans, fwPhase, fwDelay); - } - } - else if (cbPhase == END_REQ) - { - if (ChildExtension::isChildTrans(&cbTrans)) - { - tlm_generic_payload* nextChildTrans = cbTrans.get_extension()->getNextChildTrans(); - if (nextChildTrans != nullptr) - { - tlm_phase fwPhase = BEGIN_REQ; - //sc_time fwDelay = SC_ZERO_TIME; - sc_time fwDelay = sc_time(1, SC_NS); - tlm_sync_enum returnStatus = iSocket->nb_transport_fw(*nextChildTrans, fwPhase, fwDelay); - } - else - { - tlm_generic_payload* parentTrans = cbTrans.get_extension()->getParentTrans(); - tlm_phase bwPhase = END_REQ; - sc_time bwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = tSocket->nb_transport_bw(*parentTrans, bwPhase, bwDelay); - } - } - else - { - tlm_phase bwPhase = END_REQ; - sc_time bwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = tSocket->nb_transport_bw(cbTrans, bwPhase, bwDelay); - } - } - else if (cbPhase == BEGIN_RESP) - { - if (ChildExtension::isChildTrans(&cbTrans)) - { - { - tlm_phase fwPhase = END_RESP; - sc_time fwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = iSocket->nb_transport_fw(cbTrans, fwPhase, fwDelay); - } - - if (storageEnabled && cbTrans.is_read()) - { - tlm_generic_payload* parentTrans = cbTrans.get_extension()->getParentTrans(); - std::copy(cbTrans.get_data_ptr(), cbTrans.get_data_ptr() + maxOutputLength, - parentTrans->get_data_ptr() + (cbTrans.get_address() - parentTrans->get_address())); - } - - if (cbTrans.get_extension()->notifyChildTransCompletion()) // all children finished - { - // BEGIN_RESP über tSocket - tlm_generic_payload* parentTrans = cbTrans.get_extension()->getParentTrans(); - tlm_phase bwPhase = BEGIN_RESP; - sc_time bwDelay = SC_ZERO_TIME; - parentTrans->set_response_status(tlm::TLM_OK_RESPONSE); - tlm_sync_enum returnStatus = tSocket->nb_transport_bw(*parentTrans, bwPhase, bwDelay); - } - } - else - { - tlm_phase bwPhase = BEGIN_RESP; - sc_time bwDelay = SC_ZERO_TIME; - cbTrans.set_response_status(tlm::TLM_OK_RESPONSE); - tlm_sync_enum returnStatus = tSocket->nb_transport_bw(cbTrans, bwPhase, bwDelay); - } - } - else if (cbPhase == END_RESP) - { - if (ParentExtension::isParentTrans(&cbTrans)) - { - cbTrans.get_extension()->releaseChildTranses(); - } - else - { - tlm_phase fwPhase = END_RESP; - sc_time fwDelay = SC_ZERO_TIME; - tlm_sync_enum returnStatus = iSocket->nb_transport_fw(cbTrans, fwPhase, fwDelay); - } - cbTrans.release(); - } - else - SC_REPORT_FATAL(0, "Payload event queue in LengthConverter was triggered with unknown phase"); -} - -void LengthConverter::createChildTranses(tlm_generic_payload* parentTrans) -{ - unsigned numChildTranses = parentTrans->get_data_length() / maxOutputLength; - std::vector childTranses; - - for (unsigned childId = 0; childId < numChildTranses; childId++) - { - tlm_generic_payload* childTrans = memoryManager.allocate(); - childTrans->acquire(); - childTrans->set_command(parentTrans->get_command()); - childTrans->set_address(parentTrans->get_address() + childId * maxOutputLength); - childTrans->set_data_length(maxOutputLength); - if (storageEnabled && parentTrans->is_write()) - std::copy(parentTrans->get_data_ptr() + childId * maxOutputLength, parentTrans->get_data_ptr() + - (childId + 1) * maxOutputLength, childTrans->get_data_ptr()); - ChildExtension::setExtension(childTrans, parentTrans); - childTranses.push_back(childTrans); - } - ParentExtension::setExtension(parentTrans, std::move(childTranses)); -} - -LengthConverter::MemoryManager::MemoryManager(bool storageEnabled, unsigned maxDataLength) - : storageEnabled(storageEnabled), maxDataLength(maxDataLength) -{} - -LengthConverter::MemoryManager::~MemoryManager() -{ - while (!freePayloads.empty()) - { - tlm_generic_payload* payload = freePayloads.top(); - if (storageEnabled) - delete[] payload->get_data_ptr(); - payload->reset(); - delete payload; - freePayloads.pop(); - } -} - -tlm_generic_payload* LengthConverter::MemoryManager::allocate() -{ - if (freePayloads.empty()) - { - auto* payload = new tlm_generic_payload(this); - - if (storageEnabled) - { - auto* data = new unsigned char[maxDataLength]; - payload->set_data_ptr(data); - } - return payload; - } - else - { - tlm_generic_payload* result = freePayloads.top(); - freePayloads.pop(); - return result; - } -} - -void LengthConverter::MemoryManager::free(tlm_generic_payload* payload) -{ - freePayloads.push(payload); -} \ No newline at end of file diff --git a/src/simulator/simulator/LengthConverter.h b/src/simulator/simulator/LengthConverter.h deleted file mode 100644 index bac9c29d..00000000 --- a/src/simulator/simulator/LengthConverter.h +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2022, Technische Universität 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: - * Lukas Steiner - */ - -#ifndef LENGTHCONVERTER_H -#define LENGTHCONVERTER_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -//TLM_DECLARE_EXTENDED_PHASE(REQ_ARBITRATION); -//TLM_DECLARE_EXTENDED_PHASE(RESP_ARBITRATION); - -class LengthConverter : public sc_core::sc_module -{ -public: - tlm_utils::simple_initiator_socket iSocket; - tlm_utils::simple_target_socket tSocket; - - LengthConverter(const sc_core::sc_module_name& name, unsigned maxOutputLength, bool storageEnabled); - SC_HAS_PROCESS(LengthConverter); - -private: - tlm_utils::peq_with_cb_and_phase payloadEventQueue; - void peqCallback(tlm::tlm_generic_payload &payload, const tlm::tlm_phase &phase); - - //std::vector tSocketIsBusy; - //std::vector iSocketIsBusy; - - const unsigned maxOutputLength; - const bool storageEnabled; - - void createChildTranses(tlm::tlm_generic_payload* parentTrans); - - //std::uint64_t getTargetAddress(std::uint64_t address) const; - //int getISocketId(std::uint64_t address) const; - - //std::vector> pendingRequests; - - tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &trans, tlm::tlm_phase &phase, - sc_core::sc_time &fwDelay); - tlm::tlm_sync_enum nb_transport_bw(tlm::tlm_generic_payload &payload, tlm::tlm_phase &phase, - sc_core::sc_time &bwDelay); - unsigned int transport_dbg(tlm::tlm_generic_payload &trans); - - class MemoryManager : public tlm::tlm_mm_interface - { - public: - MemoryManager(bool storageEnabled, unsigned maxDataLength); - ~MemoryManager() override; - tlm::tlm_generic_payload* allocate(); - void free(tlm::tlm_generic_payload* payload) override; - - private: - std::stack freePayloads; - bool storageEnabled = false; - unsigned maxDataLength; - } memoryManager; - - class ChildExtension : public tlm::tlm_extension - { - private: - tlm::tlm_generic_payload* parentTrans; - explicit ChildExtension(tlm::tlm_generic_payload* parentTrans) : parentTrans(parentTrans) {} - - public: - //ChildExtension() = delete; - - tlm_extension_base* clone() const override - { - return new ChildExtension(parentTrans); - } - - void copy_from(tlm_extension_base const &ext) override - { - const auto& cpyFrom = dynamic_cast(ext); - parentTrans = cpyFrom.parentTrans; - } - - tlm::tlm_generic_payload* getParentTrans() - { - return parentTrans; - } - - static void setExtension(tlm::tlm_generic_payload* childTrans, tlm::tlm_generic_payload* parentTrans) - { - auto *extension = childTrans->get_extension(); - - if (extension != nullptr) - { - extension->parentTrans = parentTrans; - } - else - { - extension = new ChildExtension(parentTrans); - childTrans->set_auto_extension(extension); - } - } - - static bool isChildTrans(const tlm::tlm_generic_payload* trans) - { - if (trans->get_extension() != nullptr) - return true; - else - return false; - } - - tlm::tlm_generic_payload* getNextChildTrans() - { - return parentTrans->get_extension()->getNextChildTrans(); - } - - bool notifyChildTransCompletion() - { - return parentTrans->get_extension()->notifyChildTransCompletion(); - } - }; - - class ParentExtension : public tlm::tlm_extension - { - private: - std::vector childTranses; - unsigned nextEndReqChildId = 0; - unsigned completedChildTranses = 0; - explicit ParentExtension(std::vector _childTranses) - : childTranses(std::move(_childTranses)) {} - - public: - ParentExtension() = delete; - - tlm_extension_base* clone() const override - { - return new ParentExtension(childTranses); - } - - void copy_from(tlm_extension_base const &ext) override - { - const auto& cpyFrom = dynamic_cast(ext); - childTranses = cpyFrom.childTranses; - } - - static bool isParentTrans(const tlm::tlm_generic_payload* trans) - { - auto* extension = trans->get_extension(); - if (extension != nullptr) - return !extension->childTranses.empty(); - else - return false; - } - - static void setExtension(tlm::tlm_generic_payload* parentTrans, std::vector childTranses) - { - auto* extension = parentTrans->get_extension(); - - if (extension != nullptr) - { - extension->childTranses = std::move(childTranses); - extension->nextEndReqChildId = 0; - extension->completedChildTranses = 0; - } - else - { - extension = new ParentExtension(std::move(childTranses)); - parentTrans->set_auto_extension(extension); - } - } - - tlm::tlm_generic_payload* getNextChildTrans() - { - if (nextEndReqChildId < childTranses.size()) - return childTranses[nextEndReqChildId++]; - else - return nullptr; - } - - bool notifyChildTransCompletion() - { - completedChildTranses++; - return completedChildTranses == childTranses.size(); - } - - void releaseChildTranses() - { - std::for_each(childTranses.begin(), childTranses.end(), - [](tlm::tlm_generic_payload* childTrans){childTrans->release();}); - childTranses.clear(); - } - }; -}; - -#endif // LENGTHCONVERTER_H diff --git a/src/simulator/simulator/MemoryManager.cpp b/src/simulator/simulator/MemoryManager.cpp index bc8b74f9..d83ba61d 100644 --- a/src/simulator/simulator/MemoryManager.cpp +++ b/src/simulator/simulator/MemoryManager.cpp @@ -36,8 +36,7 @@ #include "MemoryManager.h" -#include -#include +#include "DRAMSys/common/DebugManager.h" using namespace tlm; diff --git a/src/simulator/simulator/MemoryManager.h b/src/simulator/simulator/MemoryManager.h index 31179c10..3edd23c3 100644 --- a/src/simulator/simulator/MemoryManager.h +++ b/src/simulator/simulator/MemoryManager.h @@ -39,7 +39,6 @@ #include #include - #include class MemoryManager : public tlm::tlm_mm_interface diff --git a/src/simulator/simulator/StlPlayer.cpp b/src/simulator/simulator/StlPlayer.cpp index f02c703f..967206c5 100644 --- a/src/simulator/simulator/StlPlayer.cpp +++ b/src/simulator/simulator/StlPlayer.cpp @@ -215,7 +215,7 @@ void StlPlayer::parseTraceFile() } } -std::vector::const_iterator StlPlayer::swapBuffers() +std::vector::const_iterator StlPlayer::swapBuffers() { // Wait for parser to finish if (parserThread.joinable()) diff --git a/src/simulator/simulator/StlPlayer.h b/src/simulator/simulator/StlPlayer.h index e2e995b8..35406468 100644 --- a/src/simulator/simulator/StlPlayer.h +++ b/src/simulator/simulator/StlPlayer.h @@ -41,25 +41,16 @@ #ifndef STLPLAYER_H #define STLPLAYER_H +#include "simulator/TraceSetup.h" +#include "simulator/TrafficInitiator.h" + #include #include #include #include #include - #include #include -#include "TraceSetup.h" -#include "TrafficInitiator.h" - -struct LineContent -{ - sc_core::sc_time sendingTime; - unsigned dataLength; - tlm::tlm_command command; - uint64_t address; - std::vector data; -}; class StlPlayer : public TrafficInitiator { @@ -78,6 +69,15 @@ public: uint64_t getNumberOfLines() const; private: + struct LineContent + { + sc_core::sc_time sendingTime; + unsigned dataLength; + tlm::tlm_command command; + uint64_t address; + std::vector data; + }; + void parseTraceFile(); std::vector::const_iterator swapBuffers(); diff --git a/src/simulator/simulator/TraceSetup.cpp b/src/simulator/simulator/TraceSetup.cpp index 2f7b2c66..2af57f0a 100644 --- a/src/simulator/simulator/TraceSetup.cpp +++ b/src/simulator/simulator/TraceSetup.cpp @@ -36,8 +36,10 @@ */ #include "TraceSetup.h" -#include "StlPlayer.h" -#include "TrafficGenerator.h" + +#include "simulator/StlPlayer.h" +#include "simulator/TrafficGenerator.h" + #include #include #include @@ -113,7 +115,7 @@ TraceSetup::TraceSetup(const Configuration& config, } else if constexpr (std::is_same_v) { - TrafficGenerator *trafficGenerator = new TrafficGenerator(name.c_str(), config, initiator, *this); + auto* trafficGenerator = new TrafficGenerator(name.c_str(), config, initiator, *this); players.push_back(std::unique_ptr(trafficGenerator)); totalTransactions += trafficGenerator->getTotalTransactions(); diff --git a/src/simulator/simulator/TraceSetup.h b/src/simulator/simulator/TraceSetup.h index fa20bbbe..57913573 100644 --- a/src/simulator/simulator/TraceSetup.h +++ b/src/simulator/simulator/TraceSetup.h @@ -37,17 +37,16 @@ #ifndef TRACESETUP_H #define TRACESETUP_H -#include +#include "simulator/MemoryManager.h" -#include +#include "DRAMSys/config/DRAMSysConfiguration.h" +#include "DRAMSys/configuration/Configuration.h" #include #include #include #include -#include "MemoryManager.h" - class TrafficInitiator; class TraceSetup diff --git a/src/simulator/simulator/TrafficGenerator.cpp b/src/simulator/simulator/TrafficGenerator.cpp index 148f807e..abcc5878 100644 --- a/src/simulator/simulator/TrafficGenerator.cpp +++ b/src/simulator/simulator/TrafficGenerator.cpp @@ -37,7 +37,8 @@ */ #include "TrafficGenerator.h" -#include "TraceSetup.h" + +#include "simulator/TraceSetup.h" #include diff --git a/src/simulator/simulator/TrafficGenerator.h b/src/simulator/simulator/TrafficGenerator.h index 4176cbee..7732fa9d 100644 --- a/src/simulator/simulator/TrafficGenerator.h +++ b/src/simulator/simulator/TrafficGenerator.h @@ -39,13 +39,13 @@ #ifndef TRAFFICGENERATOR_H #define TRAFFICGENERATOR_H +#include "simulator/TrafficInitiator.h" +#include "simulator/TraceSetup.h" + #include #include #include -#include -#include - class TrafficGeneratorIf : public TrafficInitiator { public: diff --git a/src/simulator/simulator/TrafficInitiator.cpp b/src/simulator/simulator/TrafficInitiator.cpp index ca24082b..70c4eeae 100644 --- a/src/simulator/simulator/TrafficInitiator.cpp +++ b/src/simulator/simulator/TrafficInitiator.cpp @@ -129,7 +129,7 @@ bool TrafficInitiator::nextPayloadSendable() const return true; } -sc_core::sc_time TrafficInitiator::evaluateGeneratorClk(const DRAMSys::Config::TrafficInitiator &conf) +sc_core::sc_time TrafficInitiator::evaluateGeneratorClk(const DRAMSys::Config::TrafficInitiator& conf) { double frequencyMHz = conf.clkMhz; sc_time playerClk = sc_time(1.0 / frequencyMHz, SC_US); diff --git a/src/simulator/simulator/TrafficInitiator.h b/src/simulator/simulator/TrafficInitiator.h index 00324649..ad3b00ca 100644 --- a/src/simulator/simulator/TrafficInitiator.h +++ b/src/simulator/simulator/TrafficInitiator.h @@ -40,20 +40,19 @@ #ifndef TRAFFICINITIATOR_H #define TRAFFICINITIATOR_H +#include "simulator/TraceSetup.h" + +#include "DRAMSys/configuration/Configuration.h" +#include "DRAMSys/common/DebugManager.h" + #include #include #include - #include #include #include #include -#include -#include - -#include - class TrafficInitiator : public sc_core::sc_module { public: diff --git a/src/simulator/simulator/main.cpp b/src/simulator/simulator/main.cpp index 4d6d468b..6255f93a 100644 --- a/src/simulator/simulator/main.cpp +++ b/src/simulator/simulator/main.cpp @@ -37,26 +37,22 @@ * Derek Christ */ +#include "simulator/TraceSetup.h" +#include "simulator/TrafficInitiator.h" + +#include "DRAMSys/simulation/DRAMSys.h" +#ifdef RECORDING +#include "DRAMSys/simulation/DRAMSysRecordable.h" +#endif +#include "DRAMSys/config/DRAMSysConfiguration.h" + #include #include #include -#include #include -#include #include -#include -#include #include -#include - -#include -#include - -#ifdef RECORDING -#include "simulation/DRAMSysRecordable.h" -#endif - using namespace sc_core; std::string pathOfFile(const std::string &file) diff --git a/src/util/DRAMSys/util/json.h b/src/util/DRAMSys/util/json.h index 7270acca..f184f8a1 100644 --- a/src/util/DRAMSys/util/json.h +++ b/src/util/DRAMSys/util/json.h @@ -37,7 +37,7 @@ #ifndef DRAMSYS_UTIL_JSON_H #define DRAMSYS_UTIL_JSON_H -#include +#include "nlohmann/json.hpp" #include