gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
60 namespace minor
61 {
62 
65 class BranchData /* : public ReportIF, public BubbleIF */
66 {
67  public:
68  enum Reason
69  {
70  /* *** No change of stream (information to branch prediction) */
71 
72  /* Don't branch at all (bubble) */
74  /* Don't branch, but here's the details of a correct prediction
75  * that was executed */
77 
78  /* *** Change of stream */
79 
80  /* Take an unpredicted branch */
82  /* Take a branch on branch prediction data (from Fetch2) */
84  /* Prediction of wrong target PC */
86  /* Bad branch prediction (didn't actually branch). Need to branch
87  * back to correct stream. If the target is wrong, use
88  * BadlyPredictedBranchTarget */
90  /* Suspend fetching for this thread (inst->id.threadId).
91  * This will be woken up by another stream changing branch so
92  * count it as stream changing itself and expect pc to be the PC
93  * of the next instruction */
95  /* Branch from an interrupt (no instruction) */
97  /* Stop fetching in anticipation of of draining */
99  };
100 
103  static bool isStreamChange(const BranchData::Reason reason);
104 
108  static bool isBranch(const BranchData::Reason reason);
109 
110  public:
113 
116 
120 
122  std::unique_ptr<PCStateBase> target;
123 
126 
127  public:
129 
130  BranchData(Reason reason_, ThreadID thread_id,
131  InstSeqNum new_stream_seq_num, InstSeqNum new_prediction_seq_num,
132  const PCStateBase &_target, MinorDynInstPtr inst_) :
133  reason(reason_), threadId(thread_id),
134  newStreamSeqNum(new_stream_seq_num),
135  newPredictionSeqNum(new_prediction_seq_num),
136  inst(inst_)
137  {
138  set(target, _target);
139  }
140 
141  BranchData(const BranchData &other) :
142  reason(other.reason), threadId(other.threadId),
145  inst(other.inst)
146  {
147  set(target, other.target);
148  }
149  BranchData &
150  operator=(const BranchData &other)
151  {
152  reason = other.reason;
153  threadId = other.threadId;
156  set(target, other.target);
157  inst = other.inst;
158  return *this;
159  }
160 
162  static BranchData bubble() { return BranchData(); }
163  bool isBubble() const { return reason == NoBranch; }
164 
166  bool isStreamChange() const { return isStreamChange(reason); }
167 
169  bool isBranch() const { return isBranch(reason); }
170 
172  void reportData(std::ostream &os) const;
173 };
174 
176 std::ostream &operator <<(std::ostream &os, BranchData::Reason reason);
177 
180 std::ostream &operator <<(std::ostream &os, const BranchData &branch);
181 
186 class ForwardLineData /* : public ReportIF, public BubbleIF */
187 {
188  private:
192  bool bubbleFlag = true;
193 
194  public:
198 
200  std::unique_ptr<PCStateBase> pc;
201 
204 
206  unsigned int lineWidth = 0;
207 
208  public:
212 
215 
218  uint8_t *line = nullptr;
219 
221  Packet *packet = nullptr;
222 
223  public:
227  pc(other.pc->clone()), fetchAddr(other.fetchAddr),
228  lineWidth(other.lineWidth), fault(other.fault), id(other.id),
229  line(other.line), packet(other.packet)
230  {}
233  {
234  bubbleFlag = other.bubbleFlag;
235  lineBaseAddr = other.lineBaseAddr;
236  set(pc, other.pc);
237  fetchAddr = other.fetchAddr;
238  lineWidth = other.lineWidth;
239  fault = other.fault;
240  id = other.id;
241  line = other.line;
242  packet = other.packet;
243  return *this;
244  }
245 
246  ~ForwardLineData() { line = NULL; }
247 
248  public:
250  bool isFault() const { return fault != NoFault; }
251 
253  void setFault(Fault fault_);
254 
257  void allocateLine(unsigned int width_);
258 
262 
267  void freeLine();
268 
270  static ForwardLineData bubble() { return ForwardLineData(); }
271  bool isBubble() const { return bubbleFlag; }
272 
274  void reportData(std::ostream &os) const;
275 };
276 
278 const unsigned int MAX_FORWARD_INSTS = 16;
279 
283 class ForwardInstData /* : public ReportIF, public BubbleIF */
284 {
285  public:
288 
290  unsigned int numInsts;
291 
294 
295  public:
296  explicit ForwardInstData(unsigned int width = 0,
297  ThreadID tid = InvalidThreadID);
298 
299  ForwardInstData(const ForwardInstData &src);
300 
301  public:
303  unsigned int width() const { return numInsts; }
304 
307 
309  void resize(unsigned int width);
310 
312  void bubbleFill();
313 
315  bool isBubble() const;
316 
318  void reportData(std::ostream &os) const;
319 };
320 
321 } // namespace minor
322 } // namespace gem5
323 
324 #endif /* __CPU_MINOR_PIPE_DATA_HH__ */
gem5::minor::ForwardInstData::ForwardInstData
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:227
gem5::minor::ForwardLineData
Line fetch data in the forward direction.
Definition: pipe_data.hh:186
dyn_inst.hh
gem5::minor::ForwardLineData::bubble
static ForwardLineData bubble()
BubbleIF interface.
Definition: pipe_data.hh:270
gem5::NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
gem5::minor::BranchData::target
std::unique_ptr< PCStateBase > target
Starting PC of that stream.
Definition: pipe_data.hh:122
gem5::minor::ForwardInstData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:272
gem5::minor::ForwardInstData::bubbleFill
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:256
gem5::minor::ForwardLineData::id
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:214
gem5::minor::ForwardInstData::isBubble
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:250
gem5::minor::BranchData::Reason
Reason
Definition: pipe_data.hh:68
gem5::minor::InstId
Id for lines and instructions.
Definition: dyn_inst.hh:75
gem5::minor::ForwardInstData::insts
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:287
gem5::minor::ForwardInstData::threadId
ThreadID threadId
Thread associated with these instructions.
Definition: pipe_data.hh:293
gem5::minor::ForwardLineData::isBubble
bool isBubble() const
Definition: pipe_data.hh:271
gem5::minor::BranchData::reason
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:112
gem5::ArmISA::set
Bitfield< 12, 11 > set
Definition: misc_types.hh:760
gem5::minor::ForwardInstData::numInsts
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:290
gem5::minor::ForwardLineData::allocateLine
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:174
minor
gem5::minor::ForwardLineData::lineWidth
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:206
gem5::minor::BranchData::isBranch
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:169
gem5::minor::BranchData::bubble
static BranchData bubble()
BubbleIF interface.
Definition: pipe_data.hh:162
gem5::minor::ForwardLineData::fetchAddr
Addr fetchAddr
Address of this line of data.
Definition: pipe_data.hh:203
gem5::minor::BranchData::NoBranch
@ NoBranch
Definition: pipe_data.hh:73
gem5::minor::ForwardInstData
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:283
gem5::minor::BranchData::BranchData
BranchData()
Definition: pipe_data.hh:128
gem5::RefCountingPtr< MinorDynInst >
gem5::minor::BranchData::operator=
BranchData & operator=(const BranchData &other)
Definition: pipe_data.hh:150
gem5::minor::ForwardLineData::setFault
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:166
gem5::minor::ForwardLineData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:217
gem5::minor::BranchData::Interrupt
@ Interrupt
Definition: pipe_data.hh:96
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
gem5::minor::ForwardLineData::pc
std::unique_ptr< PCStateBase > pc
PC of the first inst within this sequence.
Definition: pipe_data.hh:200
gem5::minor::BranchData::CorrectlyPredictedBranch
@ CorrectlyPredictedBranch
Definition: pipe_data.hh:76
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::minor::BranchData::BadlyPredictedBranchTarget
@ BadlyPredictedBranchTarget
Definition: pipe_data.hh:85
gem5::minor::ForwardLineData::line
uint8_t * line
Line data.
Definition: pipe_data.hh:218
gem5::minor::MinorDynInst::bubble
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:250
gem5::minor::ForwardInstData::width
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:303
gem5::minor::ForwardInstData::operator=
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:239
gem5::InvalidThreadID
const ThreadID InvalidThreadID
Definition: types.hh:236
gem5::minor::MAX_FORWARD_INSTS
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition: pipe_data.hh:278
gem5::minor::BranchData
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:65
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::minor::BranchData::inst
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:125
gem5::minor::BranchData::isBubble
bool isBubble() const
Definition: pipe_data.hh:163
gem5::minor::ForwardLineData::~ForwardLineData
~ForwardLineData()
Definition: pipe_data.hh:246
gem5::minor::ForwardLineData::isFault
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:250
gem5::minor::ForwardLineData::packet
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:221
gem5::minor::ForwardLineData::operator=
ForwardLineData & operator=(const ForwardLineData &other)
Definition: pipe_data.hh:232
gem5::minor::ForwardLineData::adoptPacketData
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:186
gem5::minor::BranchData::isStreamChange
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:166
gem5::minor::ForwardInstData::resize
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:263
gem5::minor::ForwardLineData::ForwardLineData
ForwardLineData(const ForwardLineData &other)
Definition: pipe_data.hh:225
base.hh
gem5::minor::BranchData::threadId
ThreadID threadId
ThreadID associated with branch.
Definition: pipe_data.hh:115
gem5::minor::BranchData::BranchData
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:130
gem5::X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:810
gem5::minor::operator<<
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:63
gem5::minor::BranchData::HaltFetch
@ HaltFetch
Definition: pipe_data.hh:98
gem5::minor::BranchData::BranchPrediction
@ BranchPrediction
Definition: pipe_data.hh:83
gem5::minor::ForwardLineData::lineBaseAddr
Addr lineBaseAddr
First byte address in the line.
Definition: pipe_data.hh:197
gem5::InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:40
gem5::minor::BranchData::BadlyPredictedBranch
@ BadlyPredictedBranch
Definition: pipe_data.hh:89
buffers.hh
gem5::minor::ForwardLineData::fault
Fault fault
This line has a fault.
Definition: pipe_data.hh:211
gem5::PCStateBase
Definition: pcstate.hh:57
gem5::minor::BranchData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:140
gem5::minor::BranchData::SuspendThread
@ SuspendThread
Definition: pipe_data.hh:94
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::minor::BranchData::UnpredictedBranch
@ UnpredictedBranch
Definition: pipe_data.hh:81
gem5::minor::BranchData::newPredictionSeqNum
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:119
gem5::minor::ForwardLineData::ForwardLineData
ForwardLineData()
Definition: pipe_data.hh:224
gem5::minor::BranchData::newStreamSeqNum
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:118
gem5::minor::ForwardLineData::bubbleFlag
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:192
gem5::ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:235
gem5::minor::ForwardLineData::freeLine
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:199
gem5::minor::BranchData::BranchData
BranchData(const BranchData &other)
Definition: pipe_data.hh:141

Generated on Sun Jul 30 2023 01:56:52 for gem5 by doxygen 1.8.17