/* * Utils.cpp * * Created on: Mar 12, 2014 * Author: jonny */ #include "Utils.h" #include "../configuration/TimingConfiguration.h" #include "../ControllerCore.h" #include "../../common/DebugManager.h" #include "../configuration/Configuration.h" namespace core { unsigned int getStartAddress(const Bank& bank) { return 0; } sc_time getDelayToMeetConstraint(sc_time previous, sc_time start, sc_time constraint) { if (previous + constraint > start) return previous + constraint - start; else return SC_ZERO_TIME; } const sc_time clkAlign(sc_time time, sc_time clk, Alignment alignment) { if (alignment == UP) return ceil(time / clk) * clk; else return floor(time / clk) * clk; } TimeInterval getIntervalOnDataStrobe(const ScheduledCommand& command) { sc_assert(command.getCommand() == Command::Read || command.getCommand() == Command::ReadA || command.getCommand() == Command::Write ||command.getCommand() == Command::WriteA); TimingConfiguration& timings = Configuration::getInstance().Timings; if(command.getCommand() == Command::Read || command.getCommand() == Command::ReadA) { return TimeInterval(command.getStart() + timings.tRL, command.getStart() + timings.tRL + timings.clk * command.getBurstLength()); } else { return TimeInterval(command.getStart() + timings.tWL, command.getStart() + timings.tWL + timings.clk * command.getBurstLength()); } } bool isClkAligned(sc_time time, sc_time clk) { return !((time / clk) - ceil(time / clk)); } bool TimeInterval::timeIsInInterval(sc_time time) { return (start < time && time < end); } bool TimeInterval::intersects(TimeInterval other) { return other.timeIsInInterval(this->start) || this->timeIsInInterval(other.start); } }