gem5  v20.1.0.0
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 RequestPort
99  {
100  public:
103 
104  public:
105  MinorCPUPort(const std::string& name_, MinorCPU &cpu_)
106  : RequestPort(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__ */
MinorCPU::wakeup
void wakeup(ThreadID tid) override
Definition: cpu.cc:147
MinorCPU::totalInsts
Counter totalInsts() const override
Simple inst count interface from BaseCPU.
Definition: cpu.cc:313
MinorCPU::wakeupOnEvent
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:285
MinorCPU::MinorCPUPort::cpu
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:102
MinorCPU::getInstPort
Port & getInstPort() override
Return a reference to the instruction port.
Definition: cpu.cc:301
MinorCPU::init
void init() override
Starting, waking and initialisation.
Definition: cpu.cc:92
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
MinorCPU::suspendContext
void suspendContext(ThreadID thread_id) override
Notify the CPU that the indicated context is now suspended.
Definition: cpu.cc:275
MinorCPU::activityRecorder
Minor::MinorActivityRecorder * activityRecorder
Activity recording for pipeline.
Definition: cpu.hh:88
MinorCPU::threadPolicy
Enums::ThreadPolicy threadPolicy
Thread Scheduling Policy (RoundRobin, Random, etc)
Definition: cpu.hh:112
Minor::MinorThread
SimpleThread MinorThread
Minor will use the SimpleThread state for now.
Definition: cpu.hh:58
MinorCPU::stats
Minor::MinorStats stats
Processor-specific statistics.
Definition: cpu.hh:132
std::vector
STL vector class.
Definition: stl.hh:37
stats.hh
Minor
Definition: activity.cc:44
SimpleThread
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
Definition: simple_thread.hh:89
MinorCPU::MinorCPU
MinorCPU(MinorCPUParams *params)
Definition: cpu.cc:48
MinorCPU::threads
std::vector< Minor::MinorThread * > threads
These are thread state-representing objects for this CPU.
Definition: cpu.hh:93
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
Minor::MinorActivityRecorder
ActivityRecorder with a Ticked interface.
Definition: activity.hh:54
Counter
int64_t Counter
Statistics counter type.
Definition: types.hh:58
MinorCPU::startup
void startup() override
Definition: cpu.cc:158
MinorCPU::~MinorCPU
~MinorCPU()
Definition: cpu.cc:82
MinorCPU::takeOverFrom
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:248
cp
Definition: cprintf.cc:40
MinorCPU
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:77
MinorCPU::switchOut
void switchOut() override
Switching interface from BaseCPU.
Definition: cpu.cc:236
MinorCPU::MinorCPUPort::MinorCPUPort
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:105
MinorCPU::memWriteback
void memWriteback() override
Definition: cpu.cc:230
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
Minor::Pipeline
The constructed pipeline.
Definition: pipeline.hh:69
MinorCPU::drainResume
void drainResume() override
Definition: cpu.cc:200
MinorCPU::activateContext
void activateContext(ThreadID thread_id) override
Thread activation interface from BaseCPU.
Definition: cpu.cc:256
MinorCPU::MinorCPUPort
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
Definition: cpu.hh:98
MinorCPU::pipeline
Minor::Pipeline * pipeline
pipeline is a container for the clockable pipeline stage objects.
Definition: cpu.hh:82
MinorCPU::regStats
void regStats() override
Stats interface from SimObject (by way of BaseCPU)
Definition: cpu.cc:113
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
MinorCPU::signalDrainDone
void signalDrainDone()
Signal from Pipeline that MinorCPU should signal that a drain is complete and set its drainState.
Definition: cpu.cc:193
BaseCPU::params
const Params * params() const
Definition: base.hh:296
MinorCPU::totalOps
Counter totalOps() const override
Definition: cpu.cc:324
MinorCPU::unserializeThread
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
Definition: cpu.cc:127
BaseCPU
Definition: cpu_dummy.hh:43
simple_thread.hh
base.hh
MinorCPU::roundRobinPriority
std::vector< ThreadID > roundRobinPriority(ThreadID priority)
Thread scheduling utility functions.
Definition: cpu.hh:165
Minor::MinorStats
Currently unused stats class.
Definition: stats.hh:55
BaseCPU::numThreads
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
Definition: base.hh:363
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
MinorCPU::getDataPort
Port & getDataPort() override
Return a reference to the data port.
Definition: cpu.cc:307
MinorCPU::randomPriority
std::vector< ThreadID > randomPriority()
Definition: cpu.hh:174
MinorCPU::unserialize
void unserialize(CheckpointIn &cp) override
Definition: cpu.cc:140
CheckpointIn
Definition: serialize.hh:67
MinorCPU::serializeThread
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
Definition: cpu.cc:121
activity.hh
MinorCPU::serialize
void serialize(CheckpointOut &cp) const override
Serialize pipeline data.
Definition: cpu.cc:133
MinorCPU::drain
DrainState drain() override
Drain interface.
Definition: cpu.cc:169

Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17