From b1efbb8721c65ac822171e845cb12100d03a8fa0 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Fri, 27 Mar 2020 15:29:58 +0100 Subject: [PATCH] Code cleanup for open sourcing. --- DRAMSys/library/CMakeLists.txt | 29 ++++---- .../library/src/common/XmlAddressDecoder.cpp | 4 +- .../library/src/common/timingCalculations.cpp | 71 ------------------- .../library/src/common/timingCalculations.h | 52 -------------- .../src/configuration/ConfigurationLoader.cpp | 3 +- DRAMSys/library/src/controller/Controller.cpp | 2 +- DRAMSys/library/src/controller/Controller.h | 4 +- .../{GenericController.h => ControllerIF.h} | 24 +++---- DRAMSys/library/src/simulation/Arbiter.h | 1 - DRAMSys/library/src/simulation/DRAMSys.cpp | 2 +- DRAMSys/library/src/simulation/DRAMSys.h | 5 +- .../library/src/simulation/TraceGenerator.h | 2 +- DRAMSys/library/src/simulation/TracePlayer.h | 1 - DRAMSys/library/src/simulation/TraceSetup.cpp | 9 ++- DRAMSys/library/src/simulation/dram/Dram.cpp | 1 - 15 files changed, 43 insertions(+), 167 deletions(-) delete mode 100644 DRAMSys/library/src/common/timingCalculations.cpp delete mode 100644 DRAMSys/library/src/common/timingCalculations.h rename DRAMSys/library/src/controller/{GenericController.h => ControllerIF.h} (81%) diff --git a/DRAMSys/library/CMakeLists.txt b/DRAMSys/library/CMakeLists.txt index 5df9597d..f0b04c92 100644 --- a/DRAMSys/library/CMakeLists.txt +++ b/DRAMSys/library/CMakeLists.txt @@ -65,17 +65,16 @@ include_directories( ) add_library(DRAMSysLibrary - src/common/third_party/tinyxml2/tinyxml2.cpp - src/common/TlmRecorder.cpp - src/common/DebugManager.cpp - src/common/CongenAddressDecoder.cpp - src/common/XmlAddressDecoder.cpp - src/common/timingCalculations.cpp - src/common/dramExtensions.cpp - src/common/utils.cpp src/common/AddressDecoder.cpp + src/common/CongenAddressDecoder.cpp + src/common/DebugManager.cpp + src/common/dramExtensions.cpp src/common/protocol.h src/common/tlm2_base_protocol_checker.h + src/common/TlmRecorder.cpp + src/common/utils.cpp + src/common/XmlAddressDecoder.cpp + src/common/third_party/tinyxml2/tinyxml2.cpp src/configuration/Configuration.cpp src/configuration/ConfigurationLoader.cpp @@ -94,7 +93,7 @@ add_library(DRAMSysLibrary src/controller/BankMachine.cpp src/controller/Command.cpp - src/controller/GenericController.h + src/controller/ControllerIF.h src/controller/Controller.cpp src/controller/ControllerRecordable.cpp @@ -141,12 +140,18 @@ add_library(DRAMSysLibrary src/simulation/Arbiter.cpp src/simulation/DRAMSys.cpp + src/simulation/ExampleInitiator.h + src/simulation/IArbiter.h src/simulation/MemoryManager.cpp + src/simulation/ReorderBuffer.h src/simulation/Setup.cpp - src/simulation/TemperatureController.cpp - src/simulation/TracePlayer.cpp - src/simulation/TraceSetup.cpp + src/simulation/SimpleArbiter.h src/simulation/StlPlayer.h + src/simulation/TemperatureController.cpp + src/simulation/TraceGenerator.h + src/simulation/TracePlayer.cpp + src/simulation/TracePlayerListener.h + src/simulation/TraceSetup.cpp src/simulation/dram/Dram.cpp src/simulation/dram/DramRecordable.cpp diff --git a/DRAMSys/library/src/common/XmlAddressDecoder.cpp b/DRAMSys/library/src/common/XmlAddressDecoder.cpp index 0dcc2d5d..c5c8d0ca 100644 --- a/DRAMSys/library/src/common/XmlAddressDecoder.cpp +++ b/DRAMSys/library/src/common/XmlAddressDecoder.cpp @@ -124,10 +124,10 @@ void XmlAddressDecoder::setConfiguration(std::string addressConfigURI) Configuration &config = Configuration::getInstance(); MemSpec *memSpec = config.memSpec; - if (config.NumberOfMemChannels != amount.channel || memSpec->NumberOfRanks != amount.rank + if (config.numberOfMemChannels != amount.channel || memSpec->NumberOfRanks != amount.rank || memSpec->NumberOfBankGroups != amount.bankgroup || memSpec->NumberOfBanks != amount.bank || memSpec->NumberOfRows != amount.row || memSpec->NumberOfColumns != amount.column - || config.NumberOfDevicesOnDIMM * memSpec->bitWidth != amount.bytes * 8) + || config.numberOfDevicesOnDIMM * memSpec->bitWidth != amount.bytes * 8) SC_REPORT_FATAL("XmlAddressDecoder", "Memspec and addressmapping do not match"); } diff --git a/DRAMSys/library/src/common/timingCalculations.cpp b/DRAMSys/library/src/common/timingCalculations.cpp deleted file mode 100644 index be69fb44..00000000 --- a/DRAMSys/library/src/common/timingCalculations.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 "timingCalculations.h" -#include "../configuration/memspec/MemSpec.h" -#include "DebugManager.h" -#include "../configuration/Configuration.h" -#include "utils.h" - -sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, - sc_time constraint) -{ - if (previous + constraint > start) - return previous + constraint - start; - else - return SC_ZERO_TIME; -} - -const sc_time FrequencyToClk(double frequencyMhz) -{ - return sc_time(1 / frequencyMhz, SC_US); -} - -const sc_time clkAlign(sc_time time, Alignment alignment) -{ - sc_time clk = Configuration::getInstance().memSpec->clk; - if (alignment == UP) - return ceil(time / clk) * clk; - else - return floor(time / clk) * clk; -} - -bool isClkAligned(sc_time time, sc_time clk) -{ - return !((time / clk) - ceil(time / clk)); -} - - diff --git a/DRAMSys/library/src/common/timingCalculations.h b/DRAMSys/library/src/common/timingCalculations.h deleted file mode 100644 index 7288b93c..00000000 --- a/DRAMSys/library/src/common/timingCalculations.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 - */ - -#ifndef TIMINGCALCULATIONS_H -#define TIMINGCALCULATIONS_H - -#include -#include -#include "dramExtensions.h" - -sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, - sc_time constraint); - -enum Alignment {UP, DOWN}; -const sc_time clkAlign(sc_time time, Alignment alignment = UP); -bool isClkAligned(sc_time time, sc_time clk); -const sc_time FrequencyToClk(double frequencyMhz); - -#endif // TIMINGCALCULATIONS_H diff --git a/DRAMSys/library/src/configuration/ConfigurationLoader.cpp b/DRAMSys/library/src/configuration/ConfigurationLoader.cpp index d0bf8cfa..60fff667 100644 --- a/DRAMSys/library/src/configuration/ConfigurationLoader.cpp +++ b/DRAMSys/library/src/configuration/ConfigurationLoader.cpp @@ -46,7 +46,6 @@ #include "memspec/MemSpecGDDR5.h" #include "memspec/MemSpecGDDR5X.h" #include "memspec/MemSpecGDDR6.h" -#include "../common/timingCalculations.h" using namespace tinyxml2; using namespace std; @@ -225,7 +224,7 @@ void ConfigurationLoader::loadCommons(Configuration &config, XMLElement *xmlSpec // Clock XMLElement *timings = xmlSpec->FirstChildElement("memtimingspec"); memSpec->clkMHz = queryDoubleParameter(timings, "clkMhz"); - memSpec->clk = FrequencyToClk(memSpec->clkMHz); + memSpec->clk = sc_time(1.0 / memSpec->clkMHz, SC_US); } void ConfigurationLoader::loadDDR3(Configuration &config, XMLElement *xmlSpec) diff --git a/DRAMSys/library/src/controller/Controller.cpp b/DRAMSys/library/src/controller/Controller.cpp index 80d5d3df..2831a030 100644 --- a/DRAMSys/library/src/controller/Controller.cpp +++ b/DRAMSys/library/src/controller/Controller.cpp @@ -60,7 +60,7 @@ #include "powerdown/PowerDownManagerDummy.h" Controller::Controller(sc_module_name name) : - GenericController(name) + ControllerIF(name) { SC_METHOD(controllerMethod); sensitive << beginReqEvent << endRespEvent << controllerEvent << dataResponseEvent; diff --git a/DRAMSys/library/src/controller/Controller.h b/DRAMSys/library/src/controller/Controller.h index f9ab37f9..53ba66cf 100644 --- a/DRAMSys/library/src/controller/Controller.h +++ b/DRAMSys/library/src/controller/Controller.h @@ -42,7 +42,7 @@ #include #include #include -#include "GenericController.h" +#include "ControllerIF.h" #include "../common/dramExtensions.h" #include "BankMachine.h" #include "cmdmux/CmdMuxIF.h" @@ -59,7 +59,7 @@ class BankMachine; class SchedulerIF; class PowerDownManagerStaggered; -class Controller : public GenericController +class Controller : public ControllerIF { public: Controller(sc_module_name); diff --git a/DRAMSys/library/src/controller/GenericController.h b/DRAMSys/library/src/controller/ControllerIF.h similarity index 81% rename from DRAMSys/library/src/controller/GenericController.h rename to DRAMSys/library/src/controller/ControllerIF.h index 113b3dbc..6abe4569 100644 --- a/DRAMSys/library/src/controller/GenericController.h +++ b/DRAMSys/library/src/controller/ControllerIF.h @@ -1,5 +1,5 @@ -#ifndef GENERICCONTROLLER_H -#define GENERICCONTROLLER_H +#ifndef CONTROLLERIF_H +#define CONTROLLERIF_H #include #include @@ -11,15 +11,15 @@ using namespace tlm; // Utiliy class to pass around the DRAMSys, without having to propagate the template defintions // throughout all classes -class GenericController : public sc_module +class ControllerIF : public sc_module { public: // Already create and bind sockets to the virtual functions - tlm_utils::simple_target_socket tSocket; // Arbiter side - tlm_utils::simple_initiator_socket iSocket; // DRAM side + tlm_utils::simple_target_socket tSocket; // Arbiter side + tlm_utils::simple_initiator_socket iSocket; // DRAM side // Destructor - virtual ~GenericController() + virtual ~ControllerIF() { sc_time activeTime = numberOfTransactionsServed * Configuration::getInstance().memSpec->BurstLength @@ -60,14 +60,14 @@ public: protected: // Bind sockets with virtual functions - GenericController(sc_module_name name) : + ControllerIF(sc_module_name name) : sc_module(name), tSocket("tSocket"), iSocket("iSocket") { - tSocket.register_nb_transport_fw(this, &GenericController::nb_transport_fw); - tSocket.register_transport_dbg(this, &GenericController::transport_dbg); - iSocket.register_nb_transport_bw(this, &GenericController::nb_transport_bw); + tSocket.register_nb_transport_fw(this, &ControllerIF::nb_transport_fw); + tSocket.register_transport_dbg(this, &ControllerIF::transport_dbg); + iSocket.register_nb_transport_bw(this, &ControllerIF::nb_transport_bw); } - SC_HAS_PROCESS(GenericController); + SC_HAS_PROCESS(ControllerIF); // Virtual transport functions virtual tlm_sync_enum nb_transport_fw(tlm_generic_payload &, tlm_phase &, sc_time &) = 0; @@ -80,4 +80,4 @@ protected: }; -#endif // GENERICCONTROLLER_H +#endif // CONTROLLERIF_H diff --git a/DRAMSys/library/src/simulation/Arbiter.h b/DRAMSys/library/src/simulation/Arbiter.h index b8576eda..beb1771d 100644 --- a/DRAMSys/library/src/simulation/Arbiter.h +++ b/DRAMSys/library/src/simulation/Arbiter.h @@ -48,7 +48,6 @@ #include #include "../common/XmlAddressDecoder.h" #include "../common/dramExtensions.h" -#include "../common/timingCalculations.h" #include "../configuration/ConfigurationLoader.h" using namespace std; diff --git a/DRAMSys/library/src/simulation/DRAMSys.cpp b/DRAMSys/library/src/simulation/DRAMSys.cpp index 5224d926..2ae31554 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.cpp +++ b/DRAMSys/library/src/simulation/DRAMSys.cpp @@ -253,7 +253,7 @@ void DRAMSys::instantiateModules(const string &traceName, { std::string str = "controller" + std::to_string(i); - GenericController *controller; + ControllerIF *controller; if (recordingEnabled) controller = new ControllerRecordable(str.c_str(), tlmRecorders[i]); else diff --git a/DRAMSys/library/src/simulation/DRAMSys.h b/DRAMSys/library/src/simulation/DRAMSys.h index 354241f0..9c838c97 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.h +++ b/DRAMSys/library/src/simulation/DRAMSys.h @@ -51,7 +51,7 @@ #include "../common/third_party/tinyxml2/tinyxml2.h" #include "../common/tlm2_base_protocol_checker.h" #include "../error/eccbaseclass.h" -#include "../controller/GenericController.h" +#include "../controller/ControllerIF.h" #include "../common/TlmRecorder.h" class DRAMSys : public sc_module @@ -87,8 +87,7 @@ private: // All transactions pass through the same arbiter Arbiter *arbiter; // Each DRAM unit has a controller - std::vector controllers; - //std::vector controllers; + std::vector controllers; // TODO: Each DRAM has a reorder buffer (check this!) ReorderBuffer *reorder; diff --git a/DRAMSys/library/src/simulation/TraceGenerator.h b/DRAMSys/library/src/simulation/TraceGenerator.h index 4631c5a9..47be2a16 100644 --- a/DRAMSys/library/src/simulation/TraceGenerator.h +++ b/DRAMSys/library/src/simulation/TraceGenerator.h @@ -52,7 +52,7 @@ public: if (clkMhz == 0) clk = Configuration::getInstance().memSpec->clk; else - clk = FrequencyToClk(clkMhz); + clk = sc_time(1.0 / clkMhz, SC_US); this->burstlenght = Configuration::getInstance().memSpec->BurstLength; } diff --git a/DRAMSys/library/src/simulation/TracePlayer.h b/DRAMSys/library/src/simulation/TracePlayer.h index 4bb1fdbd..4d3f4f7c 100644 --- a/DRAMSys/library/src/simulation/TracePlayer.h +++ b/DRAMSys/library/src/simulation/TracePlayer.h @@ -50,7 +50,6 @@ #include "../configuration/Configuration.h" #include "../common/DebugManager.h" #include "../common/XmlAddressDecoder.h" -#include "../common/timingCalculations.h" #include "TracePlayerListener.h" using namespace std; diff --git a/DRAMSys/library/src/simulation/TraceSetup.cpp b/DRAMSys/library/src/simulation/TraceSetup.cpp index 53922968..18f9fdae 100644 --- a/DRAMSys/library/src/simulation/TraceSetup.cpp +++ b/DRAMSys/library/src/simulation/TraceSetup.cpp @@ -61,13 +61,12 @@ traceSetup::traceSetup(std::string uri, device = device->NextSiblingElement("device")) { sc_time playerClk; - unsigned int frequency = device->IntAttribute("clkMhz"); + unsigned int frequencyMHz = device->IntAttribute("clkMhz"); - if (frequency == 0) { + if (frequencyMHz == 0) reportFatal("traceSetup", "No Frequency Defined"); - } else { - playerClk = FrequencyToClk(frequency); - } + else + playerClk = sc_time(1.0 / frequencyMHz, SC_US); std::string name = device->GetText(); diff --git a/DRAMSys/library/src/simulation/dram/Dram.cpp b/DRAMSys/library/src/simulation/dram/Dram.cpp index ed0ffc01..7c0f9369 100644 --- a/DRAMSys/library/src/simulation/dram/Dram.cpp +++ b/DRAMSys/library/src/simulation/dram/Dram.cpp @@ -54,7 +54,6 @@ #include #include "../../common/DebugManager.h" #include "../../common/dramExtensions.h" -#include "../../common/timingCalculations.h" #include "../../configuration/Configuration.h" #include "../../common/protocol.h" #include "../../common/utils.h"