gem5  v22.1.0.0
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"
55 #include "cpu/minor/pipe_data.hh"
56 #include "mem/packet.hh"
57 
58 namespace gem5
59 {
60 
62 namespace minor
63 {
64 
67 class Fetch1 : public Named
68 {
69  protected:
72  {
73  protected:
76 
77  public:
78  IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu) :
79  MinorCPU::MinorCPUPort(name, cpu), fetch(fetch_)
80  { }
81 
82  protected:
84  { return fetch.recvTimingResp(pkt); }
85 
87  };
88 
107  class FetchRequest :
108  public BaseMMU::Translation, /* For TLB lookups */
109  public Packet::SenderState /* For packing into a Packet */
110  {
111  protected:
114 
115  public:
119  {
120  NotIssued, /* Just been made */
121  InTranslation, /* Issued to ITLB, must wait for reqply */
122  Translated, /* Translation complete */
123  RequestIssuing, /* Issued to memory, must wait for response */
124  Complete /* Complete. Either a fault, or a fetched line */
125  };
126 
128 
131 
137 
140 
143 
147 
149  void makePacket();
150 
152  void reportData(std::ostream &os) const;
153 
157  bool isDiscardable() const;
158 
160  bool isComplete() const { return state == Complete; }
161 
162  protected:
167  void markDelayed() { }
168 
172  void finish(const Fault &fault_, const RequestPtr &request_,
174 
175  public:
176  FetchRequest(Fetch1 &fetch_, InstId id_, Addr pc_) :
177  SenderState(),
178  fetch(fetch_),
179  state(NotIssued),
180  id(id_),
181  packet(NULL),
182  request(),
183  pc(pc_),
184  fault(NoFault)
185  {
186  request = std::make_shared<Request>();
187  }
188 
189  ~FetchRequest();
190  };
191 
193 
194  protected:
199 
206 
209 
213 
217  unsigned int lineSnap;
218 
223  unsigned int maxLineWidth;
224 
226  unsigned int fetchLimit;
227 
228  protected:
233  {
234  FetchHalted, /* Not fetching, waiting to be woken by transition
235  to FetchWaitingForPC. The PC is not valid in this state */
236  FetchWaitingForPC, /* Not fetching, waiting for stream change.
237  This doesn't stop issued fetches from being returned and
238  processed or for branches to change the state to Running. */
239  FetchRunning /* Try to fetch, when possible */
240  };
241 
245  {
246  // All fields have default initializers.
248 
250  state(other.state),
251  pc(other.pc->clone()),
252  streamSeqNum(other.streamSeqNum),
254  blocked(other.blocked)
255  { }
256 
258 
262  std::unique_ptr<PCStateBase> pc;
263 
266 
271 
277 
279  bool blocked = false;
280 
282  bool wakeupGuard = false;
283  };
284 
287 
290  {
291  IcacheRunning, /* Default. Step icache queues when possible */
292  IcacheNeedsRetry /* Request rejected, will be asked to retry */
293  };
294 
295  typedef Queue<FetchRequestPtr,
299 
302 
305 
308 
311 
320  unsigned int numFetchesInITLB;
321 
322  protected:
323  friend std::ostream &operator <<(std::ostream &os,
325 
327  void changeStream(const BranchData &branch);
328 
332  void updateExpectedSeqNums(const BranchData &branch);
333 
335  void processResponse(FetchRequestPtr response,
336  ForwardLineData &line);
337 
338  friend std::ostream &operator <<(std::ostream &os,
340 
341 
345 
349  void fetchLine(ThreadID tid);
350 
355 
359  bool tryToSend(FetchRequestPtr request);
360 
363 
365  void stepQueues();
366 
369  void popAndDiscard(FetchQueue &queue);
370 
372  void handleTLBResponse(FetchRequestPtr response);
373 
376  unsigned int numInFlightFetches();
377 
379  void minorTraceResponseLine(const std::string &name,
380  FetchRequestPtr response) const;
381 
383  virtual bool recvTimingResp(PacketPtr pkt);
384  virtual void recvReqRetry();
385 
386  public:
387  Fetch1(const std::string &name_,
388  MinorCPU &cpu_,
389  const BaseMinorCPUParams &params,
392  Latch<BranchData>::Output prediction_,
393  std::vector<InputBuffer<ForwardLineData>> &next_stage_input_buffer);
394 
395  public:
398 
400  void evaluate();
401 
403  void wakeupFetch(ThreadID tid);
404 
405  void minorTrace() const;
406 
409  bool isDrained();
410 };
411 
412 } // namespace minor
413 } // namespace gem5
414 
415 #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:107
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:110
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:113
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:86
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:294
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
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:67
Memory access queuing.
Definition: fetch1.hh:110
InstId id
Identity of the line that this request will generate.
Definition: fetch1.hh:130
bool isComplete() const
Is this a complete read line or fault.
Definition: fetch1.hh:160
bool isDiscardable() const
Is this line out of date with the current stream/prediction sequence and can it be discarded without ...
Definition: fetch1.cc:755
void markDelayed()
BaseMMU::Translation interface.
Definition: fetch1.hh:167
void reportData(std::ostream &os) const
Report interface.
Definition: fetch1.cc:750
Fetch1 & fetch
Owning fetch unit.
Definition: fetch1.hh:113
void finish(const Fault &fault_, const RequestPtr &request_, ThreadContext *tc, BaseMMU::Mode mode)
Interface for ITLB responses.
Definition: fetch1.cc:241
Addr pc
PC to fixup with line address.
Definition: fetch1.hh:142
void makePacket()
Make a packet to use with the memory transaction.
Definition: fetch1.cc:229
Fault fault
Fill in a fault if one happens during fetch, check this by picking apart the response packet.
Definition: fetch1.hh:146
RequestPtr request
The underlying request that this fetch represents.
Definition: fetch1.hh:139
FetchRequest(Fetch1 &fetch_, InstId id_, Addr pc_)
Definition: fetch1.hh:176
FetchRequestState
Progress of this request through address translation and memory.
Definition: fetch1.hh:119
PacketPtr packet
FetchRequests carry packets while they're in the requests and transfers responses queues.
Definition: fetch1.hh:136
Exposable fetch port.
Definition: fetch1.hh:72
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: fetch1.hh:86
IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu)
Definition: fetch1.hh:78
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: fetch1.hh:83
Fetch1 & fetch
My owner.
Definition: fetch1.hh:75
A stage responsible for fetching "lines" from memory and passing them to Fetch2.
Definition: fetch1.hh:68
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
Definition: fetch1.hh:397
FetchState
Cycle-by-cycle state.
Definition: fetch1.hh:233
ThreadID threadPriority
Definition: fetch1.hh:286
unsigned int numFetchesInITLB
Number of requests inside the ITLB rather than in the queues.
Definition: fetch1.hh:320
virtual void recvReqRetry()
Definition: fetch1.cc:455
void changeStream(const BranchData &branch)
Start fetching from a new address.
Definition: fetch1.cc:490
void minorTraceResponseLine(const std::string &name, FetchRequestPtr response) const
Print the appropriate MinorLine line for a fetch response.
Definition: fetch1.cc:399
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:316
Latch< BranchData >::Output inp
Input port carrying branch requests from Execute.
Definition: fetch1.hh:201
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to fetch from.
Definition: fetch1.cc:124
void tryToSendToTransfers(FetchRequestPtr request)
Try and issue a fetch for a translated request at the head of the requests queue.
Definition: fetch1.cc:284
void popAndDiscard(FetchQueue &queue)
Pop a request from the given queue and correctly deallocate and discard it.
Definition: fetch1.cc:382
std::vector< Fetch1ThreadInfo > fetchInfo
Definition: fetch1.hh:285
IcacheState icacheState
Retry state of icache_port.
Definition: fetch1.hh:307
virtual bool recvTimingResp(PacketPtr pkt)
Memory interface.
Definition: fetch1.cc:418
IcachePort icachePort
IcachePort to pass to the CPU.
Definition: fetch1.hh:212
unsigned int maxLineWidth
Maximum fetch width in bytes.
Definition: fetch1.hh:223
std::vector< InputBuffer< ForwardLineData > > & nextStageReserve
Interface to reserve space in the next stage.
Definition: fetch1.hh:208
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
Definition: fetch1.cc:718
bool tryToSend(FetchRequestPtr request)
Try to send (or resend) a memory request's next/only packet to the memory system.
Definition: fetch1.cc:332
void handleTLBResponse(FetchRequestPtr response)
Handle pushing a TLB response onto the right queue.
Definition: fetch1.cc:254
unsigned int lineSnap
Line snap size in bytes.
Definition: fetch1.hh:217
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
Definition: fetch1.cc:732
Latch< BranchData >::Output prediction
Input port carrying branch predictions from Fetch2.
Definition: fetch1.hh:205
void evaluate()
Pass on input/buffer data to the output if you can.
Definition: fetch1.cc:577
void minorTrace() const
Definition: fetch1.cc:766
unsigned int fetchLimit
Maximum number of fetches allowed in flight (in queues or memory)
Definition: fetch1.hh:226
void processResponse(FetchRequestPtr response, ForwardLineData &line)
Convert a response to a ForwardLineData.
Definition: fetch1.cc:541
unsigned int numInFlightFetches()
Returns the total number of queue occupancy, in-ITLB and in-memory system fetches.
Definition: fetch1.cc:391
MinorCPU & cpu
Construction-assigned data members.
Definition: fetch1.hh:198
Queue< FetchRequestPtr, ReportTraitsPtrAdaptor< FetchRequestPtr >, NoBubbleTraits< FetchRequestPtr > > FetchQueue
Definition: fetch1.hh:298
FetchQueue transfers
Queue of in-memory system requests and responses.
Definition: fetch1.hh:304
void stepQueues()
Step requests along between requests and transfers queues.
Definition: fetch1.cc:360
friend std::ostream & operator<<(std::ostream &os, Fetch1::FetchState state)
Definition: fetch1.cc:470
void updateExpectedSeqNums(const BranchData &branch)
Update streamSeqNum and predictionSeqNum from the given branch (and assume these have changed and dis...
Definition: fetch1.cc:523
FetchRequest * FetchRequestPtr
Definition: fetch1.hh:192
InstSeqNum lineSeqNum
Sequence number for line fetch used for ordering lines to flush.
Definition: fetch1.hh:310
void fetchLine(ThreadID tid)
Insert a line fetch into the requests.
Definition: fetch1.cc:156
Latch< ForwardLineData >::Input out
Output port carrying read lines to Fetch2.
Definition: fetch1.hh:203
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:61
FetchQueue requests
Queue of address translated requests from Fetch1.
Definition: fetch1.hh:301
void moveFromRequestsToTransfers(FetchRequestPtr request)
Move a request between queues.
Definition: fetch1.cc:323
IcacheState
State of memory access for head instruction fetch.
Definition: fetch1.hh:290
Line fetch data in the forward direction.
Definition: pipe_data.hh:188
Like a Queue but with a restricted interface and a setTail function which, when the queue is empty,...
Definition: buffers.hh:573
Id for lines and instructions.
Definition: dyn_inst.hh:77
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:81
static const InstSeqNum firstPredictionSeqNum
Definition: dyn_inst.hh:82
Encapsulate wires on either input or output of the latch.
Definition: buffers.hh:253
Wrapper for a queue type to act as a pipeline stage input queue.
Definition: buffers.hh:405
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
Definition: buffers.hh:109
STL vector class.
Definition: stl.hh:37
Top level definition of the Minor in-order CPU model.
atomic_var_t state
Definition: helpers.cc:188
Bitfield< 4, 0 > mode
Definition: misc_types.hh:74
Bitfield< 17 > os
Definition: misc.hh:810
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
std::shared_ptr< Request > RequestPtr
Definition: request.hh:92
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
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
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:468
Stage cycle-by-cycle state.
Definition: fetch1.hh:245
std::unique_ptr< PCStateBase > pc
Fetch PC value.
Definition: fetch1.hh:262
Fetch1ThreadInfo(const Fetch1ThreadInfo &other)
Definition: fetch1.hh:249
InstSeqNum streamSeqNum
Stream sequence number.
Definition: fetch1.hh:270
InstSeqNum predictionSeqNum
Prediction sequence number.
Definition: fetch1.hh:276
bool blocked
Blocked indication for report.
Definition: fetch1.hh:279
bool wakeupGuard
Signal to guard against sleeping first cycle of wakeup.
Definition: fetch1.hh:282
Addr fetchAddr
The address we're currently fetching lines from.
Definition: fetch1.hh:265

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