gem5  v20.0.0.3
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:
126  reason(NoBranch), threadId(InvalidThreadID), newStreamSeqNum(0),
127  newPredictionSeqNum(0), target(TheISA::PCState(0)),
128  inst(MinorDynInst::bubble())
129  { }
130 
132  Reason reason_,
133  ThreadID thread_id,
134  InstSeqNum new_stream_seq_num,
135  InstSeqNum new_prediction_seq_num,
136  TheISA::PCState target,
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 
231  void adoptPacketData(Packet *packet);
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 
276  ForwardInstData &operator =(const ForwardInstData &src);
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__ */
MinorDynInstPtr inst
Instruction which caused this branch.
Definition: pipe_data.hh:122
bool isBubble() const
Definition: pipe_data.hh:241
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
decltype(nullptr) constexpr NoFault
Definition: types.hh:243
bool isBranch() const
As static isBranch but on this branch data.
Definition: pipe_data.hh:154
static BranchData bubble()
BubbleIF interface.
Definition: pipe_data.hh:147
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition: pipe_data.hh:248
Addr lineBaseAddr
First byte address in the line.
Definition: pipe_data.hh:181
ThreadID threadId
ThreadID associated with branch.
Definition: pipe_data.hh:112
bool bubbleFlag
This line is a bubble.
Definition: pipe_data.hh:176
Line fetch data in the forward direction.
Definition: pipe_data.hh:171
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:109
unsigned int width() const
Number of instructions carried by this object.
Definition: pipe_data.hh:273
Id for lines and instructions.
Definition: dyn_inst.hh:68
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition: pipe_data.hh:115
TheISA::PCState pc
PC of the first requested inst within this line.
Definition: pipe_data.hh:184
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Definition: activity.cc:44
Bitfield< 17 > os
Definition: misc.hh:803
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:137
bool isBubble() const
Definition: pipe_data.hh:148
uint8_t * line
Line data.
Definition: pipe_data.hh:199
uint64_t InstSeqNum
Definition: inst_seq.hh:37
unsigned int lineWidth
Explicit line width, don&#39;t rely on data.size.
Definition: pipe_data.hh:187
InstId id
Thread, stream, prediction ...
Definition: pipe_data.hh:195
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:260
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
const ThreadID InvalidThreadID
Definition: types.hh:226
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
Dynamic instruction for Minor.
Definition: dyn_inst.hh:155
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:62
Packet * packet
Packet from which the line is taken.
Definition: pipe_data.hh:202
bool isFault() const
This is a fault, not a line.
Definition: pipe_data.hh:220
static ForwardLineData bubble()
BubbleIF interface.
Definition: pipe_data.hh:240
The dynamic instruction and instruction/line id (sequence numbers) definition for Minor...
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:116
Bitfield< 4 > width
Fault fault
This line has a fault.
Definition: pipe_data.hh:192
TheISA::PCState target
Starting PC of that stream.
Definition: pipe_data.hh:119
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
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
std::shared_ptr< FaultBase > Fault
Definition: types.hh:238
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition: pipe_data.hh:253
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition: pipe_data.hh:151
ThreadID threadId
Thread associated with these instructions.
Definition: pipe_data.hh:263

Generated on Fri Jul 3 2020 15:53:00 for gem5 by doxygen 1.8.13