scheduler.cc (13329:a2d273c8e667) scheduler.cc (13403:cebee63981d3)
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

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

28 */
29
30#include "systemc/core/scheduler.hh"
31
32#include "base/fiber.hh"
33#include "base/logging.hh"
34#include "sim/eventq.hh"
35#include "systemc/core/kernel.hh"
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

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

28 */
29
30#include "systemc/core/scheduler.hh"
31
32#include "base/fiber.hh"
33#include "base/logging.hh"
34#include "sim/eventq.hh"
35#include "systemc/core/kernel.hh"
36#include "systemc/core/sc_main_fiber.hh"
36#include "systemc/ext/core/messages.hh"
37#include "systemc/ext/core/sc_main.hh"
38#include "systemc/ext/utils/sc_report.hh"
39#include "systemc/ext/utils/sc_report_handler.hh"
40#include "systemc/utils/report.hh"
41#include "systemc/utils/tracefile.hh"
42
43namespace sc_gem5
44{
45
46Scheduler::Scheduler() :
47 eq(nullptr), readyEvent(this, false, ReadyPriority),
48 pauseEvent(this, false, PausePriority),
37#include "systemc/ext/core/messages.hh"
38#include "systemc/ext/core/sc_main.hh"
39#include "systemc/ext/utils/sc_report.hh"
40#include "systemc/ext/utils/sc_report_handler.hh"
41#include "systemc/utils/report.hh"
42#include "systemc/utils/tracefile.hh"
43
44namespace sc_gem5
45{
46
47Scheduler::Scheduler() :
48 eq(nullptr), readyEvent(this, false, ReadyPriority),
49 pauseEvent(this, false, PausePriority),
49 stopEvent(this, false, StopPriority),
50 scMain(nullptr), _throwToScMain(nullptr),
50 stopEvent(this, false, StopPriority), _throwToScMain(nullptr),
51 starvationEvent(this, false, StarvationPriority),
52 _elaborationDone(false), _started(false), _stopNow(false),
53 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
54 timeAdvancesEvent(this, false, TimeAdvancesPriority), _numCycles(0),
55 _changeStamp(0), _current(nullptr), initDone(false), runOnce(false)
56{}
57
58Scheduler::~Scheduler()

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

344}
345
346void
347Scheduler::pause()
348{
349 status(StatusPaused);
350 kernel->status(::sc_core::SC_PAUSED);
351 runOnce = false;
51 starvationEvent(this, false, StarvationPriority),
52 _elaborationDone(false), _started(false), _stopNow(false),
53 _status(StatusOther), maxTickEvent(this, false, MaxTickPriority),
54 timeAdvancesEvent(this, false, TimeAdvancesPriority), _numCycles(0),
55 _changeStamp(0), _current(nullptr), initDone(false), runOnce(false)
56{}
57
58Scheduler::~Scheduler()

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

344}
345
346void
347Scheduler::pause()
348{
349 status(StatusPaused);
350 kernel->status(::sc_core::SC_PAUSED);
351 runOnce = false;
352 if (scMain && !scMain->finished())
353 scMain->run();
352 if (scMainFiber.called() && !scMainFiber.finished())
353 scMainFiber.run();
354}
355
356void
357Scheduler::stop()
358{
359 status(StatusStopped);
360 kernel->stop();
361
362 clear();
363
364 runOnce = false;
354}
355
356void
357Scheduler::stop()
358{
359 status(StatusStopped);
360 kernel->stop();
361
362 clear();
363
364 runOnce = false;
365 if (scMain && !scMain->finished())
366 scMain->run();
365 if (scMainFiber.called() && !scMainFiber.finished())
366 scMainFiber.run();
367}
368
369void
370Scheduler::start(Tick max_tick, bool run_to_time)
371{
367}
368
369void
370Scheduler::start(Tick max_tick, bool run_to_time)
371{
372 // We should be running from sc_main. Keep track of that Fiber to return
373 // to later.
374 scMain = Fiber::currentFiber();
375
376 _started = true;
377 status(StatusOther);
378 runToTime = run_to_time;
379
380 maxTick = max_tick;
381 lastReadyTick = getCurTick();
382
383 if (initDone) {

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

426}
427
428void
429Scheduler::throwToScMain()
430{
431 ::sc_core::sc_report report = reportifyException();
432 _throwToScMain = &report;
433 status(StatusOther);
372 _started = true;
373 status(StatusOther);
374 runToTime = run_to_time;
375
376 maxTick = max_tick;
377 lastReadyTick = getCurTick();
378
379 if (initDone) {

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

422}
423
424void
425Scheduler::throwToScMain()
426{
427 ::sc_core::sc_report report = reportifyException();
428 _throwToScMain = &report;
429 status(StatusOther);
434 scMain->run();
430 scMainFiber.run();
435}
436
437void
438Scheduler::scheduleStop(bool finish_delta)
439{
440 if (stopEvent.scheduled())
441 return;
442

--- 65 unchanged lines hidden ---
431}
432
433void
434Scheduler::scheduleStop(bool finish_delta)
435{
436 if (stopEvent.scheduled())
437 return;
438

--- 65 unchanged lines hidden ---