gem5  v22.1.0.0
pipe_data.cc
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 
38 #include "cpu/minor/pipe_data.hh"
39 
40 namespace gem5
41 {
42 
44 namespace minor
45 {
46 
47 std::ostream &
48 operator <<(std::ostream &os, BranchData::Reason reason)
49 {
50  switch (reason)
51  {
53  os << "NoBranch";
54  break;
56  os << "UnpredictedBranch";
57  break;
59  os << "BranchPrediction";
60  break;
62  os << "CorrectlyPredictedBranch";
63  break;
65  os << "BadlyPredictedBranch";
66  break;
68  os << "BadlyPredictedBranchTarget";
69  break;
71  os << "Interrupt";
72  break;
74  os << "SuspendThread";
75  break;
77  os << "HaltFetch";
78  break;
79  }
80 
81  return os;
82 }
83 
84 bool
86 {
87  bool ret = false;
88 
89  switch (reason)
90  {
91  /* No change of stream (see the enum comment in pipe_data.hh) */
92  case NoBranch:
94  ret = false;
95  break;
96 
97  /* Change of stream (Fetch1 should act on) */
98  case UnpredictedBranch:
99  case BranchPrediction:
102  case SuspendThread:
103  case Interrupt:
104  case HaltFetch:
105  ret = true;
106  break;
107  }
108 
109  return ret;
110 }
111 
112 bool
114 {
115  bool ret = false;
116 
117  switch (reason)
118  {
119  /* No change of stream (see the enum comment in pipe_data.hh) */
120  case NoBranch:
122  case SuspendThread:
123  case Interrupt:
124  case HaltFetch:
125  ret = false;
126  break;
127 
128  /* Change of stream (Fetch1 should act on) */
129  case UnpredictedBranch:
130  case BranchPrediction:
133  ret = true;
134  break;
135  }
136 
137  return ret;
138 }
139 
140 void
141 BranchData::reportData(std::ostream &os) const
142 {
143  if (isBubble()) {
144  os << '-';
145  } else {
146  os << reason
147  << ';' << newStreamSeqNum << '.' << newPredictionSeqNum
148  << ";0x" << std::hex << target->instAddr() << std::dec
149  << ';';
150  inst->reportData(os);
151  }
152 }
153 
154 std::ostream &
155 operator <<(std::ostream &os, const BranchData &branch)
156 {
157  os << branch.reason << " target: 0x"
158  << std::hex << branch.target->instAddr() << std::dec
159  << ' ' << *branch.inst
160  << ' ' << branch.newStreamSeqNum << "(stream)."
161  << branch.newPredictionSeqNum << "(pred)";
162 
163  return os;
164 }
165 
166 void
168 {
169  fault = fault_;
170  if (isFault())
171  bubbleFlag = false;
172 }
173 
174 void
175 ForwardLineData::allocateLine(unsigned int width_)
176 {
177  lineWidth = width_;
178  bubbleFlag = false;
179 
180  assert(!isFault());
181  assert(!line);
182 
183  line = new uint8_t[width_];
184 }
185 
186 void
188 {
189  this->packet = packet;
190  lineWidth = packet->req->getSize();
191  bubbleFlag = false;
192 
193  assert(!isFault());
194  assert(!line);
195 
196  line = packet->getPtr<uint8_t>();
197 }
198 
199 void
201 {
202  /* Only free lines in non-faulting, non-bubble lines */
203  if (!isFault() && !isBubble()) {
204  assert(line);
205  /* If packet is not NULL then the line must belong to the packet so
206  * we don't need to separately deallocate the line */
207  if (packet) {
208  delete packet;
209  } else {
210  delete [] line;
211  }
212  line = NULL;
213  bubbleFlag = true;
214  }
215 }
216 
217 void
218 ForwardLineData::reportData(std::ostream &os) const
219 {
220  if (isBubble())
221  os << '-';
222  else if (fault != NoFault)
223  os << "F;" << id;
224  else
225  os << id;
226 }
227 
229  numInsts(width), threadId(tid)
230 {
231  bubbleFill();
232 }
233 
235 {
236  *this = src;
237 }
238 
241 {
242  numInsts = src.numInsts;
243 
244  for (unsigned int i = 0; i < src.numInsts; i++)
245  insts[i] = src.insts[i];
246 
247  return *this;
248 }
249 
250 bool
252 {
253  return numInsts == 0 || insts[0]->isBubble();
254 }
255 
256 void
258 {
259  for (unsigned int i = 0; i < numInsts; i++)
261 }
262 
263 void
265 {
266  assert(width < MAX_FORWARD_INSTS);
267  numInsts = width;
268 
269  bubbleFill();
270 }
271 
272 void
273 ForwardInstData::reportData(std::ostream &os) const
274 {
275  if (isBubble()) {
276  os << '-';
277  } else {
278  unsigned int i = 0;
279 
280  os << '(';
281  while (i != numInsts) {
282  insts[i]->reportData(os);
283  i++;
284  if (i != numInsts)
285  os << ',';
286  }
287  os << ')';
288  }
289 }
290 
291 } // namespace minor
292 } // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
T * getPtr()
get a pointer to the data ptr.
Definition: packet.hh:1212
RequestPtr req
A pointer to the original request.
Definition: packet.hh:376
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
Reason reason
Explanation for this branch.
Definition: pipe_data.hh:113
InstSeqNum newPredictionSeqNum
Definition: pipe_data.hh:120
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
void reportData(std::ostream &os) const
ReportIF interface.
Definition: pipe_data.cc:141
bool isBubble() const
Definition: pipe_data.hh:164
std::unique_ptr< PCStateBase > target
Starting PC of that stream.
Definition: pipe_data.hh:123
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
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
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
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
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
Fault fault
This line has a fault.
Definition: pipe_data.hh:212
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition: dyn_inst.hh:251
Bitfield< 4 > width
Definition: misc_types.hh:72
Bitfield< 7 > i
Definition: misc_types.hh:67
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
constexpr decltype(nullptr) NoFault
Definition: types.hh:253
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Contains class definitions for data flowing between pipeline stages in the top-level structure portio...

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