gem5 v24.0.0.0
Loading...
Searching...
No Matches
sc_spawn.cc
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#include "base/logging.hh"
40
41namespace sc_gem5
42{
43
44Process *
46 const ::sc_core::sc_spawn_options *opts)
47{
48 bool method = false;
49 bool dontInitialize = false;
50 if (opts) {
51 if (opts->_spawnMethod)
52 method = true;
53 if (opts->_dontInitialize)
54 dontInitialize = true;
55 if (opts->_stackSize != -1)
56 warn_once("Ignoring request to set stack size.\n");
57 }
58
59 if (!name || name[0] == '\0') {
60 if (method)
62 else
64 }
65
66 Process *proc;
67 if (method)
68 proc = new Method(name, func);
69 else
70 proc = new Thread(name, func);
71
72 proc->dontInitialize(dontInitialize);
73
74 if (opts) {
75 for (auto e: opts->_events)
77
78 for (auto p: opts->_ports)
80
81 for (auto e: opts->_exports)
83
84 for (auto i: opts->_interfaces)
86
87 for (auto f: opts->_finders)
89
90 for (auto p: opts->_in_resets)
91 newReset(p.target, proc, p.sync, p.value);
92
93 for (auto p: opts->_inout_resets)
94 newReset(p.target, proc, p.sync, p.value);
95
96 for (auto p: opts->_out_resets)
97 newReset(p.target, proc, p.sync, p.value);
98
99 for (auto i: opts->_if_resets)
100 newReset(i.target, proc, i.sync, i.value);
101 }
102
103 if (opts && opts->_dontInitialize &&
104 opts->_events.empty() && opts->_ports.empty() &&
105 opts->_exports.empty() && opts->_interfaces.empty() &&
106 opts->_finders.empty()) {
108 proc->name());
109 }
110
111 scheduler.reg(proc);
112
113 return proc;
114}
115
116} // namespace sc_gem5
117
118namespace sc_core
119{
120
122 _spawnMethod(false), _dontInitialize(false), _stackSize(-1)
123{}
124
125
126void
131
132void
137
138void
143
144
145void
147{
148 _events.push_back(e);
149}
150
151void
156
157void
162
163void
168
169void
174
175
176void
178{
179 _in_resets.emplace_back(&port, value, true);
180}
181
182void
184{
185 _inout_resets.emplace_back(&port, value, true);
186}
187
188void
190{
191 _out_resets.emplace_back(&port, value, true);
192}
193
194void
196 const sc_signal_in_if<bool> &iface, bool value)
197{
198 _if_resets.emplace_back(&iface, value, true);
199}
200
201
202void
204{
205 _in_resets.emplace_back(&port, value, false);
206}
207
208void
210{
211 _inout_resets.emplace_back(&port, value, false);
212}
213
214void
216{
217 _out_resets.emplace_back(&port, value, false);
218}
219
220void
222 const sc_signal_in_if<bool> &iface, bool value)
223{
224 _if_resets.emplace_back(&iface, value, false);
225}
226
227} // namespace sc_core
const char * name() const
Definition sc_object.cc:44
std::vector< const sc_event * > _events
Definition sc_spawn.hh:126
std::vector< sc_port_base * > _ports
Definition sc_spawn.hh:127
std::vector< Reset< const sc_signal_in_if< bool > > > _if_resets
Definition sc_spawn.hh:145
void set_sensitivity(const sc_event *)
Definition sc_spawn.cc:146
std::vector< sc_interface * > _interfaces
Definition sc_spawn.hh:129
std::vector< sc_export_base * > _exports
Definition sc_spawn.hh:128
std::vector< Reset< const sc_out< bool > > > _out_resets
Definition sc_spawn.hh:144
std::vector< Reset< const sc_inout< bool > > > _inout_resets
Definition sc_spawn.hh:143
void async_reset_signal_is(const sc_in< bool > &, bool)
Definition sc_spawn.cc:203
std::vector< sc_event_finder * > _finders
Definition sc_spawn.hh:130
void reset_signal_is(const sc_in< bool > &, bool)
Definition sc_spawn.cc:177
std::vector< Reset< const sc_in< bool > > > _in_resets
Definition sc_spawn.hh:142
bool dontInitialize()
Definition process.hh:133
void reg(Process *p)
Definition scheduler.cc:146
int f(int a, int b)
#define warn_once(...)
Definition logging.hh:260
const char SC_ID_DISABLE_WILL_ORPHAN_PROCESS_[]
Definition messages.cc:132
const char * sc_gen_unique_name(const char *seed)
Definition sc_module.cc:820
void newStaticSensitivityInterface(Process *p, const sc_core::sc_interface *i)
void newStaticSensitivityFinder(Process *p, const sc_core::sc_event_finder *f)
void newStaticSensitivityEvent(Process *p, const sc_core::sc_event *e)
void newReset(const sc_core::sc_port_base *pb, Process *p, bool s, bool v)
Definition process.cc:425
void newStaticSensitivityPort(Process *p, const sc_core::sc_port_base *pb)
Process * spawnWork(ProcessFuncWrapper *func, const char *name, const ::sc_core::sc_spawn_options *opts)
Definition sc_spawn.cc:45
Scheduler scheduler
Definition scheduler.cc:494
void newStaticSensitivityExport(Process *p, const sc_core::sc_export_base *exp)
#define SC_REPORT_WARNING(msg_type, msg)
const std::string & name()
Definition trace.cc:48
std::stringstream ss
Definition trace.test.cc:45

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