Deleted Added
sdiff udiff text old ( 12993:977fa1dfe9b3 ) new ( 12995:3421144dd03e )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 94 unchanged lines hidden (view full) ---

103 for (auto e: list->events)
104 Event::getFromScEvent(e)->delSensitivity(this);
105}
106
107
108class UnwindExceptionReset : public ::sc_core::sc_unwind_exception
109{
110 public:
111 UnwindExceptionReset() { _isReset = true; }
112};
113
114class UnwindExceptionKill : public ::sc_core::sc_unwind_exception
115{
116 public:
117 UnwindExceptionKill() {}
118};
119
120template <typename T>
121struct BuiltinExceptionWrapper : public ExceptionWrapperBase
122{
123 public:
124 T t;
125 void throw_it() override { throw t; }

--- 61 unchanged lines hidden (view full) ---

187 forEachKid([](Process *p) { p->enable(true); });
188
189 _disabled = false;
190}
191
192void
193Process::kill(bool inc_kids)
194{
195 // Propogate the kill to our children no matter what happens to us.
196 if (inc_kids)
197 forEachKid([](Process *p) { p->kill(true); });
198
199 // If we're in the middle of unwinding, ignore the kill request.
200 if (_isUnwinding)
201 return;
202
203 // Update our state.
204 _terminated = true;
205 _isUnwinding = true;
206 _suspendedReady = false;
207 _suspended = false;
208 _syncReset = false;
209
210 // Inject the kill exception into this process.
211 injectException(killException);
212
213 _terminatedEvent.notify();
214}
215
216void
217Process::reset(bool inc_kids)
218{
219 // Propogate the reset to our children no matter what happens to us.
220 if (inc_kids)
221 forEachKid([](Process *p) { p->reset(true); });
222
223 // If we're in the middle of unwinding, ignore the reset request.
224 if (_isUnwinding)
225 return;
226
227 // Update our state.
228 _isUnwinding = true;
229
230 // Inject the reset exception into this process.
231 injectException(resetException);
232
233 _resetEvent.notify();
234}
235
236void
237Process::throw_it(ExceptionWrapperBase &exc, bool inc_kids)
238{
239 if (inc_kids)
240 forEachKid([&exc](Process *p) { p->throw_it(exc, true); });
241}
242
243void
244Process::injectException(ExceptionWrapperBase &exc)
245{
246 excWrapper = &exc;
247 scheduler.runNow(this);
248};
249
250void
251Process::syncResetOn(bool inc_kids)
252{
253 if (inc_kids)
254 forEachKid([](Process *p) { p->syncResetOn(true); });
255

--- 29 unchanged lines hidden (view full) ---

285void
286Process::run()
287{
288 bool reset;
289 do {
290 reset = false;
291 try {
292 func->call();
293 } catch(const ::sc_core::sc_unwind_exception &exc) {
294 reset = exc.is_reset();
295 _isUnwinding = false;
296 }
297 } while (reset);
298 _terminated = true;
299}
300
301void
302Process::addStatic(PendingSensitivity *s)
303{

--- 50 unchanged lines hidden ---