gem5  v22.1.0.0
pipe_data.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-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 
50 #ifndef __CPU_MINOR_PIPE_DATA_HH__
51 #define __CPU_MINOR_PIPE_DATA_HH__
52 
53 #include "cpu/minor/buffers.hh"
54 #include "cpu/minor/dyn_inst.hh"
55 #include "cpu/base.hh"
56 
57 namespace gem5
58 {
59 
61 namespace minor
62 {
63 
66 class BranchData /* : public ReportIF, public BubbleIF */
67 {
68  public:
69  enum Reason
70  {
71  /* *** No change of stream (information to branch prediction) */
72 
73  /* Don't branch at all (bubble) */
75  /* Don't branch, but here's the details of a correct prediction
76  * that was executed */
78 
79  /* *** Change of stream */
80 
81  /* Take an unpredicted branch */
83  /* Take a branch on branch prediction data (from Fetch2) */
85  /* Prediction of wrong target PC */
87  /* Bad branch prediction (didn't actually branch). Need to branch
88  * back to correct stream. If the target is wrong, use
89  * BadlyPredictedBranchTarget */
91  /* Suspend fetching for this thread (inst->id.threadId).
92  * This will be woken up by another stream changing branch so
93  * count it as stream changing itself and expect pc to be the PC
94  * of the next instruction */
96  /* Branch from an interrupt (no instruction) */
98  /* Stop fetching in anticipation of of draining */
99  HaltFetch
100  };
101 
104  static bool isStreamChange(const BranchData::Reason reason);
105 
109  static bool isBranch(const BranchData::Reason reason);
110 
111  public:
114 
117 
121 
123  std::unique_ptr<PCStateBase> target;
124 
127 
128  public:
130 
131  BranchData(Reason reason_, ThreadID thread_id,
132  InstSeqNum new_stream_seq_num, InstSeqNum new_prediction_seq_num,
133  const PCStateBase &_target, MinorDynInstPtr inst_) :
134  reason(reason_), threadId(thread_id),
135  newStreamSeqNum(new_stream_seq_num),
136  newPredictionSeqNum(new_prediction_seq_num),
137  inst(inst_)
138  {
139  set(target, _target);
140  }
141 
142  BranchData(const BranchData &other) :
143  reason(other.reason), threadId(other.threadId),
146  inst(other.inst)
147  {
148  set(target, other.target);
149  }
150  BranchData &
151  operator=(const BranchData &other)
152  {
153  reason = other.reason;
154  threadId = other.threadId;
157  set(target, other.target);
158  inst = other.inst;
159  return *this;
160  }
161 
163  static BranchData bubble() { return BranchData(); }
164  bool isBubble() const { return reason == NoBranch; }
165 
167  bool isStreamChange() const { return isStreamChange(reason); }
168 
170  bool isBranch() const { return isBranch(reason); }
171 
173  void reportData(std::ostream &os) const;
174 };
175 
177 std::ostream &operator <<(std::ostream &os, BranchData::Reason reason);
178 
181 std::ostream &operator <<(std::ostream &os, const BranchData &branch);
182 
187 class ForwardLineData /* : public ReportIF, public BubbleIF */
188 {
189  private:
193  bool bubbleFlag = true;
194 
195  public:
199 
201  std::unique_ptr<PCStateBase> pc;
202 
205 
207  unsigned int lineWidth = 0;
208 
209  public:
213 
216 
219  uint8_t *line = nullptr;
220 
222  Packet *packet = nullptr;
223 
224  public:
228  pc(other.pc->clone()), fetchAddr(other.fetchAddr),
229  lineWidth(other.lineWidth), fault(other.fault), id(other.id),
230  line(other.line), packet(other.packet)
231  {}
234  {
235  bubbleFlag = other.bubbleFlag;
236  lineBaseAddr = other.lineBaseAddr;
237  set(pc, other.pc);
238  fetchAddr = other.fetchAddr;
239  lineWidth = other.lineWidth;
240  fault = other.fault;
241  id = other.id;
242  line = other.line;
243  packet = other.packet;
244  return *this;
245  }
246 
247  ~ForwardLineData() { line = NULL; }
248 
249  public:
251  bool isFault() const { return fault != NoFault; }
252 
254  void setFault(Fault fault_);
255 
258  void allocateLine(unsigned int width_);
259 
263 
268  void freeLine();
269 
271  static ForwardLineData bubble() { return ForwardLineData(); }
272  bool isBubble() const { return bubbleFlag; }
273 
275  void reportData(std::ostream &os) const;
276 };
277 
279 const unsigned int MAX_FORWARD_INSTS = 16;
280 
284 class ForwardInstData /* : public ReportIF, public BubbleIF */
285 {
286  public:
289 
291  unsigned int numInsts;
292 
295 
296  public:
297  explicit ForwardInstData(unsigned int width = 0,
298  ThreadID tid = InvalidThreadID);
299 
300  ForwardInstData(const ForwardInstData &src);
301 
302  public:
304  unsigned int width() const { return numInsts; }
305 
308 
310  void resize(unsigned int width);
311 
313  void bubbleFill();
314 
316  bool isBubble() const;
317 
319  void reportData(std::ostream &os) const;
320 };
321 
322 } // namespace minor
323 } // namespace gem5
324 
325 #endif /* __CPU_MINOR_PIPE_DATA_HH__ */
Classes for buffer, queue and FIFO behaviour.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:67
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:126
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:119
BranchData & operator=(const BranchData &other)
Definition: pipe_data.hh:151
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:113
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:120
ThreadID threadId
ThreadID associated with branch.
Definition: pipe_data.hh:116
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:167
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:170
BranchData(const BranchData &other)
Definition: pipe_data.hh:142
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:141
bool isBubble() const
Definition: pipe_data.hh:164
static BranchData bubble()
BubbleIF interface.
Definition: pipe_data.hh:163
std::unique_ptr< PCStateBase > target
Starting PC of that stream.
Definition: pipe_data.hh:123
BranchData(Reason reason_, ThreadID thread_id, InstSeqNum new_stream_seq_num, InstSeqNum new_prediction_seq_num, const PCStateBase &_target, MinorDynInstPtr inst_)
Definition: pipe_data.hh:131
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:285
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:228
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:240
ThreadID threadId
Thread associated with these instructions.
Definition: pipe_data.hh:294
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:264
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:251
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:291
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:273
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:288
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:257
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:304
Line fetch data in the forward direction.
Definition: pipe_data.hh:188
static ForwardLineData bubble()
BubbleIF interface.
Definition: pipe_data.hh:271
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:167
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:187
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:207
Addr fetchAddr
Address of this line of data.
Definition: pipe_data.hh:204
uint8_t * line
Line data.
Definition: pipe_data.hh:219
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:193
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:200
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:222
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:218
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:215
std::unique_ptr< PCStateBase > pc
PC of the first inst within this sequence.
Definition: pipe_data.hh:201
ForwardLineData & operator=(const ForwardLineData &other)
Definition: pipe_data.hh:233
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:251
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:175
ForwardLineData(const ForwardLineData &other)
Definition: pipe_data.hh:226
Fault fault
This line has a fault.
Definition: pipe_data.hh:212
Addr lineBaseAddr
First byte address in the line.
Definition: pipe_data.hh:198
Id for lines and instructions.
Definition: dyn_inst.hh:77
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:251
The dynamic instruction and instruction/line id (sequence numbers) definition for Minor.
Bitfield< 12, 11 > set
Definition: misc_types.hh:709
Bitfield< 17 > os
Definition: misc.hh:810
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition: pipe_data.hh:279
std::ostream & operator<<(std::ostream &os, const InstId &id)
Print this id in the usual slash-separated format expected by MinorTrace.
Definition: dyn_inst.cc:64
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
const ThreadID InvalidThreadID
Definition: types.hh:236
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
uint64_t InstSeqNum
Definition: inst_seq.hh:40
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.

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