/* * Slots.cpp * * Created on: Mar 29, 2014 * Author: robert */ #include "Slots.h" #include "TimingCalculation.h" Slots::Slots(sc_time clk) : clk(clk) { } Slots::~Slots() { } void Slots::moveCommandToNextFreeSlot(ScheduledCommand& command) { while(!isFree(command.getStart())) command.delayStart(clk); } void Slots::cleanUpSlots(sc_time time) { slotSet.erase(slotSet.begin(), slotSet.lower_bound(time)); } void Slots::blockSlot(sc_time time) { sc_assert(isClkAligned(time, clk)); slotSet.insert(time); } bool Slots::isFree(sc_time time) { return (slotSet.count(time) == 0); } void Slots::blockSlots(sc_time begin, sc_time end, bool excludeBorders) { sc_assert(isClkAligned(begin, clk)); sc_assert(isClkAligned(end, clk)); if (excludeBorders) { begin += clk; end -= clk; } for (sc_time time = begin; time <= end; time += clk) { slotSet.insert(time); } }