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 --- 16 unchanged lines hidden (view full) --- 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * 27 * Authors: Gabe Black 28 */ 29 30#include "systemc/core/kernel.hh" 31 32#include "base/logging.hh" |
33#include "systemc/core/channel.hh" |
34#include "systemc/core/module.hh" 35#include "systemc/core/scheduler.hh" 36 37namespace sc_gem5 38{ 39 40namespace 41{ --- 21 unchanged lines hidden (view full) --- 63 64void 65Kernel::init() 66{ 67 status(::sc_core::SC_BEFORE_END_OF_ELABORATION); 68 for (auto m: sc_gem5::allModules) { 69 callbackModule(m); 70 m->sc_mod()->before_end_of_elaboration(); |
71 for (auto p: m->ports) 72 p->before_end_of_elaboration(); 73 for (auto e: m->exports) 74 e->before_end_of_elaboration(); |
75 } 76 callbackModule(nullptr); |
77 for (auto c: sc_gem5::allChannels) 78 c->sc_chan()->before_end_of_elaboration(); |
79 80 if (stopAfterCallbacks) 81 stopWork(); 82} 83 84void 85Kernel::regStats() 86{ 87 for (auto m: sc_gem5::allModules) 88 for (auto p: m->ports) 89 p->_gem5Finalize(); 90 91 status(::sc_core::SC_END_OF_ELABORATION); |
92 for (auto m: sc_gem5::allModules) { |
93 m->sc_mod()->end_of_elaboration(); |
94 for (auto p: m->ports) 95 p->end_of_elaboration(); 96 for (auto e: m->exports) 97 e->end_of_elaboration(); 98 } 99 for (auto c: sc_gem5::allChannels) 100 c->sc_chan()->end_of_elaboration(); |
101 102 if (stopAfterCallbacks) 103 stopWork(); 104} 105 106void 107Kernel::startup() 108{ 109 status(::sc_core::SC_START_OF_SIMULATION); |
110 for (auto m: sc_gem5::allModules) { |
111 m->sc_mod()->start_of_simulation(); |
112 for (auto p: m->ports) 113 p->start_of_simulation(); 114 for (auto e: m->exports) 115 e->start_of_simulation(); 116 } 117 for (auto c: sc_gem5::allChannels) 118 c->sc_chan()->start_of_simulation(); |
119 120 startComplete = true; 121 122 if (stopAfterCallbacks) 123 stopWork(); 124 125 kernel->status(::sc_core::SC_RUNNING); 126 --- 10 unchanged lines hidden (view full) --- 137 else 138 stopWork(); 139} 140 141void 142Kernel::stopWork() 143{ 144 status(::sc_core::SC_END_OF_SIMULATION); |
145 for (auto m: sc_gem5::allModules) { |
146 m->sc_mod()->end_of_simulation(); |
147 for (auto p: m->ports) 148 p->end_of_simulation(); 149 for (auto e: m->exports) 150 e->end_of_simulation(); 151 } 152 for (auto c: sc_gem5::allChannels) 153 c->sc_chan()->end_of_simulation(); |
154 155 endComplete = true; 156 157 status(::sc_core::SC_STOPPED); 158 159 if (stopAfterCallbacks) 160 fatal("Simulation called sc_stop during elaboration.\n"); 161} --- 28 unchanged lines hidden --- |