gem5 v24.0.0.0
Loading...
Searching...
No Matches
fetch1.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
45#ifndef __CPU_MINOR_FETCH1_HH__
46#define __CPU_MINOR_FETCH1_HH__
47
48#include <vector>
49
50#include "arch/generic/mmu.hh"
51#include "base/named.hh"
52#include "cpu/base.hh"
53#include "cpu/minor/buffers.hh"
54#include "cpu/minor/cpu.hh"
56#include "mem/packet.hh"
57
58namespace gem5
59{
60
61namespace minor
62{
63
66class Fetch1 : public Named
67{
68 protected:
71 {
72 protected:
75
76 public:
77 IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu) :
79 { }
80
81 protected:
83 { return fetch.recvTimingResp(pkt); }
84
86 };
87
107 public BaseMMU::Translation, /* For TLB lookups */
108 public Packet::SenderState /* For packing into a Packet */
109 {
110 protected:
113
114 public:
118 {
119 NotIssued, /* Just been made */
120 InTranslation, /* Issued to ITLB, must wait for reqply */
121 Translated, /* Translation complete */
122 RequestIssuing, /* Issued to memory, must wait for response */
123 Complete /* Complete. Either a fault, or a fetched line */
124 };
125
127
130
136
139
142
146
148 void makePacket();
149
151 void reportData(std::ostream &os) const;
152
156 bool isDiscardable() const;
157
159 bool isComplete() const { return state == Complete; }
160
161 protected:
166 void markDelayed() { }
167
171 void finish(const Fault &fault_, const RequestPtr &request_,
173
174 public:
175 FetchRequest(Fetch1 &fetch_, InstId id_, Addr pc_) :
176 SenderState(),
177 fetch(fetch_),
179 id(id_),
180 packet(NULL),
181 request(),
182 pc(pc_),
184 {
185 request = std::make_shared<Request>();
186 }
187
189 };
190
192
193 protected:
198
205
208
212
217
223
225 unsigned int fetchLimit;
226
227 protected:
232 {
233 FetchHalted, /* Not fetching, waiting to be woken by transition
234 to FetchWaitingForPC. The PC is not valid in this state */
235 FetchWaitingForPC, /* Not fetching, waiting for stream change.
236 This doesn't stop issued fetches from being returned and
237 processed or for branches to change the state to Running. */
238 FetchRunning /* Try to fetch, when possible */
239 };
240
244 {
245 // All fields have default initializers.
247
249 state(other.state),
250 pc(other.pc->clone()),
253 blocked(other.blocked)
254 { }
255
257
261 std::unique_ptr<PCStateBase> pc;
262
265
270
276
278 bool blocked = false;
279
281 bool wakeupGuard = false;
282 };
283
286
289 {
290 IcacheRunning, /* Default. Step icache queues when possible */
291 IcacheNeedsRetry /* Request rejected, will be asked to retry */
292 };
293
294 typedef Queue<FetchRequestPtr,
298
301
304
307
310
319 unsigned int numFetchesInITLB;
320
321 protected:
322 friend std::ostream &operator <<(std::ostream &os,
324
326 void changeStream(const BranchData &branch);
327
331 void updateExpectedSeqNums(const BranchData &branch);
332
334 void processResponse(FetchRequestPtr response,
335 ForwardLineData &line);
336
337 friend std::ostream &operator <<(std::ostream &os,
339
340
344
348 void fetchLine(ThreadID tid);
349
354
358 bool tryToSend(FetchRequestPtr request);
359
362
364 void stepQueues();
365
368 void popAndDiscard(FetchQueue &queue);
369
371 void handleTLBResponse(FetchRequestPtr response);
372
375 unsigned int numInFlightFetches();
376
378 void minorTraceResponseLine(const std::string &name,
379 FetchRequestPtr response) const;
380
382 virtual bool recvTimingResp(PacketPtr pkt);
383 virtual void recvReqRetry();
384
385 public:
386 Fetch1(const std::string &name_,
387 MinorCPU &cpu_,
388 const BaseMinorCPUParams &params,
391 Latch<BranchData>::Output prediction_,
392 std::vector<InputBuffer<ForwardLineData>> &next_stage_input_buffer);
393
394 public:
397
399 void evaluate();
400
402 void wakeupFetch(ThreadID tid);
403
404 void minorTrace() const;
405
408 bool isDrained();
409};
410
411} // namespace minor
412} // namespace gem5
413
414#endif /* __CPU_MINOR_FETCH1_HH__ */
Classes for buffer, queue and FIFO behaviour.
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
Definition cpu.hh:106
MinorCPU & cpu
The enclosing cpu.
Definition cpu.hh:109
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition cpu.hh:112
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition cpu.hh:85
Interface for things with names.
Definition named.hh:39
virtual std::string name() const
Definition named.hh:47
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition pipe_data.hh:66
Memory access queuing.
Definition fetch1.hh:109
InstId id
Identity of the line that this request will generate.
Definition fetch1.hh:129
bool isComplete() const
Is this a complete read line or fault.
Definition fetch1.hh:159
bool isDiscardable() const
Is this line out of date with the current stream/prediction sequence and can it be discarded without ...
Definition fetch1.cc:754
void markDelayed()
BaseMMU::Translation interface.
Definition fetch1.hh:166
void reportData(std::ostream &os) const
Report interface.
Definition fetch1.cc:749
Fetch1 & fetch
Owning fetch unit.
Definition fetch1.hh:112
void finish(const Fault &fault_, const RequestPtr &request_, ThreadContext *tc, BaseMMU::Mode mode)
Interface for ITLB responses.
Definition fetch1.cc:240
Addr pc
PC to fixup with line address.
Definition fetch1.hh:141
void makePacket()
Make a packet to use with the memory transaction.
Definition fetch1.cc:228
Fault fault
Fill in a fault if one happens during fetch, check this by picking apart the response packet.
Definition fetch1.hh:145
RequestPtr request
The underlying request that this fetch represents.
Definition fetch1.hh:138
FetchRequest(Fetch1 &fetch_, InstId id_, Addr pc_)
Definition fetch1.hh:175
FetchRequestState
Progress of this request through address translation and memory.
Definition fetch1.hh:118
PacketPtr packet
FetchRequests carry packets while they're in the requests and transfers responses queues.
Definition fetch1.hh:135
Exposable fetch port.
Definition fetch1.hh:71
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition fetch1.hh:85
IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu)
Definition fetch1.hh:77
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition fetch1.hh:82
Fetch1 & fetch
My owner.
Definition fetch1.hh:74
A stage responsible for fetching "lines" from memory and passing them to Fetch2.
Definition fetch1.hh:67
FetchState
Cycle-by-cycle state.
Definition fetch1.hh:232
ThreadID threadPriority
Definition fetch1.hh:285
unsigned int numFetchesInITLB
Number of requests inside the ITLB rather than in the queues.
Definition fetch1.hh:319
Fetch1(const std::string &name_, MinorCPU &cpu_, const BaseMinorCPUParams &params, Latch< BranchData >::Output inp_, Latch< ForwardLineData >::Input out_, Latch< BranchData >::Output prediction_, std::vector< InputBuffer< ForwardLineData > > &next_stage_input_buffer)
Definition fetch1.cc:60
virtual void recvReqRetry()
Definition fetch1.cc:454
void changeStream(const BranchData &branch)
Start fetching from a new address.
Definition fetch1.cc:489
void minorTraceResponseLine(const std::string &name, FetchRequestPtr response) const
Print the appropriate MinorLine line for a fetch response.
Definition fetch1.cc:398
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
Definition fetch1.hh:396
unsigned int numFetchesInMemorySystem
Count of the number fetches which have left the transfers queue and are in the 'wild' in the memory s...
Definition fetch1.hh:315
Latch< BranchData >::Output inp
Input port carrying branch requests from Execute.
Definition fetch1.hh:200
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to fetch from.
Definition fetch1.cc:123
void tryToSendToTransfers(FetchRequestPtr request)
Try and issue a fetch for a translated request at the head of the requests queue.
Definition fetch1.cc:283
void popAndDiscard(FetchQueue &queue)
Pop a request from the given queue and correctly deallocate and discard it.
Definition fetch1.cc:381
std::vector< Fetch1ThreadInfo > fetchInfo
Definition fetch1.hh:284
IcacheState icacheState
Retry state of icache_port.
Definition fetch1.hh:306
virtual bool recvTimingResp(PacketPtr pkt)
Memory interface.
Definition fetch1.cc:417
IcachePort icachePort
IcachePort to pass to the CPU.
Definition fetch1.hh:211
Addr lineSnap
Line snap size in bytes.
Definition fetch1.hh:216
std::vector< InputBuffer< ForwardLineData > > & nextStageReserve
Interface to reserve space in the next stage.
Definition fetch1.hh:207
Addr maxLineWidth
Maximum fetch width in bytes.
Definition fetch1.hh:222
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
Definition fetch1.cc:717
friend std::ostream & operator<<(std::ostream &os, Fetch1::FetchState state)
Definition fetch1.cc:469
bool tryToSend(FetchRequestPtr request)
Try to send (or resend) a memory request's next/only packet to the memory system.
Definition fetch1.cc:331
void handleTLBResponse(FetchRequestPtr response)
Handle pushing a TLB response onto the right queue.
Definition fetch1.cc:253
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
Definition fetch1.cc:731
Latch< BranchData >::Output prediction
Input port carrying branch predictions from Fetch2.
Definition fetch1.hh:204
void evaluate()
Pass on input/buffer data to the output if you can.
Definition fetch1.cc:576
void minorTrace() const
Definition fetch1.cc:765
unsigned int fetchLimit
Maximum number of fetches allowed in flight (in queues or memory)
Definition fetch1.hh:225
void processResponse(FetchRequestPtr response, ForwardLineData &line)
Convert a response to a ForwardLineData.
Definition fetch1.cc:540
unsigned int numInFlightFetches()
Returns the total number of queue occupancy, in-ITLB and in-memory system fetches.
Definition fetch1.cc:390
MinorCPU & cpu
Construction-assigned data members.
Definition fetch1.hh:197
Queue< FetchRequestPtr, ReportTraitsPtrAdaptor< FetchRequestPtr >, NoBubbleTraits< FetchRequestPtr > > FetchQueue
Definition fetch1.hh:297
FetchQueue transfers
Queue of in-memory system requests and responses.
Definition fetch1.hh:303
void stepQueues()
Step requests along between requests and transfers queues.
Definition fetch1.cc:359
void updateExpectedSeqNums(const BranchData &branch)
Update streamSeqNum and predictionSeqNum from the given branch (and assume these have changed and dis...
Definition fetch1.cc:522
FetchRequest * FetchRequestPtr
Definition fetch1.hh:191
InstSeqNum lineSeqNum
Sequence number for line fetch used for ordering lines to flush.
Definition fetch1.hh:309
void fetchLine(ThreadID tid)
Insert a line fetch into the requests.
Definition fetch1.cc:155
Latch< ForwardLineData >::Input out
Output port carrying read lines to Fetch2.
Definition fetch1.hh:202
FetchQueue requests
Queue of address translated requests from Fetch1.
Definition fetch1.hh:300
void moveFromRequestsToTransfers(FetchRequestPtr request)
Move a request between queues.
Definition fetch1.cc:322
IcacheState
State of memory access for head instruction fetch.
Definition fetch1.hh:289
Line fetch data in the forward direction.
Definition pipe_data.hh:187
Like a Queue but with a restricted interface and a setTail function which, when the queue is empty,...
Definition buffers.hh:572
Id for lines and instructions.
Definition dyn_inst.hh:76
static const InstSeqNum firstStreamSeqNum
First sequence numbers to use in initialisation of the pipeline and to be expected on the first line/...
Definition dyn_inst.hh:80
static const InstSeqNum firstPredictionSeqNum
Definition dyn_inst.hh:81
Encapsulate wires on either input or output of the latch.
Definition buffers.hh:252
... BubbleTraits are trait classes to add BubbleIF interface functionality to templates which process...
Definition buffers.hh:122
Wrapper for a queue type to act as a pipeline stage input queue.
Definition buffers.hh:404
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
Definition buffers.hh:108
STL vector class.
Definition stl.hh:37
Top level definition of the Minor in-order CPU model.
atomic_var_t state
Definition helpers.cc:211
Bitfield< 4, 0 > mode
Definition misc_types.hh:74
Bitfield< 17 > os
Definition misc.hh:838
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
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
constexpr decltype(nullptr) NoFault
Definition types.hh:253
uint64_t InstSeqNum
Definition inst_seq.hh:40
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Declaration of the Packet class.
Contains class definitions for data flowing between pipeline stages in the top-level structure portio...
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469
Stage cycle-by-cycle state.
Definition fetch1.hh:244
std::unique_ptr< PCStateBase > pc
Fetch PC value.
Definition fetch1.hh:261
Fetch1ThreadInfo(const Fetch1ThreadInfo &other)
Definition fetch1.hh:248
InstSeqNum streamSeqNum
Stream sequence number.
Definition fetch1.hh:269
InstSeqNum predictionSeqNum
Prediction sequence number.
Definition fetch1.hh:275
bool blocked
Blocked indication for report.
Definition fetch1.hh:278
bool wakeupGuard
Signal to guard against sleeping first cycle of wakeup.
Definition fetch1.hh:281
Addr fetchAddr
The address we're currently fetching lines from.
Definition fetch1.hh:264

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0