55 const std::string & name,
57 const SpartaHandler & consumer_event_handler) :
60 fancy_name_(name +
"[" + consumer_event_handler.
getName() +
"]"),
61 single_cycle_event_scheduleable_(consumer_event_handler, 1 , sched_phase)
64 single_cycle_event_scheduleable_.
setLabel(fancy_name_.c_str());
91 single_cycle_event_scheduleable_.
cancel();
102 return single_cycle_event_scheduleable_.
isScheduled();
122 "Cannot schedule sparta::SingleCycleUniqueEvent:'"
123 <<
getName() <<
"' in any relative time other than 0 or 1. rel_cycle given: "
126 const auto to_be_scheduled_relative_tick =
127 local_clk_->
getTick(Clock::Cycle(rel_cycle));
129 const auto to_be_scheduled_abs_tick =
130 local_scheduler_->
calcIndexTime(to_be_scheduled_relative_tick);
132 if(
SPARTA_EXPECT_TRUE(next_scheduled_tick_ < to_be_scheduled_abs_tick || is_init_tick_))
139 "Bummer! You found a bug in PhasedSingleCycleUniqueEvent. Please file a GitHub Issue");
141 single_cycle_event_scheduleable_.
142 scheduleRelativeTick(to_be_scheduled_relative_tick, local_scheduler_);
143 prev_scheduled_tick_ = next_scheduled_tick_;
144 next_scheduled_tick_ = to_be_scheduled_abs_tick;
145 is_init_tick_ =
false;
147 else if((to_be_scheduled_abs_tick < next_scheduled_tick_) &&
148 (prev_scheduled_tick_ != to_be_scheduled_abs_tick))
155 "Bummer! You found a bug in PhasedSingleCycleUniqueEvent. Please file a GitHub Issue");
156 sparta_assert(prev_scheduled_tick_ < to_be_scheduled_abs_tick,
157 "Bummer! You found a bug in PhasedSingleCycleUniqueEvent. Please file a GitHub Issue")
159 single_cycle_event_scheduleable_.
160 scheduleRelativeTick(to_be_scheduled_relative_tick, local_scheduler_);
161 prev_scheduled_tick_ = to_be_scheduled_abs_tick;
173 template<
class ScheduleableT>
174 void precedes(ScheduleableT & consumer,
const std::string & reason =
"") {
175 single_cycle_event_scheduleable_.
precedes(consumer, reason);
178#ifndef DO_NOT_DOCUMENT
182 return single_cycle_event_scheduleable_;
188 void createResource_()
override {
194 const Clock * local_clk_ =
nullptr;
197 Scheduler * local_scheduler_ =
nullptr;
205 std::string fancy_name_;
208 Scheduleable single_cycle_event_scheduleable_;
211 bool is_init_tick_ =
true;
File that defines the Clock class.
File that defines the EventNode class.
File that defines the Scheduleable class.
A simple time-based, event precedence based scheduler.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
#define SPARTA_EXPECT_TRUE(x)
A macro for hinting to the compiler a particular condition should be considered most likely true.
File that contains the macro used to generate the class callbacks.
Basic Node framework in sparta device tree composite pattern.
Scheduler * getScheduler() const
Scheduler::Tick getTick(const Cycle &cycle) const
Return the tick corresponding to the given cycle.
EventNode is the base class for all event types in SPARTA. Not to be used by the modeler....
sparta::SchedulingPhase getSchedulingPhase() const
Get the scheduling phase of this event node.
virtual Scheduleable & getScheduleable()=0
Get the scheduleable associated with this event node.
An event that can only be schedule one cycle into the future.
bool isScheduled() const
Return true if this scheduleable was scheduled at all.
PhasedSingleCycleUniqueEvent(const PhasedSingleCycleUniqueEvent &)=delete
Disallow the copying of the PhasedSingleCycleUniqueEvent.
bool isContinuing() const
Is this Event continuing?
PhasedSingleCycleUniqueEvent(TreeNode *event_set, const std::string &name, SchedulingPhase sched_phase, const SpartaHandler &consumer_event_handler)
Create a PhasedSingleCycleUniqueEvent.
void precedes(ScheduleableT &consumer, const std::string &reason="")
Have this SingleCycleUniqueEvent precede another.
PhasedSingleCycleUniqueEvent & operator=(const PhasedSingleCycleUniqueEvent &)=delete
Disallow the assignment of the PhasedSingleCycleUniqueEvent.
void setContinuing(bool continuing)
void schedule(Clock::Cycle rel_cycle=0)
Schedule this PhasedSingleCycleUniqueEvent exactly zero or one cycle into the future....
virtual ~PhasedSingleCycleUniqueEvent()=default
Uniquely destroy.
void cancel()
Cancel the event for now and one cycle into the future.
A class that defines the basic scheduling interface to the Scheduler. Not intended to be used by mode...
void setContinuing(bool continuing)
This event, if continuing == true, will keep the simulation running.
void cancel()
Cancel all the times that this Scheduleable was placed on the Scheduler.
void precedes(Scheduleable &consumer, const std::string &reason="")
Have this Scheduleable precede another.
bool isScheduled() const
Return true if this scheduleable was scheduled at all.
void setLabel(const char *label)
Set a new label for this Scheduleable – used in debugging.
void setScheduleableClock(const Clock *clk)
Set the clock and scheduler of this Scheduleable.
bool isContinuing() const
Is this Event continuing?
uint64_t Tick
Typedef for our unit of time.
constexpr Tick calcIndexTime(const Tick rel_time) const
Const expression to calculate tick value for indexing.
Node in a composite tree representing a sparta Tree item.
const Clock * getClock() override
Walks up parents (starting with self) until a parent with an associated local clock is found,...
const std::string & getName() const override
Gets the name of this node.
Macros for handling exponential backoff.
SchedulingPhase
The SchedulingPhases used for events (Tick, Update, PortUpdate, etc)