gem5  v22.1.0.0
cpu.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2014, 2020 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 "base/compiler.hh"
48 #include "base/random.hh"
49 #include "cpu/base.hh"
50 #include "cpu/minor/activity.hh"
51 #include "cpu/minor/stats.hh"
52 #include "cpu/simple_thread.hh"
53 #include "enums/ThreadPolicy.hh"
54 #include "params/BaseMinorCPU.hh"
55 
56 namespace gem5
57 {
58 
60 namespace minor
61 {
62 
65 class Pipeline;
66 
69 
70 } // namespace minor
71 
85 class MinorCPU : public BaseCPU
86 {
87  protected:
91 
92  public:
97 
102 
103  public:
106  class MinorCPUPort : public RequestPort
107  {
108  public:
111 
112  public:
113  MinorCPUPort(const std::string& name_, MinorCPU &cpu_)
114  : RequestPort(name_, &cpu_), cpu(cpu_)
115  { }
116 
117  };
118 
120  enums::ThreadPolicy threadPolicy;
121  protected:
123  Port &getDataPort() override;
124 
126  Port &getInstPort() override;
127 
128  public:
129  MinorCPU(const BaseMinorCPUParams &params);
130 
131  ~MinorCPU();
132 
133  public:
135  void init() override;
136  void startup() override;
137  void wakeup(ThreadID tid) override;
138 
141 
143  void regStats() override;
144 
146  Counter totalInsts() const override;
147  Counter totalOps() const override;
148 
149  void serializeThread(CheckpointOut &cp, ThreadID tid) const override;
150  void unserializeThread(CheckpointIn &cp, ThreadID tid) override;
151 
153  void serialize(CheckpointOut &cp) const override;
154  void unserialize(CheckpointIn &cp) override;
155 
157  DrainState drain() override;
158  void drainResume() override;
161  void signalDrainDone();
162  void memWriteback() override;
163 
165  void switchOut() override;
166  void takeOverFrom(BaseCPU *old_cpu) override;
167 
169  void activateContext(ThreadID thread_id) override;
170  void suspendContext(ThreadID thread_id) override;
171 
174  {
175  std::vector<ThreadID> prio_list;
176  for (ThreadID i = 1; i <= numThreads; i++) {
177  prio_list.push_back((priority + i) % numThreads);
178  }
179  return prio_list;
180  }
181 
183  {
184  std::vector<ThreadID> prio_list;
185  for (ThreadID i = 0; i < numThreads; i++) {
186  prio_list.push_back(i);
187  }
188 
189  std::shuffle(prio_list.begin(), prio_list.end(),
190  random_mt.gen);
191 
192  return prio_list;
193  }
194 
200 
205  void wakeupOnEvent(unsigned int stage_id);
207 };
208 
209 } // namespace gem5
210 
211 #endif /* __CPU_MINOR_CPU_HH__ */
void updateCycleCounters(CPUState state)
base method keeping track of cycle progression
Definition: base.hh:544
@ CPU_STATE_ON
Definition: base.hh:534
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
Definition: base.hh:367
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
Definition: cpu.hh:107
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:110
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:113
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:86
Port & getInstPort() override
Return a reference to the instruction port.
Definition: cpu.cc:301
MinorCPU(const BaseMinorCPUParams &params)
Definition: cpu.cc:50
void serialize(CheckpointOut &cp) const override
Serialize pipeline data.
Definition: cpu.cc:129
void wakeup(ThreadID tid) override
Definition: cpu.cc:143
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: cpu.cc:117
DrainState drain() override
Drain interface.
Definition: cpu.cc:165
Counter totalInsts() const override
Simple inst count interface from BaseCPU.
Definition: cpu.cc:313
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: cpu.cc:136
~MinorCPU()
Definition: cpu.cc:85
minor::Pipeline * pipeline
pipeline is a container for the clockable pipeline stage objects.
Definition: cpu.hh:90
minor::MinorStats stats
Processor-specific statistics.
Definition: cpu.hh:140
minor::MinorActivityRecorder * activityRecorder
Activity recording for pipeline.
Definition: cpu.hh:96
void signalDrainDone()
Signal from Pipeline that MinorCPU should signal that a drain is complete and set its drainState.
Definition: cpu.cc:189
void init() override
Starting, waking and initialisation.
Definition: cpu.cc:98
void switchOut() override
Switching interface from BaseCPU.
Definition: cpu.cc:232
void wakeupOnEvent(unsigned int stage_id)
Interface for stages to signal that they have become active after a callback or eventq event where th...
Definition: cpu.cc:291
void memWriteback() override
Write back dirty buffers to memory using functional writes.
Definition: cpu.cc:226
void tick()
The tick method in the MinorCPU is simply updating the cycle counters as the ticking of the pipeline ...
Definition: cpu.hh:199
Counter totalOps() const override
Definition: cpu.cc:324
std::vector< ThreadID > roundRobinPriority(ThreadID priority)
Thread scheduling utility functions.
Definition: cpu.hh:173
void regStats() override
Stats interface from SimObject (by way of BaseCPU)
Definition: cpu.cc:110
void activateContext(ThreadID thread_id) override
Thread activation interface from BaseCPU.
Definition: cpu.cc:252
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition: cpu.cc:123
std::vector< ThreadID > randomPriority()
Definition: cpu.hh:182
void takeOverFrom(BaseCPU *old_cpu) override
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
Definition: cpu.cc:244
void startup() override
startup() is the final initialization call before simulation.
Definition: cpu.cc:154
enums::ThreadPolicy threadPolicy
Thread Scheduling Policy (RoundRobin, Random, etc)
Definition: cpu.hh:120
Port & getDataPort() override
Return a reference to the data port.
Definition: cpu.cc:307
std::vector< minor::MinorThread * > threads
These are thread state-representing objects for this CPU.
Definition: cpu.hh:101
void drainResume() override
Resume execution after a successful drain.
Definition: cpu.cc:196
void suspendContext(ThreadID thread_id) override
Notify the CPU that the indicated context is now suspended.
Definition: cpu.cc:281
EventFunctionWrapper * fetchEventWrapper
Definition: cpu.hh:206
Ports are used to interface objects to each other.
Definition: port.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
ActivityRecorder with a Ticked interface.
Definition: activity.hh:59
The constructed pipeline.
Definition: pipeline.hh:74
STL vector class.
Definition: stl.hh:37
The stats for MinorCPU separated from the CPU definition.
Random random_mt
Definition: random.cc:99
std::mt19937_64 gen
Definition: random.hh:69
DrainState
Object drain/handover states.
Definition: drain.hh:75
const Params & params() const
Definition: sim_object.hh:176
ActivityRecoder from cpu/activity.h wrapped to provide evaluate and minorTrace.
Bitfield< 7 > i
Definition: misc_types.hh:67
SimpleThread MinorThread
Minor will use the SimpleThread state for now.
Definition: cpu.hh:65
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
std::ostream CheckpointOut
Definition: serialize.hh:66
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Currently unused stats class.
Definition: stats.hh:60

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1