gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
39
40namespace gem5
41{
42
43namespace minor
44{
45
46std::ostream &
47operator <<(std::ostream &os, BranchData::Reason reason)
48{
49 switch (reason)
50 {
52 os << "NoBranch";
53 break;
55 os << "UnpredictedBranch";
56 break;
58 os << "BranchPrediction";
59 break;
61 os << "CorrectlyPredictedBranch";
62 break;
64 os << "BadlyPredictedBranch";
65 break;
67 os << "BadlyPredictedBranchTarget";
68 break;
70 os << "Interrupt";
71 break;
73 os << "SuspendThread";
74 break;
76 os << "HaltFetch";
77 break;
78 }
79
80 return os;
81}
82
83bool
85{
86 bool ret = false;
87
88 switch (reason)
89 {
90 /* No change of stream (see the enum comment in pipe_data.hh) */
91 case NoBranch:
93 ret = false;
94 break;
95
96 /* Change of stream (Fetch1 should act on) */
101 case SuspendThread:
102 case Interrupt:
103 case HaltFetch:
104 ret = true;
105 break;
106 }
107
108 return ret;
109}
110
111bool
113{
114 bool ret = false;
115
116 switch (reason)
117 {
118 /* No change of stream (see the enum comment in pipe_data.hh) */
119 case NoBranch:
121 case SuspendThread:
122 case Interrupt:
123 case HaltFetch:
124 ret = false;
125 break;
126
127 /* Change of stream (Fetch1 should act on) */
129 case BranchPrediction:
132 ret = true;
133 break;
134 }
135
136 return ret;
137}
138
139void
140BranchData::reportData(std::ostream &os) const
141{
142 if (isBubble()) {
143 os << '-';
144 } else {
145 os << reason
146 << ';' << newStreamSeqNum << '.' << newPredictionSeqNum
147 << ";0x" << std::hex << target->instAddr() << std::dec
148 << ';';
149 inst->reportData(os);
150 }
151}
152
153std::ostream &
154operator <<(std::ostream &os, const BranchData &branch)
155{
156 os << branch.reason << " target: 0x"
157 << std::hex << branch.target->instAddr() << std::dec
158 << ' ' << *branch.inst
159 << ' ' << branch.newStreamSeqNum << "(stream)."
160 << branch.newPredictionSeqNum << "(pred)";
161
162 return os;
163}
164
165void
167{
168 fault = fault_;
169 if (isFault())
170 bubbleFlag = false;
171}
172
173void
175{
176 lineWidth = width_;
177 bubbleFlag = false;
178
179 assert(!isFault());
180 assert(!line);
181
182 line = new uint8_t[width_];
183}
184
185void
187{
188 this->packet = packet;
189 lineWidth = packet->req->getSize();
190 bubbleFlag = false;
191
192 assert(!isFault());
193 assert(!line);
194
195 line = packet->getPtr<uint8_t>();
196}
197
198void
200{
201 /* Only free lines in non-faulting, non-bubble lines */
202 if (!isFault() && !isBubble()) {
203 assert(line);
204 /* If packet is not NULL then the line must belong to the packet so
205 * we don't need to separately deallocate the line */
206 if (packet) {
207 delete packet;
208 } else {
209 delete [] line;
210 }
211 line = NULL;
212 bubbleFlag = true;
213 }
214}
215
216void
217ForwardLineData::reportData(std::ostream &os) const
218{
219 if (isBubble())
220 os << '-';
221 else if (fault != NoFault)
222 os << "F;" << id;
223 else
224 os << id;
225}
226
228 numInsts(width), threadId(tid)
229{
230 bubbleFill();
231}
232
234{
235 *this = src;
236}
237
240{
241 numInsts = src.numInsts;
242
243 for (unsigned int i = 0; i < src.numInsts; i++)
244 insts[i] = src.insts[i];
245
246 return *this;
247}
248
249bool
251{
252 return numInsts == 0 || insts[0]->isBubble();
253}
254
255void
257{
258 for (unsigned int i = 0; i < numInsts; i++)
260}
261
262void
264{
265 assert(width < MAX_FORWARD_INSTS);
266 numInsts = width;
267
268 bubbleFill();
269}
270
271void
272ForwardInstData::reportData(std::ostream &os) const
273{
274 if (isBubble()) {
275 os << '-';
276 } else {
277 unsigned int i = 0;
278
279 os << '(';
280 while (i != numInsts) {
281 insts[i]->reportData(os);
282 i++;
283 if (i != numInsts)
284 os << ',';
285 }
286 os << ')';
287 }
288}
289
290} // namespace minor
291} // namespace gem5
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
T * getPtr()
get a pointer to the data ptr.
Definition packet.hh:1225
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition pipe_data.hh:66
MinorDynInstPtr inst
Instruction which caused this branch.
Definition pipe_data.hh:125
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Definition pipe_data.hh:118
Reason reason
Explanation for this branch.
Definition pipe_data.hh:112
InstSeqNum newPredictionSeqNum
Definition pipe_data.hh:119
bool isStreamChange() const
As static isStreamChange but on this branch data.
Definition pipe_data.hh:166
bool isBranch() const
As static isBranch but on this branch data.
Definition pipe_data.hh:169
void reportData(std::ostream &os) const
ReportIF interface.
Definition pipe_data.cc:140
std::unique_ptr< PCStateBase > target
Starting PC of that stream.
Definition pipe_data.hh:122
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
Definition pipe_data.hh:284
ForwardInstData(unsigned int width=0, ThreadID tid=InvalidThreadID)
Definition pipe_data.cc:227
ForwardInstData & operator=(const ForwardInstData &src)
Copy the inst array only as far as numInsts.
Definition pipe_data.cc:239
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
Definition pipe_data.cc:263
bool isBubble() const
BubbleIF interface.
Definition pipe_data.cc:250
unsigned int numInsts
The number of insts slots that can be expected to be valid insts.
Definition pipe_data.hh:290
void reportData(std::ostream &os) const
ReportIF interface.
Definition pipe_data.cc:272
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
Definition pipe_data.hh:287
void bubbleFill()
Fill with bubbles from 0 to width() - 1.
Definition pipe_data.cc:256
unsigned int width() const
Number of instructions carried by this object.
Definition pipe_data.hh:303
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
Definition pipe_data.cc:166
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
Definition pipe_data.cc:186
unsigned int lineWidth
Explicit line width, don't rely on data.size.
Definition pipe_data.hh:206
uint8_t * line
Line data.
Definition pipe_data.hh:218
bool bubbleFlag
This line is a bubble.
Definition pipe_data.hh:192
void freeLine()
Free this ForwardLineData line.
Definition pipe_data.cc:199
Packet * packet
Packet from which the line is taken.
Definition pipe_data.hh:221
void reportData(std::ostream &os) const
ReportIF interface.
Definition pipe_data.cc:217
InstId id
Thread, stream, prediction ... id of this line.
Definition pipe_data.hh:214
bool isFault() const
This is a fault, not a line.
Definition pipe_data.hh:250
void allocateLine(unsigned int width_)
In-place initialise a ForwardLineData, freeing and overridding the line.
Definition pipe_data.cc:174
Fault fault
This line has a fault.
Definition pipe_data.hh:211
static MinorDynInstPtr bubble()
There is a single bubble inst.
Definition dyn_inst.hh:250
Bitfield< 4 > width
Definition misc_types.hh:72
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 17 > os
Definition misc.hh:838
const unsigned int MAX_FORWARD_INSTS
Maximum number of instructions that can be carried by the pipeline.
Definition pipe_data.hh:278
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
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
constexpr decltype(nullptr) NoFault
Definition types.hh:253
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 Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0