stopEvent(this, false, StopPriority),
scMain(nullptr), _throwToScMain(nullptr),
starvationEvent(this, false, StarvationPriority),
- _started(false), _paused(false), _stopped(false), _stopNow(false),
+ _started(false), _stopNow(false), _status(StatusOther),
maxTickEvent(this, false, MaxTickPriority),
_numCycles(0), _changeStamp(0), _current(nullptr), initDone(false),
runOnce(false), readyList(nullptr)
p->ready();
}
- update();
-
- while (!deltas.empty())
- deltas.front()->run();
+ runUpdate();
+ runDelta();
for (auto ets: eventsToSchedule)
eq->schedule(ets.first, ets.second);
}
initDone = true;
+
+ status(StatusOther);
}
void
if (_stopNow)
return;
- // The update phase.
- update();
-
- // The delta phase.
- while (!deltas.empty())
- deltas.front()->run();
+ runUpdate();
+ runDelta();
if (!runToTime && starved())
scheduleStarvationEvent();
if (runOnce)
schedulePause();
+
+ status(StatusOther);
}
void
-Scheduler::update()
+Scheduler::runUpdate()
{
+ status(StatusUpdate);
+
Channel *channel = updateList.getNext();
while (channel) {
channel->popListNode();
}
}
+void
+Scheduler::runDelta()
+{
+ status(StatusDelta);
+ while (!deltas.empty())
+ deltas.front()->run();
+}
+
void
Scheduler::pause()
{
- _paused = true;
+ status(StatusPaused);
kernel->status(::sc_core::SC_PAUSED);
runOnce = false;
if (scMain && !scMain->finished())
void
Scheduler::stop()
{
- _stopped = true;
+ status(StatusStopped);
kernel->stop();
clear();
scMain = Fiber::currentFiber();
_started = true;
- _paused = false;
- _stopped = false;
+ status(StatusOther);
runToTime = run_to_time;
maxTick = max_tick;
}
// Run scheduled channel updates.
- void update();
+ void runUpdate();
+
+ // Run delta events.
+ void runDelta();
void setScMainFiber(Fiber *sc_main) { scMain = sc_main; }
void schedulePause();
void scheduleStop(bool finish_delta);
- bool paused() { return _paused; }
- bool stopped() { return _stopped; }
+ enum Status
+ {
+ StatusOther = 0,
+ StatusDelta,
+ StatusUpdate,
+ StatusTiming,
+ StatusPaused,
+ StatusStopped
+ };
+
+ bool paused() { return status() == StatusPaused; }
+ bool stopped() { return status() == StatusStopped; }
+ bool inDelta() { return status() == StatusDelta; }
+ bool inUpdate() { return status() == StatusUpdate; }
+ bool inTiming() { return status() == StatusTiming; }
uint64_t changeStamp() { return _changeStamp; }
void throwToScMain(const ::sc_core::sc_report *r=nullptr);
+ Status status() { return _status; }
+ void status(Status s) { _status = s; }
+
private:
typedef const EventBase::Priority Priority;
static Priority DefaultPriority = EventBase::Default_Pri;
void scheduleStarvationEvent();
bool _started;
- bool _paused;
- bool _stopped;
bool _stopNow;
+ Status _status;
+
Tick maxTick;
Tick lastReadyTick;
void
inline void
Scheduler::TimeSlot::process()
{
+ scheduler.status(StatusTiming);
+
while (!events.empty())
events.front()->run();
+
+ scheduler.status(StatusOther);
scheduler.completeTimeSlot(this);
}