gem5  v19.0.0.0
cpu.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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  * Authors: Gabe Black
28  */
29 
31 
33 #include "scx/scx.h"
34 #include "sim/serialize.hh"
35 
36 namespace Iris
37 {
38 
39 BaseCPU::BaseCPU(BaseCPUParams *params, sc_core::sc_module *_evs) :
40  ::BaseCPU::BaseCPU(params), evs(_evs),
41  clockEvent(nullptr), periodAttribute(nullptr)
42 {
44 
45  const auto &event_vec = evs->get_child_events();
46  auto event_it = std::find_if(event_vec.begin(), event_vec.end(),
47  [](const sc_core::sc_event *e) -> bool {
48  return e->basename() == ClockEventName; });
49  if (event_it != event_vec.end())
50  clockEvent = *event_it;
51 
54  panic_if(base && !periodAttribute,
55  "The EVS clock period attribute is not of type "
56  "sc_attribute<Tick>.");
57 
61  base);
62  panic_if(base && !sendFunctional,
63  "The EVS send functional attribute is not of type "
64  "sc_attribute<PortProxy::SendFunctionalFunc>.");
65 
66  // Make sure fast model knows we're using debugging mechanisms to control
67  // the simulation, and it shouldn't shut down if simulation time stops
68  // for some reason. Despite the misleading name, this doesn't start a CADI
69  // server because it's first parameter is false.
70  scx::scx_start_cadi_server(false, false, true);
71 }
72 
74 {
75  for (auto &tc: threadContexts)
76  delete tc;
77  threadContexts.clear();
78 }
79 
80 Counter
82 {
83  Counter count = 0;
84  for (auto *tc: threadContexts)
85  count += tc->getCurrentInstCount();
86  return count;
87 }
88 
89 void
91 {
93  for (auto *tc: threadContexts)
94  tc->initMemProxies(tc);
95 }
96 
97 void
99 {
100  ::serialize(*threadContexts[tid], cp);
101 }
102 
103 } // namespace Iris
count
Definition: misc.hh:705
sc_attr_base * get_attribute(const std::string &)
Definition: sc_object.cc:94
static const std::string PeriodAttributeName
Definition: cpu.hh:48
virtual const std::vector< sc_event * > & get_child_events() const
Definition: sc_module.cc:253
Definition: cprintf.cc:42
sc_core::sc_attribute< PortProxy::SendFunctionalFunc > * sendFunctional
Definition: cpu.hh:103
std::vector< ThreadContext * > threadContexts
Definition: base.hh:267
sc_core::sc_module * evs
Definition: cpu.hh:98
sc_core::sc_attribute< Tick > * periodAttribute
Definition: cpu.hh:102
Bitfield< 51, 12 > base
Definition: pagetable.hh:142
int64_t Counter
Statistics counter type.
Definition: types.hh:58
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: cpu.cc:90
Bitfield< 9 > e
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
static const std::string ClockEventName
Definition: cpu.hh:45
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: cpu.cc:98
std::ostream CheckpointOut
Definition: serialize.hh:68
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:281
static const std::string SendFunctionalAttributeName
Definition: cpu.hh:54
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: base.cc:683
sc_core::sc_event * clockEvent
Definition: cpu.hh:101
BaseCPU(BaseCPUParams *params, sc_core::sc_module *_evs)
Definition: cpu.cc:39
Counter totalInsts() const override
Definition: cpu.cc:81
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:185
virtual ~BaseCPU()
Definition: cpu.cc:73
Definition: cpu.cc:36

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13