diff --git a/DRAMSys/library/library.pro b/DRAMSys/library/library.pro index 21ee97ad..acf9a8af 100644 --- a/DRAMSys/library/library.pro +++ b/DRAMSys/library/library.pro @@ -157,7 +157,8 @@ SOURCES += \ src/controller/cmdmux/CmdMuxOldest.cpp \ src/controller/ControllerRecordable.cpp \ src/controller/checker/CheckerDDR3.cpp \ - src/controller/RefreshManager.cpp + src/controller/refresh/RefreshManager.cpp \ + src/controller/refresh/RefreshManagerDummy.cpp HEADERS += \ src/common/third_party/tinyxml2/tinyxml2.h \ @@ -251,7 +252,9 @@ HEADERS += \ src/controller/ControllerRecordable.h \ src/controller/checker/CheckerIF.h \ src/controller/checker/CheckerDDR3.h \ - src/controller/RefreshManager.h + src/controller/refresh/RefreshManagerIF.h \ + src/controller/refresh/RefreshManager.h \ + src/controller/refresh/RefreshManagerDummy.h #src/common/third_party/json/include/nlohmann/json.hpp \ thermalsim = $$(THERMALSIM) diff --git a/DRAMSys/library/src/controller/ControllerNew.cpp b/DRAMSys/library/src/controller/ControllerNew.cpp index d6e9bba1..99316ec5 100644 --- a/DRAMSys/library/src/controller/ControllerNew.cpp +++ b/DRAMSys/library/src/controller/ControllerNew.cpp @@ -43,7 +43,8 @@ #include "../common/protocol.h" #include "core/scheduling/ScheduledCommand.h" #include "checker/CheckerDDR3.h" -#include "RefreshManager.h" +#include "refresh/RefreshManager.h" +#include "refresh/RefreshManagerDummy.h" ControllerNew::ControllerNew(sc_module_name name) : GenericController(name) @@ -52,13 +53,30 @@ ControllerNew::ControllerNew(sc_module_name name) : sensitive << triggerEvent << triggerEventQueue; dont_initialize(); + Configuration config = Configuration::getInstance(); + checker = new CheckerDDR3(); - refreshManager = new RefreshManager(); - triggerEventQueue.notify(refreshManager->getInitialDelay()); - scheduler = new SchedulerFifo(); + if (config.ControllerCoreRefDisable) + refreshManager = new RefreshManagerDummy(); + else + { + refreshManager = new RefreshManager(); + triggerEventQueue.notify(refreshManager->getInitialDelay()); + } + if (config.Scheduler == "FifoStrict") + { + scheduler = new SchedulerFifo(); + commandMux = new CmdMuxStrict(); + } + else if (config.Scheduler == "FrFcfs") + { + scheduler = new SchedulerFrFcfs(); + commandMux = new CmdMuxOldest(); + } + else + SC_REPORT_FATAL("ControllerNew", "Selected scheduler not supported"); for (unsigned bankID = 0; bankID < Configuration::getInstance().memSpec->NumberOfBanks; bankID++) bankMachines[Bank(bankID)] = new BankMachine(scheduler, checker, Bank(bankID)); - commandMux = new CmdMuxStrict(); startBandwidthIdleCollector(); } diff --git a/DRAMSys/library/src/controller/ControllerNew.h b/DRAMSys/library/src/controller/ControllerNew.h index c8d7c3ca..0ed2e785 100644 --- a/DRAMSys/library/src/controller/ControllerNew.h +++ b/DRAMSys/library/src/controller/ControllerNew.h @@ -50,7 +50,7 @@ #include "scheduler/SchedulerIF.h" #include "../common/DebugManager.h" #include "checker/CheckerIF.h" -#include "RefreshManager.h" +#include "refresh/RefreshManagerIF.h" using namespace tlm; @@ -84,7 +84,7 @@ private: CmdMuxIF *commandMux; SchedulerIF *scheduler; CheckerIF *checker; - RefreshManager *refreshManager; + RefreshManagerIF *refreshManager; void releasePayload(); void acquirePayload(); diff --git a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp index 1bb36603..fe8a8391 100644 --- a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp @@ -34,6 +34,25 @@ #include "CheckerDDR3.h" +CheckerDDR3::CheckerDDR3() +{ + Configuration config = Configuration::getInstance(); + memSpec = dynamic_cast(config.memSpec); + if (memSpec == nullptr) + SC_REPORT_FATAL("CheckerDDR3", "Wrong MemSpec chosen"); + + if (config.ControllerCoreRefDisable) + { + timeForNextREFA = sc_max_time(); + timeForNextPREA = sc_max_time(); + } + else + { + timeForNextREFA = memSpec->tREFI; + timeForNextPREA = timeForNextREFA - memSpec->tRP; + } +} + sc_time CheckerDDR3::delayToSatisfyConstraints(Command command, Bank bank) { ScheduledCommand lastCommand; diff --git a/DRAMSys/library/src/controller/checker/CheckerDDR3.h b/DRAMSys/library/src/controller/checker/CheckerDDR3.h index f4acd019..1deeb7fa 100644 --- a/DRAMSys/library/src/controller/checker/CheckerDDR3.h +++ b/DRAMSys/library/src/controller/checker/CheckerDDR3.h @@ -43,16 +43,7 @@ class CheckerDDR3 final : public CheckerIF { public: - CheckerDDR3() - { - memSpec = dynamic_cast(Configuration::getInstance().memSpec); - if (memSpec == nullptr) - SC_REPORT_FATAL("CheckerDDR3", "Wrong MemSpec chosen"); - - timeForNextREFA = memSpec->tREFI; - timeForNextPREA = timeForNextREFA - memSpec->tRP; - } - + CheckerDDR3(); sc_time delayToSatisfyConstraints(Command, Bank); void insert(const ScheduledCommand &); diff --git a/DRAMSys/library/src/controller/RefreshManager.cpp b/DRAMSys/library/src/controller/refresh/RefreshManager.cpp similarity index 97% rename from DRAMSys/library/src/controller/RefreshManager.cpp rename to DRAMSys/library/src/controller/refresh/RefreshManager.cpp index 6e616556..9ae16379 100644 --- a/DRAMSys/library/src/controller/RefreshManager.cpp +++ b/DRAMSys/library/src/controller/refresh/RefreshManager.cpp @@ -33,8 +33,8 @@ */ #include "RefreshManager.h" -#include "../common/dramExtensions.h" -#include "core/configuration/Configuration.h" +#include "../../common/dramExtensions.h" +#include "../core/configuration/Configuration.h" RefreshManager::RefreshManager() { @@ -79,5 +79,3 @@ sc_time RefreshManager::getInitialDelay() { return timeForNextPREA; } - - diff --git a/DRAMSys/library/src/controller/RefreshManager.h b/DRAMSys/library/src/controller/refresh/RefreshManager.h similarity index 93% rename from DRAMSys/library/src/controller/RefreshManager.h rename to DRAMSys/library/src/controller/refresh/RefreshManager.h index dc150e80..2882d342 100644 --- a/DRAMSys/library/src/controller/RefreshManager.h +++ b/DRAMSys/library/src/controller/refresh/RefreshManager.h @@ -38,8 +38,9 @@ #include #include #include -#include "Command.h" -#include "core/configuration/MemSpec.h" +#include "RefreshManagerIF.h" +#include "../Command.h" +#include "../core/configuration/MemSpec.h" using namespace tlm; @@ -49,7 +50,7 @@ enum class RmState REFRESHING }; -class RefreshManager +class RefreshManager final : public RefreshManagerIF { public: RefreshManager(); diff --git a/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.cpp b/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.cpp new file mode 100644 index 00000000..8a1fa224 --- /dev/null +++ b/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2019, 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. + * + * Author: Lukas Steiner + */ + +#include "RefreshManagerDummy.h" + +std::pair RefreshManagerDummy::getNextCommand() +{ + return std::pair(Command::NOP, nullptr); +} + +sc_time RefreshManagerDummy::updateState() +{ + return SC_ZERO_TIME; +} + +sc_time RefreshManagerDummy::getInitialDelay() +{ + return SC_ZERO_TIME; +} diff --git a/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.h b/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.h new file mode 100644 index 00000000..8031d82c --- /dev/null +++ b/DRAMSys/library/src/controller/refresh/RefreshManagerDummy.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019, 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. + * + * Author: Lukas Steiner + */ + +#ifndef REFRESHMANAGERDUMMY_H +#define REFRESHMANAGERDUMMY_H + +#include +#include +#include +#include "RefreshManagerIF.h" +#include "../Command.h" + +using namespace tlm; + +class RefreshManagerDummy final : public RefreshManagerIF +{ +public: + std::pair getNextCommand(); + sc_time updateState(); + sc_time getInitialDelay(); +}; + +#endif // REFRESHMANAGERDUMMY_H diff --git a/DRAMSys/library/src/controller/refresh/RefreshManagerIF.h b/DRAMSys/library/src/controller/refresh/RefreshManagerIF.h new file mode 100644 index 00000000..94999460 --- /dev/null +++ b/DRAMSys/library/src/controller/refresh/RefreshManagerIF.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2019, 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. + * + * Author: Lukas Steiner + */ + +#ifndef REFRESHMANAGERIF_H +#define REFRESHMANAGERIF_H + +#include +#include +#include +#include "../Command.h" + +using namespace tlm; + +class RefreshManagerIF +{ +public: + virtual ~RefreshManagerIF() {} + + virtual std::pair getNextCommand() = 0; + virtual sc_time updateState() = 0; + virtual sc_time getInitialDelay() = 0; +}; + +#endif // REFRESHMANAGERIF_H