gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  * Authors: Andrew Bardsley
38  */
39 
52 #ifndef __CPU_MINOR_PIPE_DATA_HH__
53 #define __CPU_MINOR_PIPE_DATA_HH__
54 
55 #include "cpu/minor/buffers.hh"
56 #include "cpu/minor/dyn_inst.hh"
57 #include "cpu/base.hh"
58 
59 namespace Minor
60 {
61 
64 class BranchData /* : public ReportIF, public BubbleIF */
65 {
66  public:
67  enum Reason
68  {
69  /* *** No change of stream (information to branch prediction) */
70 
71  /* Don't branch at all (bubble) */
73  /* Don't branch, but here's the details of a correct prediction
74  * that was executed */
76 
77  /* *** Change of stream */
78 
79  /* Take an unpredicted branch */
81  /* Take a branch on branch prediction data (from Fetch2) */
83  /* Prediction of wrong target PC */
85  /* Bad branch prediction (didn't actually branch). Need to branch
86  * back to correct stream. If the target is wrong, use
87  * BadlyPredictedBranchTarget */
89  /* Suspend fetching for this thread (inst->id.threadId).
90  * This will be woken up by another stream changing branch so
91  * count it as stream changing itself and expect pc to be the PC
92  * of the next instruction */
94  /* Branch from an interrupt (no instruction) */
96  /* Stop fetching in anticipation of of draining */
98  };
99 
102  static bool isStreamChange(const BranchData::Reason reason);
103 
107  static bool isBranch(const BranchData::Reason reason);
108 
109  public:
112 
115 
119 
122 
125 
126  public:
129  newPredictionSeqNum(0), target(TheISA::PCState(0)),
131  { }
132 
134  Reason reason_,
135  ThreadID thread_id,
136  InstSeqNum new_stream_seq_num,
137  InstSeqNum new_prediction_seq_num,
139  MinorDynInstPtr inst_) :
140  reason(reason_),
141  threadId(thread_id),
142  newStreamSeqNum(new_stream_seq_num),
143  newPredictionSeqNum(new_prediction_seq_num),
144  target(target),
145  inst(inst_)
146  { }
147 
149  static BranchData bubble() { return BranchData(); }
150  bool isBubble() const { return reason == NoBranch; }
151 
153  bool isStreamChange() const { return isStreamChange(reason); }
154 
156  bool isBranch() const { return isBranch(reason); }
157 
159  void reportData(std::ostream &os) const;
160 };
161 
163 std::ostream &operator <<(std::ostream &os, BranchData::Reason reason);
164 
167 std::ostream &operator <<(std::ostream &os, const BranchData &branch);
168 
173 class ForwardLineData /* : public ReportIF, public BubbleIF */
174 {
175  private:
179 
180  public:
184 
187 
189  unsigned int lineWidth;
190 
191  public:
195 
198 
201  uint8_t *line;
202 
205 
206  public:
208  bubbleFlag(true),
209  lineBaseAddr(0),
210  lineWidth(0),
211  fault(NoFault),
212  line(NULL),
213  packet(NULL)
214  {
215  /* Make lines bubbles by default */
216  }
217 
218  ~ForwardLineData() { line = NULL; }
219 
220  public:
222  bool isFault() const { return fault != NoFault; }
223 
225  void setFault(Fault fault_);
226 
229  void allocateLine(unsigned int width_);
230 
234 
239  void freeLine();
240 
242  static ForwardLineData bubble() { return ForwardLineData(); }
243  bool isBubble() const { return bubbleFlag; }
244 
246  void reportData(std::ostream &os) const;
247 };
248 
250 const unsigned int MAX_FORWARD_INSTS = 16;
251 
255 class ForwardInstData /* : public ReportIF, public BubbleIF */
256 {
257  public:
260 
262  unsigned int numInsts;
263 
266 
267  public:
268  explicit ForwardInstData(unsigned int width = 0,
269  ThreadID tid = InvalidThreadID);
270 
271  ForwardInstData(const ForwardInstData &src);
272 
273  public:
275  unsigned int width() const { return numInsts; }
276 
279 
281  void resize(unsigned int width);
282 
284  void bubbleFill();
285 
287  bool isBubble() const;
288 
290  void reportData(std::ostream &os) const;
291 };
292 
293 }
294 
295 #endif /* __CPU_MINOR_PIPE_DATA_HH__ */
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:124
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
decltype(nullptr) constexpr NoFault
Definition: types.hh:189
static BranchData bubble()
BubbleIF interface.
Definition: pipe_data.hh:149
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition: pipe_data.hh:250
Addr lineBaseAddr
First byte address in the line.
Definition: pipe_data.hh:183
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:139
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:222
ThreadID threadId
ThreadID associated with branch.
Definition: pipe_data.hh:114
bool isBubble() const
Definition: pipe_data.hh:243
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:178
Line fetch data in the forward direction.
Definition: pipe_data.hh:173
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:111
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:216
Id for lines and instructions.
Definition: dyn_inst.hh:70
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:117
TheISA::PCState pc
PC of the first requested inst within this line.
Definition: pipe_data.hh:186
Bitfield< 17 > os
Definition: misc.hh:804
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:275
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:156
bool isBubble() const
BubbleIF interface.
Definition: pipe_data.cc:249
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition: pipe_data.cc:226
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition: pipe_data.cc:262
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:271
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition: pipe_data.hh:259
uint8_t * line
Line data.
Definition: pipe_data.hh:201
uint64_t InstSeqNum
Definition: inst_seq.hh:40
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition: pipe_data.hh:189
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:197
Classes for buffer, queue and FIFO behaviour.
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition: pipe_data.hh:262
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition: pipe_data.cc:255
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
const ThreadID InvalidThreadID
Definition: types.hh:172
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
Dynamic instruction for Minor.
Definition: dyn_inst.hh:157
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:64
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:153
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:204
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
static ForwardLineData bubble()
BubbleIF interface.
Definition: pipe_data.hh:242
The dynamic instruction and instruction/line id (sequence numbers) definition for Minor...
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:118
Fault fault
This line has a fault.
Definition: pipe_data.hh:194
bool isBubble() const
Definition: pipe_data.hh:150
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition: pipe_data.cc:173
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition: pipe_data.cc:165
TheISA::PCState target
Starting PC of that stream.
Definition: pipe_data.hh:121
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition: pipe_data.cc:238
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition: pipe_data.cc:185
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:133
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
void freeLine()
Free this ForwardLineData line.
Definition: pipe_data.cc:198
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:255
ThreadID threadId
Thread associated with these instructions.
Definition: pipe_data.hh:265

Generated on Fri Jun 9 2017 13:03:42 for gem5 by doxygen 1.8.6