for (auto c: sc_gem5::allChannels)
c->sc_chan()->end_of_elaboration();
} catch (...) {
- ::sc_gem5::scheduler.throwToScMain();
+ ::sc_gem5::scheduler.throwUp();
}
}
for (auto c: sc_gem5::allChannels)
c->sc_chan()->start_of_simulation();
} catch (...) {
- ::sc_gem5::scheduler.throwToScMain();
+ ::sc_gem5::scheduler.throwUp();
}
startComplete = true;
for (auto c: sc_gem5::allChannels)
c->sc_chan()->end_of_simulation();
} catch (...) {
- ::sc_gem5::scheduler.throwToScMain();
+ ::sc_gem5::scheduler.throwUp();
}
endComplete = true;
Scheduler::Scheduler() :
eq(nullptr), readyEvent(this, false, ReadyPriority),
pauseEvent(this, false, PausePriority),
- stopEvent(this, false, StopPriority), _throwToScMain(nullptr),
+ stopEvent(this, false, StopPriority), _throwUp(nullptr),
starvationEvent(this, false, StarvationPriority),
_elaborationDone(false), _started(false), _stopNow(false),
_status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
try {
_current->run();
} catch (...) {
- throwToScMain();
+ throwUp();
}
}
}
channel = updateList.getNext();
}
} catch (...) {
- throwToScMain();
+ throwUp();
}
}
while (!deltas.empty())
deltas.back()->run();
} catch (...) {
- throwToScMain();
+ throwUp();
}
}
if (starvationEvent.scheduled())
deschedule(&starvationEvent);
- if (_throwToScMain) {
- const ::sc_core::sc_report *to_throw = _throwToScMain;
- _throwToScMain = nullptr;
+ if (_throwUp) {
+ const ::sc_core::sc_report *to_throw = _throwUp;
+ _throwUp = nullptr;
throw *to_throw;
}
}
}
void
-Scheduler::throwToScMain()
+Scheduler::throwUp()
{
- ::sc_core::sc_report report = reportifyException();
- _throwToScMain = &report;
- status(StatusOther);
- scMainFiber.run();
+ if (scMainFiber.called() && !scMainFiber.finished()) {
+ ::sc_core::sc_report report = reportifyException();
+ _throwUp = &report;
+ status(StatusOther);
+ scMainFiber.run();
+ } else {
+ reportHandlerProc(reportifyException(),
+ ::sc_core::sc_report_handler::get_catch_actions());
+ }
}
void
uint64_t changeStamp() { return _changeStamp; }
void stepChangeStamp() { _changeStamp++; }
- void throwToScMain();
+ // Throw upwards, either to sc_main or to the report handler if sc_main
+ // isn't running.
+ void throwUp();
Status status() { return _status; }
void status(Status s) { _status = s; }
EventWrapper<Scheduler, &Scheduler::pause> pauseEvent;
EventWrapper<Scheduler, &Scheduler::stop> stopEvent;
- const ::sc_core::sc_report *_throwToScMain;
+ const ::sc_core::sc_report *_throwUp;
bool
starved()
scheduler.completeTimeSlot(this);
else
scheduler.schedule(this);
- scheduler.throwToScMain();
+ scheduler.throwUp();
}
scheduler.status(StatusOther);