gem5  v20.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 Minor
58 {
59 
62 class BranchData /* : public ReportIF, public BubbleIF */
63 {
64  public:
65  enum Reason
66  {
67  /* *** No change of stream (information to branch prediction) */
68 
69  /* Don't branch at all (bubble) */
71  /* Don't branch, but here's the details of a correct prediction
72  * that was executed */
74 
75  /* *** Change of stream */
76 
77  /* Take an unpredicted branch */
79  /* Take a branch on branch prediction data (from Fetch2) */
81  /* Prediction of wrong target PC */
83  /* Bad branch prediction (didn't actually branch). Need to branch
84  * back to correct stream. If the target is wrong, use
85  * BadlyPredictedBranchTarget */
87  /* Suspend fetching for this thread (inst->id.threadId).
88  * This will be woken up by another stream changing branch so
89  * count it as stream changing itself and expect pc to be the PC
90  * of the next instruction */
92  /* Branch from an interrupt (no instruction) */
94  /* Stop fetching in anticipation of of draining */
96  };
97 
100  static bool isStreamChange(const BranchData::Reason reason);
101 
105  static bool isBranch(const BranchData::Reason reason);
106 
107  public:
110 
113 
117 
120 
123 
124  public:
129  { }
130 
132  Reason reason_,
133  ThreadID thread_id,
134  InstSeqNum new_stream_seq_num,
135  InstSeqNum new_prediction_seq_num,
137  MinorDynInstPtr inst_) :
138  reason(reason_),
139  threadId(thread_id),
140  newStreamSeqNum(new_stream_seq_num),
141  newPredictionSeqNum(new_prediction_seq_num),
142  target(target),
143  inst(inst_)
144  { }
145 
147  static BranchData bubble() { return BranchData(); }
148  bool isBubble() const { return reason == NoBranch; }
149 
151  bool isStreamChange() const { return isStreamChange(reason); }
152 
154  bool isBranch() const { return isBranch(reason); }
155 
157  void reportData(std::ostream &os) const;
158 };
159 
161 std::ostream &operator <<(std::ostream &os, BranchData::Reason reason);
162 
165 std::ostream &operator <<(std::ostream &os, const BranchData &branch);
166 
171 class ForwardLineData /* : public ReportIF, public BubbleIF */
172 {
173  private:
177 
178  public:
182 
185 
187  unsigned int lineWidth;
188 
189  public:
193 
196 
199  uint8_t *line;
200 
203 
204  public:
206  bubbleFlag(true),
207  lineBaseAddr(0),
208  lineWidth(0),
209  fault(NoFault),
210  line(NULL),
211  packet(NULL)
212  {
213  /* Make lines bubbles by default */
214  }
215 
216  ~ForwardLineData() { line = NULL; }
217 
218  public:
220  bool isFault() const { return fault != NoFault; }
221 
223  void setFault(Fault fault_);
224 
227  void allocateLine(unsigned int width_);
228 
232 
237  void freeLine();
238 
240  static ForwardLineData bubble() { return ForwardLineData(); }
241  bool isBubble() const { return bubbleFlag; }
242 
244  void reportData(std::ostream &os) const;
245 };
246 
248 const unsigned int MAX_FORWARD_INSTS = 16;
249 
253 class ForwardInstData /* : public ReportIF, public BubbleIF */
254 {
255  public:
258 
260  unsigned int numInsts;
261 
264 
265  public:
266  explicit ForwardInstData(unsigned int width = 0,
267  ThreadID tid = InvalidThreadID);
268 
269  ForwardInstData(const ForwardInstData &src);
270 
271  public:
273  unsigned int width() const { return numInsts; }
274 
277 
279  void resize(unsigned int width);
280 
282  void bubbleFill();
283 
285  bool isBubble() const;
286 
288  void reportData(std::ostream &os) const;
289 };
290 
291 }
292 
293 #endif /* __CPU_MINOR_PIPE_DATA_HH__ */
InvalidThreadID
const ThreadID InvalidThreadID
Definition: types.hh:228
dyn_inst.hh
Minor::BranchData::threadId
ThreadID threadId
ThreadID associated with branch.
Definition: pipe_data.hh:112
Minor::BranchData::target
TheISA::PCState target
Starting PC of that stream.
Definition: pipe_data.hh:119
Minor::ForwardInstData::threadId
ThreadID threadId
Thread associated with these instructions.
Definition: pipe_data.hh:263
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
Minor::BranchData::inst
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:122
Minor::ForwardInstData
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:253
Minor::BranchData::BranchPrediction
@ BranchPrediction
Definition: pipe_data.hh:80
Minor::ForwardInstData::bubbleFill
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:253
Minor::BranchData::isStreamChange
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:151
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Minor::ForwardLineData::adoptPacketData
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:183
Minor::BranchData::newStreamSeqNum
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:115
Minor::ForwardInstData::ForwardInstData
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:224
TheISA
Definition: decode_cache.hh:37
Minor::ForwardLineData
Line fetch data in the forward direction.
Definition: pipe_data.hh:171
Minor::BranchData::HaltFetch
@ HaltFetch
Definition: pipe_data.hh:95
Minor::BranchData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:137
Minor::ForwardLineData::freeLine
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:196
Minor::BranchData::reason
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:109
Minor::ForwardLineData::id
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:195
Minor::BranchData::UnpredictedBranch
@ UnpredictedBranch
Definition: pipe_data.hh:78
Minor::BranchData::BadlyPredictedBranchTarget
@ BadlyPredictedBranchTarget
Definition: pipe_data.hh:82
Minor
Definition: activity.cc:44
Minor::BranchData::CorrectlyPredictedBranch
@ CorrectlyPredictedBranch
Definition: pipe_data.hh:73
Minor::ForwardLineData::lineWidth
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:187
Minor::ForwardInstData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:269
Minor::ForwardLineData::packet
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:202
Minor::BranchData::isBubble
bool isBubble() const
Definition: pipe_data.hh:148
Minor::ForwardLineData::fault
Fault fault
This line has a fault.
Definition: pipe_data.hh:192
Minor::BranchData::NoBranch
@ NoBranch
Definition: pipe_data.hh:70
Minor::BranchData::isBranch
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:154
Minor::BranchData::Interrupt
@ Interrupt
Definition: pipe_data.hh:93
Minor::MinorDynInst
Dynamic instruction for Minor.
Definition: dyn_inst.hh:155
Minor::ForwardLineData::lineBaseAddr
Addr lineBaseAddr
First byte address in the line.
Definition: pipe_data.hh:181
Minor::ForwardLineData::reportData
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:214
Minor::ForwardLineData::setFault
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:163
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
Minor::ForwardInstData::width
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:273
Minor::ForwardInstData::isBubble
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:247
Minor::ForwardInstData::insts
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:257
Minor::ForwardInstData::numInsts
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:260
Minor::ForwardLineData::allocateLine
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:171
Minor::ForwardLineData::~ForwardLineData
~ForwardLineData()
Definition: pipe_data.hh:216
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Minor::ForwardLineData::isFault
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:220
Minor::BranchData::newPredictionSeqNum
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:116
Minor::ForwardLineData::bubbleFlag
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:176
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:248
Minor::ForwardLineData::isBubble
bool isBubble() const
Definition: pipe_data.hh:241
Minor::BranchData::BranchData
BranchData()
Definition: pipe_data.hh:125
Minor::BranchData
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:62
Minor::BranchData::BadlyPredictedBranch
@ BadlyPredictedBranch
Definition: pipe_data.hh:86
Minor::BranchData::Reason
Reason
Definition: pipe_data.hh:65
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:61
base.hh
Minor::ForwardLineData::bubble
static ForwardLineData bubble()
BubbleIF interface.
Definition: pipe_data.hh:240
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
Minor::ForwardLineData::ForwardLineData
ForwardLineData()
Definition: pipe_data.hh:205
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Minor::BranchData::bubble
static BranchData bubble()
BubbleIF interface.
Definition: pipe_data.hh:147
Minor::ForwardLineData::pc
TheISA::PCState pc
PC of the first requested inst within this line.
Definition: pipe_data.hh:184
Minor::ForwardInstData::operator=
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:236
buffers.hh
RefCountingPtr< MinorDynInst >
Minor::ForwardInstData::resize
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:260
Minor::ForwardLineData::line
uint8_t * line
Line data.
Definition: pipe_data.hh:199
Minor::InstId
Id for lines and instructions.
Definition: dyn_inst.hh:68
Minor::BranchData::SuspendThread
@ SuspendThread
Definition: pipe_data.hh:91
Minor::BranchData::BranchData
BranchData(Reason reason_, ThreadID thread_id, InstSeqNum new_stream_seq_num, InstSeqNum new_prediction_seq_num, TheISA::PCState target, MinorDynInstPtr inst_)
Definition: pipe_data.hh:131

Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17