gem5  v21.1.0.2
sc_main.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/types.hh"
29 #include "sim/eventq.hh"
30 #include "systemc/core/kernel.hh"
36 
37 namespace sc_core
38 {
39 
40 namespace
41 {
42 
44 
45 } // anonymous namespace
46 
47 int
49 {
51 }
52 
53 const char *const *
55 {
57 }
58 
59 void
61 {
64 }
65 
66 void
68 {
71 }
72 
73 void
75 {
76  if (time.value() == 0) {
78  } else {
80  if (gem5::MaxTick - now < time.value())
83  }
84 }
85 
86 void
88 {
89  if (sc_is_running()) {
91  return;
92  }
93  _stop_mode = mode;
94 }
95 
98 {
99  return _stop_mode;
100 }
101 
102 void
104 {
105  static bool stop_called = false;
106  if (stop_called) {
107  static bool stop_warned = false;
108  if (!stop_warned)
110  stop_warned = true;
111  return;
112  }
113  stop_called = true;
114 
116  return;
117 
118  if ((sc_get_status() & SC_RUNNING)) {
119  bool finish_delta = (_stop_mode == SC_STOP_FINISH_DELTA);
120  ::sc_gem5::scheduler.scheduleStop(finish_delta);
121  } else {
123  }
124 }
125 
126 const sc_time &
128 {
129  static sc_time tstamp(1.0, SC_SEC);
130  tstamp = sc_time::from_value(::sc_gem5::scheduler.getCurTick());
131  return tstamp;
132 }
133 
136 {
137  return sc_gem5::scheduler.numCycles();
138 }
139 
140 bool
142 {
143  return sc_get_status() & (SC_RUNNING | SC_PAUSED);
144 }
145 
146 bool
148 {
150 }
151 
152 bool
154 {
156 }
157 
158 bool
160 {
163 }
164 
165 sc_time
167 {
168  return sc_time::from_value(::sc_gem5::scheduler.timeToPending());
169 }
170 
171 sc_status
173 {
175 }
176 
177 std::ostream &
178 operator << (std::ostream &os, sc_status s)
179 {
180  switch (s) {
181  case SC_ELABORATION:
182  os << "SC_ELABORATION";
183  break;
185  os << "SC_BEFORE_END_OF_ELABORATION";
186  break;
188  os << "SC_END_OF_ELABORATION";
189  break;
191  os << "SC_START_OF_SIMULATION";
192  break;
193  case SC_RUNNING:
194  os << "SC_RUNNING";
195  break;
196  case SC_PAUSED:
197  os << "SC_PAUSED";
198  break;
199  case SC_STOPPED:
200  os << "SC_STOPPED";
201  break;
203  os << "SC_END_OF_SIMULATION";
204  break;
205 
206  // Nonstandard
208  os << "SC_END_OF_INITIALIZATION";
209  break;
210  case SC_END_OF_UPDATE:
211  os << "SC_END_OF_UPDATE";
212  break;
213  case SC_BEFORE_TIMESTEP:
214  os << "SC_BEFORE_TIMESTEP";
215  break;
216 
217  default:
218  if (s & SC_STATUS_ANY) {
219  const char *prefix = "(";
220  for (sc_status m = (sc_status)0x1;
221  m < SC_STATUS_ANY; m = (sc_status)(m << 1)) {
222  if (m & s) {
223  os << prefix;
224  prefix = "|";
225  os << m;
226  }
227  }
228  os << ")";
229  } else {
230  gem5::ccprintf(os, "%#x", s);
231  }
232  }
233 
234  return os;
235 }
236 
237 } // namespace sc_core
sc_core::sc_start
void sc_start()
Definition: sc_main.cc:60
kernel.hh
sc_core::sc_time::from_value
static sc_time from_value(sc_dt::uint64)
Definition: sc_time.cc:210
sc_core::sc_get_status
sc_status sc_get_status()
Definition: sc_main.cc:172
sc_core::sc_pending_activity_at_current_time
bool sc_pending_activity_at_current_time()
Definition: sc_main.cc:147
sc_main_fiber.hh
sc_gem5::Kernel::stop
static void stop()
Definition: kernel.cc:141
sc_gem5::ScMainFiber::argc
int argc()
Definition: sc_main_fiber.hh:50
sc_core
Definition: messages.cc:31
sc_core::SC_ID_SIMULATION_TIME_OVERFLOW_
const char SC_ID_SIMULATION_TIME_OVERFLOW_[]
Definition: messages.cc:107
sc_gem5::Scheduler::pendingCurr
bool pendingCurr()
Definition: scheduler.hh:331
sc_core::sc_argv
const char *const * sc_argv()
Definition: sc_main.cc:54
sc_core::SC_RUN_TO_TIME
@ SC_RUN_TO_TIME
Definition: sc_main.hh:48
gem5::MaxTick
const Tick MaxTick
Definition: types.hh:60
sc_gem5::kernel
Kernel * kernel
Definition: kernel.cc:182
sc_core::SC_BEFORE_END_OF_ELABORATION
@ SC_BEFORE_END_OF_ELABORATION
Definition: sc_main.hh:84
sc_gem5::Scheduler::getCurTick
gem5::Tick getCurTick()
Definition: scheduler.hh:243
sc_core::SC_ID_STOP_MODE_AFTER_START_
const char SC_ID_STOP_MODE_AFTER_START_[]
Definition: messages.cc:113
sc_core::sc_pending_activity_at_future_time
bool sc_pending_activity_at_future_time()
Definition: sc_main.cc:153
gem5::ccprintf
void ccprintf(cp::Print &print)
Definition: cprintf.hh:130
sc_core::SC_ELABORATION
@ SC_ELABORATION
Definition: sc_main.hh:83
sc_core::SC_END_OF_ELABORATION
@ SC_END_OF_ELABORATION
Definition: sc_main.hh:85
sc_core::SC_STOPPED
@ SC_STOPPED
Definition: sc_main.hh:89
sc_core::sc_stop
void sc_stop()
Definition: sc_main.cc:103
sc_gem5::Scheduler::numCycles
uint64_t numCycles()
Definition: scheduler.hh:184
SC_REPORT_ERROR
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report_handler.hh:127
sc_dt::uint64
uint64_t uint64
Definition: sc_nbdefs.hh:206
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
sc_main.hh
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:561
sc_core::SC_BEFORE_TIMESTEP
@ SC_BEFORE_TIMESTEP
Definition: sc_main.hh:95
sc_core::sc_time
Definition: sc_time.hh:49
sc_core::sc_time::value
sc_dt::uint64 value() const
Definition: sc_time.cc:115
sc_core::operator<<
std::ostream & operator<<(std::ostream &os, sc_status s)
Definition: sc_main.cc:178
sc_gem5::ScMainFiber::argv
const char *const * argv()
Definition: sc_main_fiber.hh:51
messages.hh
sc_core::SC_SEC
@ SC_SEC
Definition: sc_time.hh:46
sc_core::SC_START_OF_SIMULATION
@ SC_START_OF_SIMULATION
Definition: sc_main.hh:86
sc_core::sc_time_to_pending_activity
sc_time sc_time_to_pending_activity()
Definition: sc_main.cc:166
sc_core::sc_argc
int sc_argc()
Definition: sc_main.cc:48
sc_core::sc_set_stop_mode
void sc_set_stop_mode(sc_stop_mode mode)
Definition: sc_main.cc:87
sc_core::SC_END_OF_SIMULATION
@ SC_END_OF_SIMULATION
Definition: sc_main.hh:90
sc_core::SC_STOP_FINISH_DELTA
@ SC_STOP_FINISH_DELTA
Definition: sc_main.hh:64
sc_core::SC_EXIT_ON_STARVATION
@ SC_EXIT_ON_STARVATION
Definition: sc_main.hh:49
sc_gem5::scMainFiber
ScMainFiber scMainFiber
Definition: sc_main_fiber.cc:81
SC_REPORT_WARNING
#define SC_REPORT_WARNING(msg_type, msg)
Definition: sc_report_handler.hh:123
sc_core::SC_ID_SIMULATION_STOP_CALLED_TWICE_
const char SC_ID_SIMULATION_STOP_CALLED_TWICE_[]
Definition: messages.cc:109
sc_report_handler.hh
gem5::ArmISA::m
Bitfield< 0 > m
Definition: misc_types.hh:394
sc_core::sc_delta_count
sc_dt::uint64 sc_delta_count()
Definition: sc_main.cc:135
types.hh
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:809
sc_core::sc_pause
void sc_pause()
Definition: sc_main.cc:67
sc_core::sc_status
sc_status
Definition: sc_main.hh:81
sc_core::SC_END_OF_UPDATE
@ SC_END_OF_UPDATE
Definition: sc_main.hh:94
sc_gem5::Scheduler::scheduleStop
void scheduleStop(bool finish_delta)
Definition: scheduler.cc:473
sc_gem5::Scheduler::schedulePause
void schedulePause()
Definition: scheduler.cc:450
sc_core::sc_stop_mode
sc_stop_mode
Definition: sc_main.hh:62
sc_core::SC_STATUS_ANY
@ SC_STATUS_ANY
Definition: sc_main.hh:96
sc_gem5::Scheduler::oneCycle
void oneCycle()
Definition: scheduler.cc:442
sc_gem5::Scheduler::pendingFuture
bool pendingFuture()
Definition: scheduler.hh:339
sc_gem5::scheduler
Scheduler scheduler
Definition: scheduler.cc:494
sc_gem5::Kernel::status
static sc_core::sc_status status()
Definition: kernel.cc:54
sc_core::sc_starvation_policy
sc_starvation_policy
Definition: sc_main.hh:46
sc_core::SC_RUNNING
@ SC_RUNNING
Definition: sc_main.hh:87
sc_gem5::Scheduler::start
void start(gem5::Tick max_tick, bool run_to_time)
Definition: scheduler.cc:404
sc_core::SC_PAUSED
@ SC_PAUSED
Definition: sc_main.hh:88
sc_core::sc_time_stamp
const sc_time & sc_time_stamp()
Definition: sc_main.cc:127
scheduler.hh
sc_core::SC_END_OF_INITIALIZATION
@ SC_END_OF_INITIALIZATION
Definition: sc_main.hh:93
sc_core::sc_get_stop_mode
sc_stop_mode sc_get_stop_mode()
Definition: sc_main.cc:97
gem5::ArmISA::mode
Bitfield< 4, 0 > mode
Definition: misc_types.hh:73
sc_core::sc_is_running
bool sc_is_running()
Definition: sc_main.cc:141
sc_core::sc_pending_activity
bool sc_pending_activity()
Definition: sc_main.cc:159
eventq.hh

Generated on Tue Sep 21 2021 12:25:50 for gem5 by doxygen 1.8.17