gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpu.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
44 #ifndef __CPU_MINOR_CPU_HH__
45 #define __CPU_MINOR_CPU_HH__
46 
47 #include "cpu/minor/activity.hh"
48 #include "cpu/minor/stats.hh"
49 #include "cpu/base.hh"
50 #include "cpu/simple_thread.hh"
51 #include "enums/ThreadPolicy.hh"
52 #include "params/MinorCPU.hh"
53 
54 namespace Minor
55 {
58 class Pipeline;
59 
62 };
63 
77 class MinorCPU : public BaseCPU
78 {
79  protected:
83 
84  public:
89 
94 
95  public:
98  class MinorCPUPort : public MasterPort
99  {
100  public:
103 
104  public:
105  MinorCPUPort(const std::string& name_, MinorCPU &cpu_)
106  : MasterPort(name_, &cpu_), cpu(cpu_)
107  { }
108 
109  };
110 
112  Enums::ThreadPolicy threadPolicy;
113  protected:
115  Port &getDataPort() override;
116 
118  Port &getInstPort() override;
119 
120  public:
121  MinorCPU(MinorCPUParams *params);
122 
123  ~MinorCPU();
124 
125  public:
127  void init() override;
128  void startup() override;
129  void wakeup(ThreadID tid) override;
130 
133 
135  void regStats() override;
136 
138  Counter totalInsts() const override;
139  Counter totalOps() const override;
140 
141  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
142  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
143 
145  void serialize(CheckpointOut &cp) const override;
146  void unserialize(CheckpointIn &cp) override;
147 
149  DrainState drain() override;
150  void drainResume() override;
153  void signalDrainDone();
154  void memWriteback() override;
155 
157  void switchOut() override;
158  void takeOverFrom(BaseCPU *old_cpu) override;
159 
161  void activateContext(ThreadID thread_id) override;
162  void suspendContext(ThreadID thread_id) override;
163 
166  {
167  std::vector<ThreadID> prio_list;
168  for (ThreadID i = 1; i <= numThreads; i++) {
169  prio_list.push_back((priority + i) % numThreads);
170  }
171  return prio_list;
172  }
173 
175  {
176  std::vector<ThreadID> prio_list;
177  for (ThreadID i = 0; i < numThreads; i++) {
178  prio_list.push_back(i);
179  }
180  std::random_shuffle(prio_list.begin(), prio_list.end());
181  return prio_list;
182  }
183 
188  void wakeupOnEvent(unsigned int stage_id);
189 };
190 
191 #endif /* __CPU_MINOR_CPU_HH__ */
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:71
Ports are used to interface objects to each other.
Definition: port.hh:56
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:102
The stats for MinorCPU separated from the CPU definition.
Bitfield< 7 > i
void takeOverFrom(ThreadContext &ntc, ThreadContext &otc)
Copy state between thread contexts in preparation for CPU handover.
ActivityRecoder from cpu/activity.h wrapped to provide evaluate and minorTrace.
ActivityRecorder with a Ticked interface.
Definition: activity.hh:54
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
Minor::Pipeline * pipeline
pipeline is a container for the clockable pipeline stage objects.
Definition: cpu.hh:82
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:105
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Definition: activity.cc:44
Definition: cprintf.cc:40
DrainState
Object drain/handover states.
Definition: drain.hh:71
STL vector class.
Definition: stl.hh:37
Provide a non-protected base class for Minor&#39;s Ports as derived classes are created by Fetch1 and Exe...
Definition: cpu.hh:98
SimpleThread MinorThread
Minor will use the SimpleThread state for now.
Definition: cpu.hh:58
std::vector< ThreadID > randomPriority()
Definition: cpu.hh:174
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
Minor::MinorActivityRecorder * activityRecorder
Activity recording for pipeline.
Definition: cpu.hh:88
int64_t Counter
Statistics counter type.
Definition: types.hh:56
std::vector< ThreadID > roundRobinPriority(ThreadID priority)
Thread scheduling utility functions.
Definition: cpu.hh:165
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
Enums::ThreadPolicy threadPolicy
Thread Scheduling Policy (RoundRobin, Random, etc)
Definition: cpu.hh:112
std::ostream CheckpointOut
Definition: serialize.hh:63
std::vector< Minor::MinorThread * > threads
These are thread state-representing objects for this CPU.
Definition: cpu.hh:93
void unserialize(ThreadContext &tc, CheckpointIn &cp)
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:77
Minor::MinorStats stats
Processor-specific statistics.
Definition: cpu.hh:132
The constructed pipeline.
Definition: pipeline.hh:69
Currently unused stats class.
Definition: stats.hh:55
const FlagsType init
This Stat is Initialized.
Definition: info.hh:45

Generated on Mon Jun 8 2020 15:34:38 for gem5 by doxygen 1.8.13