From a6ce8f63cbe8fa5e2e141eb4cfc98347f8469d04 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Fri, 22 Jan 2021 15:54:37 +0100 Subject: [PATCH] Improve command mux for multicycle commands, RAS/CAS bus missing. --- DRAMSys/library/src/controller/Controller.cpp | 15 +++++-- .../src/controller/cmdmux/CmdMuxOldest.cpp | 26 ++++++++---- .../src/controller/cmdmux/CmdMuxOldest.h | 5 +++ .../src/controller/cmdmux/CmdMuxStrict.cpp | 40 +++++++++++++++---- .../src/controller/cmdmux/CmdMuxStrict.h | 3 ++ 5 files changed, 71 insertions(+), 18 deletions(-) diff --git a/DRAMSys/library/src/controller/Controller.cpp b/DRAMSys/library/src/controller/Controller.cpp index 9c103ee6..3576ddc6 100644 --- a/DRAMSys/library/src/controller/Controller.cpp +++ b/DRAMSys/library/src/controller/Controller.cpp @@ -322,16 +322,25 @@ void Controller::controllerMethod() // (6) Restart bank machines, refresh managers and power-down managers to issue new requests for the future sc_time timeForNextTrigger = sc_max_time(); + sc_time localTime; for (auto it : bankMachines) { - sc_time localTime = it->start(); + localTime = it->start(); if (!(localTime == sc_time_stamp() && readyCmdBlocked)) timeForNextTrigger = std::min(timeForNextTrigger, localTime); } for (auto it : refreshManagers) - timeForNextTrigger = std::min(timeForNextTrigger, it->start()); + { + localTime = it->start(); + if (!(localTime == sc_time_stamp() && readyCmdBlocked)) + timeForNextTrigger = std::min(timeForNextTrigger, localTime); + } for (auto it : powerDownManagers) - timeForNextTrigger = std::min(timeForNextTrigger, it->start()); + { + localTime = it->start(); + if (!(localTime == sc_time_stamp() && readyCmdBlocked)) + timeForNextTrigger = std::min(timeForNextTrigger, localTime); + } if (timeForNextTrigger != sc_max_time()) controllerEvent.notify(timeForNextTrigger - sc_time_stamp()); diff --git a/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.cpp b/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.cpp index 819db5c4..f11f597e 100644 --- a/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.cpp +++ b/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.cpp @@ -38,28 +38,40 @@ using namespace tlm; +CmdMuxOldest::CmdMuxOldest() : memSpec(Configuration::getInstance().memSpec) {} + CommandTuple::Type CmdMuxOldest::selectCommand(ReadyCommands &readyCommands) { auto result = readyCommands.cend(); - auto it = readyCommands.cbegin(); uint64_t lastPayloadID = UINT64_MAX; - uint64_t newPayloadID = 0; + uint64_t newPayloadID; + sc_time lastTimestamp = sc_max_time(); + sc_time newTimestamp; - while (it != readyCommands.cend()) + for (auto it = readyCommands.cbegin(); it != readyCommands.cend(); it++) { - if (std::get(*it) == sc_time_stamp()) + newTimestamp = std::get(*it) + + memSpec->getCommandLength(std::get(*it)) - memSpec->tCK; + newPayloadID = DramExtension::getChannelPayloadID(std::get(*it)); + + if (newTimestamp < lastTimestamp) + { + lastTimestamp = newTimestamp; + lastPayloadID = newPayloadID; + result = it; + } + else if (newTimestamp == lastTimestamp) { - newPayloadID = DramExtension::getChannelPayloadID(std::get(*it)); if (newPayloadID < lastPayloadID) { lastPayloadID = newPayloadID; result = it; } } - it++; } - if (lastPayloadID != UINT64_MAX) + if (result != readyCommands.cend() && + std::get(*result) == sc_time_stamp()) return *result; else return CommandTuple::Type(Command::NOP, nullptr, sc_max_time()); diff --git a/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.h b/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.h index 6b93a44e..ee2c794e 100644 --- a/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.h +++ b/DRAMSys/library/src/controller/cmdmux/CmdMuxOldest.h @@ -36,11 +36,16 @@ #define CMDMUXOLDEST_H #include "CmdMuxIF.h" +#include "../../configuration/Configuration.h" class CmdMuxOldest : public CmdMuxIF { public: + CmdMuxOldest(); CommandTuple::Type selectCommand(ReadyCommands &); + +private: + const MemSpec *memSpec; }; #endif // CMDMUXOLDEST_H diff --git a/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.cpp b/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.cpp index e88b6dd2..d10f36fa 100644 --- a/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.cpp +++ b/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.cpp @@ -38,18 +38,42 @@ using namespace tlm; +CmdMuxStrict::CmdMuxStrict() : memSpec(Configuration::getInstance().memSpec) {} + CommandTuple::Type CmdMuxStrict::selectCommand(ReadyCommands &readyCommands) { auto result = readyCommands.cend(); - auto it = readyCommands.cbegin(); uint64_t lastPayloadID = UINT64_MAX; - uint64_t newPayloadID = 0; + uint64_t newPayloadID; + sc_time lastTimestamp = sc_max_time(); + sc_time newTimestamp; - while (it != readyCommands.cend()) + for (auto it = readyCommands.cbegin(); it != readyCommands.cend(); it++) { - if (std::get(*it) == sc_time_stamp()) + newTimestamp = std::get(*it) + + memSpec->getCommandLength(std::get(*it)) - memSpec->tCK; + newPayloadID = DramExtension::getChannelPayloadID(std::get(*it)); + + if (newTimestamp < lastTimestamp) + { + if (isCasCommand(std::get(*it))) + { + if (newPayloadID == nextPayloadID) + { + lastTimestamp = newTimestamp; + lastPayloadID = newPayloadID; + result = it; + } + } + else + { + lastTimestamp = newTimestamp; + lastPayloadID = newPayloadID; + result = it; + } + } + else if (newTimestamp == lastTimestamp) { - newPayloadID = DramExtension::getChannelPayloadID(std::get(*it)); if (isCasCommand(std::get(*it))) { if ((newPayloadID < lastPayloadID) && (newPayloadID == nextPayloadID)) @@ -58,7 +82,7 @@ CommandTuple::Type CmdMuxStrict::selectCommand(ReadyCommands &readyCommands) result = it; } } - else // RAS command + else { if (newPayloadID < lastPayloadID) { @@ -67,10 +91,10 @@ CommandTuple::Type CmdMuxStrict::selectCommand(ReadyCommands &readyCommands) } } } - it++; } - if (lastPayloadID != UINT64_MAX) + if (result != readyCommands.cend() && + std::get(*result) == sc_time_stamp()) { if (isCasCommand(std::get(*result))) nextPayloadID++; diff --git a/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.h b/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.h index f105dcc1..b8eebd94 100644 --- a/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.h +++ b/DRAMSys/library/src/controller/cmdmux/CmdMuxStrict.h @@ -36,14 +36,17 @@ #define CMDMUXSTRICT_H #include "CmdMuxIF.h" +#include "../../configuration/Configuration.h" class CmdMuxStrict : public CmdMuxIF { public: + CmdMuxStrict(); CommandTuple::Type selectCommand(ReadyCommands &); private: uint64_t nextPayloadID = 0; + const MemSpec *memSpec; }; #endif // CMDMUXSTRICT_H