Merge branch 'feat/cmdmux' into 'develop'
Use std::optional in cmdMux See merge request ems/astdm/modeling.dram/dram.sys.5!109
This commit is contained in:
@@ -387,7 +387,7 @@ void Controller::controllerMethod()
|
||||
it->evaluate();
|
||||
|
||||
// (4) Collect all ready commands from BMs, RMs and PDMs
|
||||
CommandTuple::Type commandTuple;
|
||||
|
||||
// clear command buffer
|
||||
readyCommands.clear();
|
||||
|
||||
@@ -395,7 +395,7 @@ void Controller::controllerMethod()
|
||||
{
|
||||
// (4.1) Check for power-down commands (PDEA/PDEP/SREFEN or PDXA/PDXP/SREFEX)
|
||||
Rank rank = Rank(rankID);
|
||||
commandTuple = powerDownManagers[rank]->getNextCommand();
|
||||
auto commandTuple = powerDownManagers[rank]->getNextCommand();
|
||||
if (std::get<CommandTuple::Command>(commandTuple) != Command::NOP)
|
||||
readyCommands.emplace_back(commandTuple);
|
||||
else
|
||||
@@ -426,11 +426,12 @@ void Controller::controllerMethod()
|
||||
std::get<CommandTuple::Timestamp>(it) =
|
||||
checker->timeToSatisfyConstraints(command, *trans);
|
||||
}
|
||||
commandTuple = cmdMux->selectCommand(readyCommands);
|
||||
Command command = std::get<CommandTuple::Command>(commandTuple);
|
||||
tlm_generic_payload* trans = std::get<CommandTuple::Payload>(commandTuple);
|
||||
if (command != Command::NOP) // can happen with FIFO strict
|
||||
auto commandTuple = cmdMux->selectCommand(readyCommands);
|
||||
if (commandTuple.has_value()) // can happen with FIFO strict
|
||||
{
|
||||
Command command = std::get<CommandTuple::Command>(*commandTuple);
|
||||
tlm_generic_payload* trans = std::get<CommandTuple::Payload>(*commandTuple);
|
||||
|
||||
Rank rank = ControllerExtension::getRank(*trans);
|
||||
Bank bank = ControllerExtension::getBank(*trans);
|
||||
|
||||
@@ -492,7 +493,7 @@ void Controller::controllerMethod()
|
||||
for (auto& it : bankMachines)
|
||||
{
|
||||
it->evaluate();
|
||||
commandTuple = it->getNextCommand();
|
||||
auto commandTuple = it->getNextCommand();
|
||||
Command command = std::get<CommandTuple::Command>(commandTuple);
|
||||
tlm_generic_payload* trans = std::get<CommandTuple::Payload>(commandTuple);
|
||||
if (command != Command::NOP)
|
||||
@@ -505,7 +506,7 @@ void Controller::controllerMethod()
|
||||
for (auto& it : refreshManagers)
|
||||
{
|
||||
it->evaluate();
|
||||
commandTuple = it->getNextCommand();
|
||||
auto commandTuple = it->getNextCommand();
|
||||
Command command = std::get<CommandTuple::Command>(commandTuple);
|
||||
tlm_generic_payload* trans = std::get<CommandTuple::Payload>(commandTuple);
|
||||
if (command != Command::NOP)
|
||||
@@ -522,7 +523,7 @@ void Controller::controllerMethod()
|
||||
for (auto& it : powerDownManagers)
|
||||
{
|
||||
it->evaluate();
|
||||
commandTuple = it->getNextCommand();
|
||||
auto commandTuple = it->getNextCommand();
|
||||
Command command = std::get<CommandTuple::Command>(commandTuple);
|
||||
tlm_generic_payload* trans = std::get<CommandTuple::Payload>(commandTuple);
|
||||
if (command != Command::NOP)
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include "DRAMSys/controller/Command.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace DRAMSys
|
||||
{
|
||||
|
||||
@@ -52,7 +54,7 @@ public:
|
||||
CmdMuxIF() = default;
|
||||
virtual ~CmdMuxIF() = default;
|
||||
|
||||
virtual CommandTuple::Type selectCommand(const ReadyCommands& readyCommands) = 0;
|
||||
virtual std::optional<CommandTuple::Type> selectCommand(const ReadyCommands& readyCommands) = 0;
|
||||
};
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -45,7 +45,7 @@ CmdMuxOldest::CmdMuxOldest(const MemSpec& memSpec) : memSpec(memSpec)
|
||||
{
|
||||
}
|
||||
|
||||
CommandTuple::Type CmdMuxOldest::selectCommand(const ReadyCommands& readyCommands)
|
||||
std::optional<CommandTuple::Type> CmdMuxOldest::selectCommand(const ReadyCommands& readyCommands)
|
||||
{
|
||||
auto result = readyCommands.cend();
|
||||
uint64_t lastPayloadID = UINT64_MAX;
|
||||
@@ -73,10 +73,12 @@ CommandTuple::Type CmdMuxOldest::selectCommand(const ReadyCommands& readyCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (result != readyCommands.cend() &&
|
||||
std::get<CommandTuple::Timestamp>(*result) == sc_time_stamp())
|
||||
return *result;
|
||||
return {Command::NOP, nullptr, scMaxTime};
|
||||
assert(result != readyCommands.cend());
|
||||
|
||||
if (std::get<CommandTuple::Timestamp>(*result) != sc_time_stamp())
|
||||
return std::nullopt;
|
||||
|
||||
return *result;
|
||||
}
|
||||
|
||||
CmdMuxOldestRasCas::CmdMuxOldestRasCas(const MemSpec& memSpec) : memSpec(memSpec)
|
||||
@@ -86,7 +88,7 @@ CmdMuxOldestRasCas::CmdMuxOldestRasCas(const MemSpec& memSpec) : memSpec(memSpec
|
||||
readyRasCasCommands.reserve(2);
|
||||
}
|
||||
|
||||
CommandTuple::Type CmdMuxOldestRasCas::selectCommand(const ReadyCommands& readyCommands)
|
||||
std::optional<CommandTuple::Type> CmdMuxOldestRasCas::selectCommand(const ReadyCommands& readyCommands)
|
||||
{
|
||||
readyRasCommands.clear();
|
||||
readyCasCommands.clear();
|
||||
@@ -180,10 +182,12 @@ CommandTuple::Type CmdMuxOldestRasCas::selectCommand(const ReadyCommands& readyC
|
||||
}
|
||||
}
|
||||
|
||||
if (result != readyCommands.cend() &&
|
||||
std::get<CommandTuple::Timestamp>(*result) == sc_time_stamp())
|
||||
return *result;
|
||||
return {Command::NOP, nullptr, scMaxTime};
|
||||
assert(result != readyCommands.cend());
|
||||
|
||||
if (std::get<CommandTuple::Timestamp>(*result) != sc_time_stamp())
|
||||
return std::nullopt;
|
||||
|
||||
return *result;
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -45,7 +45,7 @@ class CmdMuxOldest : public CmdMuxIF
|
||||
{
|
||||
public:
|
||||
explicit CmdMuxOldest(const MemSpec& memSpec);
|
||||
CommandTuple::Type selectCommand(const ReadyCommands& readyCommands) override;
|
||||
std::optional<CommandTuple::Type> selectCommand(const ReadyCommands& readyCommands) override;
|
||||
|
||||
private:
|
||||
const MemSpec& memSpec;
|
||||
@@ -56,7 +56,7 @@ class CmdMuxOldestRasCas : public CmdMuxIF
|
||||
{
|
||||
public:
|
||||
explicit CmdMuxOldestRasCas(const MemSpec& memSpec);
|
||||
CommandTuple::Type selectCommand(const ReadyCommands& readyCommands) override;
|
||||
std::optional<CommandTuple::Type> selectCommand(const ReadyCommands& readyCommands) override;
|
||||
|
||||
private:
|
||||
const MemSpec& memSpec;
|
||||
|
||||
@@ -45,7 +45,7 @@ CmdMuxStrict::CmdMuxStrict(const MemSpec& memSpec) : memSpec(memSpec)
|
||||
{
|
||||
}
|
||||
|
||||
CommandTuple::Type CmdMuxStrict::selectCommand(const ReadyCommands& readyCommands)
|
||||
std::optional<CommandTuple::Type> CmdMuxStrict::selectCommand(const ReadyCommands& readyCommands)
|
||||
{
|
||||
auto result = readyCommands.cend();
|
||||
uint64_t lastPayloadID = UINT64_MAX;
|
||||
@@ -88,7 +88,8 @@ CommandTuple::Type CmdMuxStrict::selectCommand(const ReadyCommands& readyCommand
|
||||
nextPayloadID++;
|
||||
return *result;
|
||||
}
|
||||
return {Command::NOP, nullptr, scMaxTime};
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CmdMuxStrictRasCas::CmdMuxStrictRasCas(const MemSpec& memSpec) : memSpec(memSpec)
|
||||
@@ -98,7 +99,7 @@ CmdMuxStrictRasCas::CmdMuxStrictRasCas(const MemSpec& memSpec) : memSpec(memSpec
|
||||
readyRasCasCommands.reserve(2);
|
||||
}
|
||||
|
||||
CommandTuple::Type CmdMuxStrictRasCas::selectCommand(const ReadyCommands& readyCommands)
|
||||
std::optional<CommandTuple::Type> CmdMuxStrictRasCas::selectCommand(const ReadyCommands& readyCommands)
|
||||
{
|
||||
readyRasCommands.clear();
|
||||
readyCasCommands.clear();
|
||||
@@ -188,7 +189,7 @@ CommandTuple::Type CmdMuxStrictRasCas::selectCommand(const ReadyCommands& readyC
|
||||
nextPayloadID++;
|
||||
return *result;
|
||||
}
|
||||
return {Command::NOP, nullptr, scMaxTime};
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -45,7 +45,7 @@ class CmdMuxStrict : public CmdMuxIF
|
||||
{
|
||||
public:
|
||||
explicit CmdMuxStrict(const MemSpec& memSpec);
|
||||
CommandTuple::Type selectCommand(const ReadyCommands& readyCommands) override;
|
||||
std::optional<CommandTuple::Type> selectCommand(const ReadyCommands& readyCommands) override;
|
||||
|
||||
private:
|
||||
uint64_t nextPayloadID = 1;
|
||||
@@ -57,7 +57,7 @@ class CmdMuxStrictRasCas : public CmdMuxIF
|
||||
{
|
||||
public:
|
||||
explicit CmdMuxStrictRasCas(const MemSpec& memSpec);
|
||||
CommandTuple::Type selectCommand(const ReadyCommands& readyCommands) override;
|
||||
std::optional<CommandTuple::Type> selectCommand(const ReadyCommands& readyCommands) override;
|
||||
|
||||
private:
|
||||
uint64_t nextPayloadID = 1;
|
||||
|
||||
Reference in New Issue
Block a user