First version of RasCas command mux, not working.

This commit is contained in:
Lukas Steiner
2021-03-24 09:10:12 +01:00
parent 81bbe066c8
commit 0c51a4e1f8
9 changed files with 277 additions and 2 deletions

View File

@@ -95,3 +95,8 @@ sc_time MemSpec::getRefreshIntervalSB() const
SC_REPORT_FATAL("MemSpec", "Same bank refresh not supported");
return SC_ZERO_TIME;
}
bool MemSpec::hasRasAndCasBus() const
{
return false;
}

View File

@@ -77,6 +77,8 @@ public:
virtual sc_time getRefreshIntervalPB() const;
virtual sc_time getRefreshIntervalSB() const;
virtual bool hasRasAndCasBus() const;
virtual sc_time getExecutionTime(Command, const tlm::tlm_generic_payload &) const = 0;
virtual TimeInterval getIntervalOnDataStrobe(Command) const = 0;

View File

@@ -94,6 +94,11 @@ sc_time MemSpecHBM2::getRefreshIntervalPB() const
return tREFISB;
}
bool MemSpecHBM2::hasRasAndCasBus() const
{
return true;
}
sc_time MemSpecHBM2::getExecutionTime(Command command, const tlm_generic_payload &payload) const
{
if (command == Command::PRE || command == Command::PREA)

View File

@@ -83,6 +83,8 @@ public:
virtual sc_time getRefreshIntervalAB() const override;
virtual sc_time getRefreshIntervalPB() const override;
virtual bool hasRasAndCasBus() const override;
virtual sc_time getExecutionTime(Command, const tlm::tlm_generic_payload &) const override;
virtual TimeInterval getIntervalOnDataStrobe(Command) const override;

View File

@@ -112,9 +112,19 @@ Controller::Controller(sc_module_name name) :
scheduler = new SchedulerFrFcfsGrp();
if (config.cmdMux == Configuration::CmdMux::Oldest)
cmdMux = new CmdMuxOldest();
{
if (memSpec->hasRasAndCasBus())
cmdMux = new CmdMuxOldestRasCas();
else
cmdMux = new CmdMuxOldest();
}
else if (config.cmdMux == Configuration::CmdMux::Strict)
cmdMux = new CmdMuxStrict();
{
if (memSpec->hasRasAndCasBus())
cmdMux = new CmdMuxStrictRasCas();
else
cmdMux = new CmdMuxStrict();
}
if (config.respQueue == Configuration::RespQueue::Fifo)
respQueue = new RespQueueFifo();

View File

@@ -76,3 +76,114 @@ CommandTuple::Type CmdMuxOldest::selectCommand(ReadyCommands &readyCommands)
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
CmdMuxOldestRasCas::CmdMuxOldestRasCas() : memSpec(Configuration::getInstance().memSpec)
{
readyRasCommands.reserve(memSpec->numberOfBanks);
readyCasCommands.reserve(memSpec->numberOfBanks);
}
CommandTuple::Type CmdMuxOldestRasCas::selectCommand(ReadyCommands &readyCommands)
{
readyRasCommands.clear();
readyCasCommands.clear();
for (auto it : readyCommands)
{
if (isRasCommand(std::get<CommandTuple::Command>(it)))
readyRasCommands.emplace_back(it);
else
readyCasCommands.emplace_back(it);
}
auto resultRas = readyRasCommands.cend();
auto resultCas = readyCasCommands.cend();
uint64_t lastPayloadID = UINT64_MAX;
uint64_t newPayloadID;
sc_time lastTimestamp = sc_max_time();
sc_time newTimestamp;
for (auto it = readyRasCommands.cbegin(); it != readyRasCommands.cend(); it++)
{
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;
resultRas = it;
}
else if (newTimestamp == lastTimestamp)
{
if (newPayloadID < lastPayloadID)
{
lastPayloadID = newPayloadID;
resultRas = it;
}
}
}
lastPayloadID = UINT64_MAX;
lastTimestamp = sc_max_time();
for (auto it = readyCasCommands.cbegin(); it != readyCasCommands.cend(); it++)
{
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;
resultCas = it;
}
else if (newTimestamp == lastTimestamp)
{
if (newPayloadID < lastPayloadID)
{
lastPayloadID = newPayloadID;
resultCas = it;
}
}
}
if (resultRas != readyRasCommands.cend() && resultCas != readyCasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp()
&& std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
{
if (DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*resultRas))
<= DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*resultCas)))
return *resultRas;
else
return *resultCas;
}
else if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp())
return *resultRas;
else if (std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
return *resultCas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else if (resultRas != readyRasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp())
return *resultRas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else if (resultCas != readyCasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
return *resultCas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}

View File

@@ -48,4 +48,17 @@ private:
const MemSpec *memSpec;
};
class CmdMuxOldestRasCas : public CmdMuxIF
{
public:
CmdMuxOldestRasCas();
CommandTuple::Type selectCommand(ReadyCommands &);
private:
const MemSpec *memSpec;
ReadyCommands readyRasCommands;
ReadyCommands readyCasCommands;
};
#endif // CMDMUXOLDEST_H

