gem5 v24.0.0.0
Loading...
Searching...
No Matches
process.hh
Go to the documentation of this file.
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
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef __SYSTEMC_CORE_PROCESS_HH__
29#define __SYSTEMC_CORE_PROCESS_HH__
30
31#include <functional>
32#include <memory>
33#include <vector>
34
35#include "base/fiber.hh"
36#include "systemc/core/list.hh"
45
46namespace sc_core
47{
48
49class sc_join;
50
51} // namespace sc_core
52
53namespace sc_gem5
54{
55
56class ScHalt
57{};
58
59class Process;
60class Reset;
61
63{
64 public:
65 virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
66 bool needsStart() const { return _needsStart; }
67 void needsStart(bool ns) { _needsStart = ns; }
68 bool dynamic() const { return _dynamic; }
69 bool isUnwinding() const { return _isUnwinding; }
70 void isUnwinding(bool v) { _isUnwinding = v; }
71 bool terminated() const { return _terminated; }
72
73 bool scheduled() const { return _scheduled; }
74 void scheduled(bool new_val) { _scheduled = new_val; }
75
76 void forEachKid(const std::function<void(Process *)> &work);
77
78 bool suspended() const { return _suspended; }
79 bool disabled() const { return _disabled; }
80
81 void suspend(bool inc_kids);
82 void resume(bool inc_kids);
83 void disable(bool inc_kids);
84 void enable(bool inc_kids);
85
86 void kill(bool inc_kids);
87 void reset(bool inc_kids);
88 void throw_it(ExceptionWrapperBase &exc, bool inc_kids);
89
92
93 void syncResetOn(bool inc_kids);
94 void syncResetOff(bool inc_kids);
95
96 void signalReset(bool set, bool sync);
97
98 void incref() { refCount++; }
99 void decref() { refCount--; }
100
103
104 void setStackSize(size_t size) { stackSize = size; }
105
106 void run();
107
110 void clearDynamic() { setDynamic(nullptr); }
111 void addReset(Reset *);
112
115 void cancelTimeout();
116
118
119 void ready();
120
122
123 static Process *newest() { return _newest; }
124
125 void lastReport(::sc_core::sc_report *report);
127
128 bool hasStaticSensitivities() { return !staticSensitivities.empty(); }
129 bool internal() { return _internal; }
130 bool timedOut() { return _timedOut; }
132
134 void dontInitialize(bool di) { _dontInitialize = di; }
135
136 void joinWait(::sc_core::sc_join *join) { joinWaiters.push_back(join); }
137
138 void waitCount(int count) { _waitCount = count; }
139
140 const char *uniqueName(const char *seed) { return nameGen.gen(seed); }
141
142 protected:
143 void timeout();
144
145 Process(const char *name, ProcessFuncWrapper *func, bool internal=false);
146
148
149 virtual ~Process()
150 {
151 popListNode();
152 delete func;
153 for (auto s: staticSensitivities) {
154 s->clear();
155 delete s;
156 }
157 clearDynamic();
158 }
159
162
164
166
167 // Needed to support the deprecated "timed_out" function.
169
171
177
178 void terminate();
179
183
185
188
190
192
193 size_t stackSize;
194
198
199 std::unique_ptr<::sc_core::sc_report> _lastReport;
200
202
204};
205
206class Reset
207{
208 public:
209 Reset(Process *p, bool s, bool v) :
210 _process(p), _signal(nullptr), _sync(s), _value(v)
211 {}
212
213 bool
215 {
216 _signal = s;
217
218 if (_signal->_addReset(this)) {
219 _process->addReset(this);
220 if (_signal->read() == _value)
221 update();
222 return true;
223 }
224 return false;
225 }
227
228 Process *process() { return _process; }
230 bool sync() { return _sync; }
231 bool value() { return _value; }
232
233 private:
236 bool _sync;
237 bool _value;
238};
239
240void newReset(const sc_core::sc_port_base *pb, Process *p, bool s, bool v);
242 bool s, bool v);
243
244} // namespace sc_gem5
245
246#endif //__SYSTEMC_CORE_PROCESS_HH__
This class represents a fiber, which is a light weight sort of thread which is cooperatively schedule...
Definition fiber.hh:72
const char * name() const
Definition sc_object.cc:44
virtual const bool & read() const =0
virtual bool _addReset(sc_gem5::Reset *reset) const
virtual::sc_core::sc_curr_proc_kind procKind() const =0
static Process * _newest
Definition process.hh:147
ScEvent timeoutEvent
Definition process.hh:113
void kill(bool inc_kids)
Definition process.cc:141
static Process * newest()
Definition process.hh:123
void scheduled(bool new_val)
Definition process.hh:74
void suspend(bool inc_kids)
Definition process.cc:77
void cancelTimeout()
Definition process.cc:304
void joinWait(::sc_core::sc_join *join)
Definition process.hh:136
void forEachKid(const std::function< void(Process *)> &work)
Definition process.cc:67
DynamicSensitivity * dynamicSensitivity
Definition process.hh:196
void isUnwinding(bool v)
Definition process.hh:70
void resume(bool inc_kids)
Definition process.cc:98
void addReset(Reset *)
Definition process.cc:298
void disable(bool inc_kids)
Definition process.cc:112
std::unique_ptr<::sc_core::sc_report > _lastReport
Definition process.hh:199
bool dynamic() const
Definition process.hh:68
void syncResetOn(bool inc_kids)
Definition process.cc:223
std::vector<::sc_core::sc_join * > joinWaiters
Definition process.hh:201
void clearDynamic()
Definition process.hh:110
virtual ~Process()
Definition process.hh:149
void satisfySensitivity(Sensitivity *)
Definition process.cc:332
bool isUnwinding() const
Definition process.hh:69
::sc_core::sc_report * lastReport() const
Definition process.cc:376
std::vector< Reset * > resets
Definition process.hh:197
::sc_core::sc_event & resetEvent()
Definition process.hh:101
void signalReset(bool set, bool sync)
Definition process.cc:241
virtual gem5::Fiber * fiber()
Definition process.hh:121
void waitCount(int count)
Definition process.hh:138
StaticSensitivities staticSensitivities
Definition process.hh:195
InternalScEvent _resetEvent
Definition process.hh:160
bool suspended() const
Definition process.hh:78
bool disabled() const
Definition process.hh:79
void setTimeout(::sc_core::sc_time t)
Definition process.cc:311
bool scheduled() const
Definition process.hh:73
void needsStart(bool ns)
Definition process.hh:67
InternalScEvent _terminatedEvent
Definition process.hh:161
ProcessFuncWrapper * func
Definition process.hh:163
bool terminated() const
Definition process.hh:71
::sc_core::sc_event & terminatedEvent()
Definition process.hh:102
const char * uniqueName(const char *seed)
Definition process.hh:140
void setDynamic(DynamicSensitivity *)
Definition process.cc:288
void addStatic(StaticSensitivity *)
Definition process.cc:282
Process(const char *name, ProcessFuncWrapper *func, bool internal=false)
Definition process.cc:378
void reset(bool inc_kids)
Definition process.cc:169
void throw_it(ExceptionWrapperBase &exc, bool inc_kids)
Definition process.cc:198
void setStackSize(size_t size)
Definition process.hh:104
ExceptionWrapperBase * excWrapper
Definition process.hh:91
void dontInitialize(bool di)
Definition process.hh:134
bool dontInitialize()
Definition process.hh:133
bool needsStart() const
Definition process.hh:66
void syncResetOff(bool inc_kids)
Definition process.cc:232
void injectException(ExceptionWrapperBase &exc)
Definition process.cc:216
UniqueNameGen nameGen
Definition process.hh:203
void enable(bool inc_kids)
Definition process.cc:130
bool hasStaticSensitivities()
Definition process.hh:128
const sc_core::sc_signal_in_if< bool > * signal()
Definition process.hh:229
Process * process()
Definition process.hh:228
bool install(const sc_core::sc_signal_in_if< bool > *s)
Definition process.hh:214
const sc_core::sc_signal_in_if< bool > * _signal
Definition process.hh:235
Process * _process
Definition process.hh:234
void update()
Definition process.hh:226
Reset(Process *p, bool s, bool v)
Definition process.hh:209
const char * gen(std::string seed)
Definition module.hh:60
static Fiber * primaryFiber()
Get a pointer to the primary Fiber.
Definition fiber.cc:186
void newReset(const sc_core::sc_port_base *pb, Process *p, bool s, bool v)
Definition process.cc:425
void popListNode()
Definition list.hh:51

Generated on Tue Jun 18 2024 16:24:06 for gem5 by doxygen 1.11.0