Improve command mux for multicycle commands, RAS/CAS bus missing.

This commit is contained in:
Lukas Steiner
2021-01-22 15:54:37 +01:00
parent d198a78e5a
commit a6ce8f63cb
5 changed files with 71 additions and 18 deletions

View File

@@ -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());

View File

@@ -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<CommandTuple::Timestamp>(*it) == sc_time_stamp())
newTimestamp = std::get<CommandTuple::Timestamp>(*it) +
memSpec->getCommandLength(std::get<CommandTuple::Command>(*it)) - memSpec->tCK;
newPayloadID = DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*it));
if (newTimestamp < lastTimestamp)
{
lastTimestamp = newTimestamp;
lastPayloadID = newPayloadID;
result = it;
}
else if (newTimestamp == lastTimestamp)
{
newPayloadID = DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*it));
if (newPayloadID < lastPayloadID)
{
lastPayloadID = newPayloadID;
result = it;
}
}
it++;
}
if (lastPayloadID != UINT64_MAX)
if (result != readyCommands.cend() &&
std::get<CommandTuple::Timestamp>(*result) == sc_time_stamp())
return *result;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());

View File

@@ -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

View File

@@ -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<CommandTuple::Timestamp>(*it) == sc_time_stamp())
newTimestamp = std::get<CommandTuple::Timestamp>(*it) +
memSpec->getCommandLength(std::get<CommandTuple::Command>(*it)) - memSpec->tCK;
newPayloadID = DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*it));
if (newTimestamp < lastTimestamp)
{
if (isCasCommand(std::get<CommandTuple::Command>(*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<CommandTuple::Payload>(*it));
if (isCasCommand(std::get<CommandTuple::Command>(*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<CommandTuple::Timestamp>(*result) == sc_time_stamp())
{
if (isCasCommand(std::get<CommandTuple::Command>(*result)))
nextPayloadID++;

View File

@@ -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