101 lines
2.6 KiB
C++
101 lines
2.6 KiB
C++
/*
|
|
* ReadChecker.cpp
|
|
*
|
|
* Created on: Mar 13, 2014
|
|
* Author: jonny
|
|
*/
|
|
|
|
#include "ReadChecker.h"
|
|
#include "../../utils/Utils.h"
|
|
#include "../../../common/Utils.h"
|
|
|
|
namespace core {
|
|
|
|
void ReadChecker::delayToSatisfyConstraints(ScheduledCommand& command) const
|
|
{
|
|
assert(command.getCommand() == Command::Read || command.getCommand() == Command::ReadA);
|
|
|
|
ScheduledCommand lastCommand = state.getLastScheduledCommand(command.getBank());
|
|
|
|
if (lastCommand.isValidCommand())
|
|
{
|
|
if (lastCommand.getCommand() == Command::Activate)
|
|
{
|
|
command.delayToMeetConstraint(lastCommand.getEnd(), SC_ZERO_TIME);
|
|
}
|
|
else if (lastCommand.getCommand() == Command::Read || lastCommand.getCommand() == Command::Write)
|
|
{
|
|
}
|
|
else if (lastCommand.getCommand() == Command::PDNAX)
|
|
{
|
|
command.delayToMeetConstraint(lastCommand.getEnd(), config.Timings.tXP);
|
|
}
|
|
else
|
|
reportFatal("Read Checker",
|
|
"Read can not follow " + commandToString(lastCommand.getCommand()));
|
|
}
|
|
|
|
while (!state.bus.isFree(command.getStart()) || collidesOnDataStrobe(command))
|
|
{
|
|
command.delayStart(config.Timings.clk);
|
|
}
|
|
}
|
|
|
|
sc_time ReadChecker::getExecutionTime(const tlm::tlm_generic_payload& payload,
|
|
Command command) const
|
|
{
|
|
assert(command == Command::Read || command == Command::ReadA);
|
|
|
|
if (command == Command::Read)
|
|
{
|
|
return config.Timings.tRL + config.Timings.clk * payload.get_streaming_width();
|
|
}
|
|
else
|
|
{
|
|
return config.Timings.clk * payload.get_streaming_width() + max(config.Timings.tRP,config.Timings.tRL);
|
|
}
|
|
}
|
|
|
|
bool ReadChecker::collidesOnDataStrobe(ScheduledCommand& read) const
|
|
{
|
|
for (ScheduledCommand& strobeCommand : state.lastDataStrobeCommands)
|
|
{
|
|
if (collidesWithStrobeCommand(read, strobeCommand))
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ReadChecker::collidesWithStrobeCommand(ScheduledCommand& read,
|
|
ScheduledCommand& strobeCommand) const
|
|
{
|
|
if (strobeCommand.getCommand() == Command::Read || strobeCommand.getCommand() == Command::ReadA)
|
|
{
|
|
return getIntervalOnDataStrobe(read).intersects(getIntervalOnDataStrobe(strobeCommand));
|
|
}
|
|
else if (strobeCommand.getCommand() == Command::Write
|
|
|| strobeCommand.getCommand() == Command::WriteA)
|
|
{
|
|
//read to write
|
|
if (strobeCommand.getStart() >= read.getStart())
|
|
{
|
|
return !(strobeCommand.getStart() >= getIntervalOnDataStrobe(read).end);
|
|
}
|
|
//write to read
|
|
else
|
|
{
|
|
return !(read.getStart()>= getIntervalOnDataStrobe(strobeCommand).end + config.Timings.tWTR);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
reportFatal("Read Checker",
|
|
"Invalid strobeCommand in data strobe commands "
|
|
+ commandToString(strobeCommand.getCommand()));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
} /* namespace controller */
|