View File

@@ -103,3 +103,117 @@ CommandTuple::Type CmdMuxStrict::selectCommand(ReadyCommands &readyCommands)
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
CmdMuxStrictRasCas::CmdMuxStrictRasCas() : memSpec(Configuration::getInstance().memSpec)
{
readyRasCommands.reserve(memSpec->numberOfBanks);
readyCasCommands.reserve(memSpec->numberOfBanks);
}
CommandTuple::Type CmdMuxStrictRasCas::selectCommand(ReadyCommands &readyCommands)
{
readyRasCommands.clear();
readyCasCommands.clear();
for (auto it : readyCommands)
{
if (isRasCommand(std::get<CommandTuple::Command>(it)))
readyRasCommands.emplace_back(it);
else
readyCasCommands.emplace_back(it);
}
auto resultRas = readyRasCommands.cend();
auto resultCas = readyCasCommands.cend();
uint64_t lastPayloadID = UINT64_MAX;
uint64_t newPayloadID;
sc_time lastTimestamp = sc_max_time();
sc_time newTimestamp;
for (auto it = readyRasCommands.cbegin(); it != readyRasCommands.cend(); it++)
{
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;
resultRas = it;
}
else if (newTimestamp == lastTimestamp)
{
if (newPayloadID < lastPayloadID)
{
lastPayloadID = newPayloadID;
resultRas = it;
}
}
}
lastPayloadID = UINT64_MAX;
lastTimestamp = sc_max_time();
for (auto it = readyCasCommands.cbegin(); it != readyCasCommands.cend(); it++)
{
newTimestamp = std::get<CommandTuple::Timestamp>(*it) +
memSpec->getCommandLength(std::get<CommandTuple::Command>(*it)) - memSpec->tCK;
newPayloadID = DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*it));
if (newPayloadID == nextPayloadID)
{
if (newTimestamp < lastTimestamp)
{
lastTimestamp = newTimestamp;
lastPayloadID = newPayloadID;
resultCas = it;
}
else if (newTimestamp == lastTimestamp)
{
if (newPayloadID < lastPayloadID)
{
lastPayloadID = newPayloadID;
resultCas = it;
}
}
}
}
if (resultRas != readyRasCommands.cend() && resultCas != readyCasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp()
&& std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
{
if (DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*resultRas))
<= DramExtension::getChannelPayloadID(std::get<CommandTuple::Payload>(*resultCas)))
return *resultRas;
else
return *resultCas;
}
else if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp())
return *resultRas;
else if (std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
return *resultCas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else if (resultRas != readyRasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultRas) == sc_time_stamp())
return *resultRas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else if (resultCas != readyCasCommands.cend())
{
if (std::get<CommandTuple::Timestamp>(*resultCas) == sc_time_stamp())
return *resultCas;
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}
else
return CommandTuple::Type(Command::NOP, nullptr, sc_max_time());
}

View File

@@ -49,4 +49,17 @@ private:
const MemSpec *memSpec;
};
class CmdMuxStrictRasCas : public CmdMuxIF
{
public:
CmdMuxStrictRasCas();
CommandTuple::Type selectCommand(ReadyCommands &);
private:
uint64_t nextPayloadID = 1;
const MemSpec *memSpec;
ReadyCommands readyRasCommands;
ReadyCommands readyCasCommands;
};
#endif // CMDMUXSTRICT_H