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

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

35#include "systemc/core/scheduler.hh"
36
37namespace sc_gem5
38{
39
40namespace
41{
42
43bool scMainDone = false;
44bool stopAfterCallbacks = false;
45bool startComplete = false;
46bool endComplete = false;
47
48sc_core::sc_status _status = sc_core::SC_ELABORATION;
49
50} // anonymous namespace
51
52bool Kernel::startOfSimulationComplete() { return startComplete; }
53bool Kernel::endOfSimulationComplete() { return endComplete; }
54
55bool Kernel::scMainFinished() { return scMainDone; }
56void Kernel::scMainFinished(bool finished) { scMainDone = finished; }
57
58sc_core::sc_status Kernel::status() { return _status; }
59void Kernel::status(sc_core::sc_status s) { _status = s; }
60
61Kernel::Kernel(Params *params) :
62 SimObject(params), t0Event(this, false, EventBase::Default_Pri - 1)
63{
64 // Install ourselves as the scheduler's event manager.
65 ::sc_gem5::scheduler.setEventQueue(eventQueue());
66}
67
68void
69Kernel::init()
70{
71 if (scMainDone)
72 return;
73
74 status(::sc_core::SC_BEFORE_END_OF_ELABORATION);
75 for (auto m: sc_gem5::allModules) {
76 callbackModule(m);
77 m->sc_mod()->before_end_of_elaboration();
78 for (auto p: m->ports)
79 p->before_end_of_elaboration();
80 for (auto e: m->exports)
81 e->before_end_of_elaboration();

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

86
87 if (stopAfterCallbacks)
88 stopWork();
89}
90
91void
92Kernel::regStats()
93{
94 if (scMainDone)
95 return;
96
97 for (auto m: sc_gem5::allModules)
98 for (auto p: m->ports)
99 p->_gem5Finalize();
100
101 status(::sc_core::SC_END_OF_ELABORATION);
102 for (auto m: sc_gem5::allModules) {
103 m->sc_mod()->end_of_elaboration();
104 for (auto p: m->ports)

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

111
112 if (stopAfterCallbacks)
113 stopWork();
114}
115
116void
117Kernel::startup()
118{
119 if (scMainDone)
120 return;
121
122 status(::sc_core::SC_START_OF_SIMULATION);
123 for (auto m: sc_gem5::allModules) {
124 m->sc_mod()->start_of_simulation();
125 for (auto p: m->ports)
126 p->start_of_simulation();
127 for (auto e: m->exports)
128 e->start_of_simulation();
129 }

--- 66 unchanged lines hidden ---