gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  * Authors: Andrew Bardsley
38  */
39 
47 #ifndef __CPU_MINOR_FETCH1_HH__
48 #define __CPU_MINOR_FETCH1_HH__
49 
50 #include "cpu/minor/buffers.hh"
51 #include "cpu/minor/cpu.hh"
52 #include "cpu/minor/pipe_data.hh"
53 #include "cpu/base.hh"
54 #include "mem/packet.hh"
55 
56 namespace Minor
57 {
58 
61 class Fetch1 : public Named
62 {
63  protected:
66  {
67  protected:
70 
71  public:
72  IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu) :
73  MinorCPU::MinorCPUPort(name, cpu), fetch(fetch_)
74  { }
75 
76  protected:
78  { return fetch.recvTimingResp(pkt); }
79 
80  void recvReqRetry() { fetch.recvReqRetry(); }
81  };
82 
101  class FetchRequest :
102  public BaseTLB::Translation, /* For TLB lookups */
103  public Packet::SenderState /* For packing into a Packet */
104  {
105  protected:
108 
109  public:
113  {
114  NotIssued, /* Just been made */
115  InTranslation, /* Issued to ITLB, must wait for reqply */
116  Translated, /* Translation complete */
117  RequestIssuing, /* Issued to memory, must wait for response */
118  Complete /* Complete. Either a fault, or a fetched line */
119  };
120 
122 
125 
131 
134 
137 
141 
143  void makePacket();
144 
146  void reportData(std::ostream &os) const;
147 
151  bool isDiscardable() const;
152 
154  bool isComplete() const { return state == Complete; }
155 
156  protected:
161  void markDelayed() { }
162 
166  void finish(const Fault &fault_, const RequestPtr &request_,
168 
169  public:
171  SenderState(),
172  fetch(fetch_),
173  state(NotIssued),
174  id(id_),
175  packet(NULL),
176  request(),
177  pc(pc_),
178  fault(NoFault)
179  {
180  request = std::make_shared<Request>();
181  }
182 
183  ~FetchRequest();
184  };
185 
187 
188  protected:
193 
200 
203 
207 
211  unsigned int lineSnap;
212 
217  unsigned int maxLineWidth;
218 
220  unsigned int fetchLimit;
221 
222  protected:
227  {
228  FetchHalted, /* Not fetching, waiting to be woken by transition
229  to FetchWaitingForPC. The PC is not valid in this state */
230  FetchWaitingForPC, /* Not fetching, waiting for stream change.
231  This doesn't stop issued fetches from being returned and
232  processed or for branches to change the state to Running. */
233  FetchRunning /* Try to fetch, when possible */
234  };
235 
239 
242  state(FetchWaitingForPC),
243  pc(TheISA::PCState(0)),
244  streamSeqNum(InstId::firstStreamSeqNum),
245  predictionSeqNum(InstId::firstPredictionSeqNum),
246  blocked(false),
247  wakeupGuard(false)
248  { }
249 
251  state(other.state),
252  pc(other.pc),
253  streamSeqNum(other.streamSeqNum),
254  predictionSeqNum(other.predictionSeqNum),
255  blocked(other.blocked)
256  { }
257 
259 
264 
269 
275 
277  bool blocked;
278 
281  };
282 
285 
288  {
289  IcacheRunning, /* Default. Step icache queues when possible */
290  IcacheNeedsRetry /* Request rejected, will be asked to retry */
291  };
292 
293  typedef Queue<FetchRequestPtr,
297 
300 
303 
306 
309 
318  unsigned int numFetchesInITLB;
319 
320  protected:
321  friend std::ostream &operator <<(std::ostream &os,
322  Fetch1::FetchState state);
323 
325  void changeStream(const BranchData &branch);
326 
330  void updateExpectedSeqNums(const BranchData &branch);
331 
333  void processResponse(FetchRequestPtr response,
334  ForwardLineData &line);
335 
336  friend std::ostream &operator <<(std::ostream &os,
337  IcacheState state);
338 
339 
343 
347  void fetchLine(ThreadID tid);
348 
352  void tryToSendToTransfers(FetchRequestPtr request);
353 
357  bool tryToSend(FetchRequestPtr request);
358 
360  void moveFromRequestsToTransfers(FetchRequestPtr request);
361 
363  void stepQueues();
364 
367  void popAndDiscard(FetchQueue &queue);
368 
370  void handleTLBResponse(FetchRequestPtr response);
371 
374  unsigned int numInFlightFetches();
375 
377  void minorTraceResponseLine(const std::string &name,
378  FetchRequestPtr response) const;
379 
381  virtual bool recvTimingResp(PacketPtr pkt);
382  virtual void recvReqRetry();
383 
384  public:
385  Fetch1(const std::string &name_,
386  MinorCPU &cpu_,
387  MinorCPUParams &params,
390  Latch<BranchData>::Output prediction_,
391  std::vector<InputBuffer<ForwardLineData>> &next_stage_input_buffer);
392 
393  public:
396 
398  void evaluate();
399 
401  void wakeupFetch(ThreadID tid);
402 
403  void minorTrace() const;
404 
407  bool isDrained();
408 };
409 
410 }
411 
412 #endif /* __CPU_MINOR_FETCH1_HH__ */
ThreadID threadPriority
Definition: fetch1.hh:284
Exposable fetch port.
Definition: fetch1.hh:65
void processResponse(FetchRequestPtr response, ForwardLineData &line)
Convert a response to a ForwardLineData.
Definition: fetch1.cc:539
std::vector< Fetch1ThreadInfo > fetchInfo
Definition: fetch1.hh:283
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:104
IcacheState
State of memory access for head instruction fetch.
Definition: fetch1.hh:287
InstSeqNum predictionSeqNum
Prediction sequence number.
Definition: fetch1.hh:274
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
Contains class definitions for data flowing between pipeline stages in the top-level structure portio...
void fetchLine(ThreadID tid)
Insert a line fetch into the requests.
Definition: fetch1.cc:148
Like a Queue but with a restricted interface and a setTail function which, when the queue is empty...
Definition: buffers.hh:567
void stepQueues()
Step requests along between requests and transfers queues.
Definition: fetch1.cc:359
Memory access queuing.
Definition: fetch1.hh:101
bool tryToSend(FetchRequestPtr request)
Try to send (or resend) a memory request&#39;s next/only packet to the memory system. ...
Definition: fetch1.cc:331
FetchRequestState
Progress of this request through address translation and memory.
Definition: fetch1.hh:112
Queue< FetchRequestPtr, ReportTraitsPtrAdaptor< FetchRequestPtr >, NoBubbleTraits< FetchRequestPtr > > FetchQueue
Definition: fetch1.hh:296
std::vector< InputBuffer< ForwardLineData > > & nextStageReserve
Interface to reserve space in the next stage.
Definition: fetch1.hh:202
unsigned int lineSnap
Line snap size in bytes.
Definition: fetch1.hh:211
unsigned int numFetchesInMemorySystem
Count of the number fetches which have left the transfers queue and are in the &#39;wild&#39; in the memory s...
Definition: fetch1.hh:314
InstId id
Identity of the line that this request will generate.
Definition: fetch1.hh:124
std::shared_ptr< Request > RequestPtr
Definition: request.hh:83
void popAndDiscard(FetchQueue &queue)
Pop a request from the given queue and correctly deallocate and discard it.
Definition: fetch1.cc:381
void changeStream(const BranchData &branch)
Start fetching from a new address.
Definition: fetch1.cc:489
void updateExpectedSeqNums(const BranchData &branch)
Update streamSeqNum and predictionSeqNum from the given branch (and assume these have changed and dis...
Definition: fetch1.cc:521
Line fetch data in the forward direction.
Definition: pipe_data.hh:173
Stage cycle-by-cycle state.
Definition: fetch1.hh:238
IcacheState icacheState
Retry state of icache_port.
Definition: fetch1.hh:305
TheISA::PCState pc
PC to fixup with line address.
Definition: fetch1.hh:136
Fetch1ThreadInfo(const Fetch1ThreadInfo &other)
Definition: fetch1.hh:250
Id for lines and instructions.
Definition: dyn_inst.hh:70
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:107
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Definition: activity.cc:46
Fetch1(const std::string &name_, MinorCPU &cpu_, MinorCPUParams &params, Latch< BranchData >::Output inp_, Latch< ForwardLineData >::Input out_, Latch< BranchData >::Output prediction_, std::vector< InputBuffer< ForwardLineData >> &next_stage_input_buffer)
Definition: fetch1.cc:55
Latch< BranchData >::Output inp
Input port carrying branch requests from Execute.
Definition: fetch1.hh:195
Bitfield< 4, 0 > mode
Fetch1 & fetch
My owner.
Definition: fetch1.hh:69
Wrapper for a queue type to act as a pipeline stage input queue.
Definition: buffers.hh:399
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 17 > os
Definition: misc.hh:805
STL vector class.
Definition: stl.hh:40
void handleTLBResponse(FetchRequestPtr response)
Handle pushing a TLB response onto the right queue.
Definition: fetch1.cc:253
MinorCPU & cpu
Construction-assigned data members.
Definition: fetch1.hh:192
Provide a non-protected base class for Minor&#39;s Ports as derived classes are created by Fetch1 and Exe...
Definition: cpu.hh:100
bool blocked
Blocked indication for report.
Definition: fetch1.hh:277
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: fetch1.hh:77
Definition: trace.hh:151
void markDelayed()
BaseTLB::Translation interface.
Definition: fetch1.hh:161
Bitfield< 4 > pc
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
Definition: buffers.hh:103
void minorTraceResponseLine(const std::string &name, FetchRequestPtr response) const
Print the appropriate MinorLine line for a fetch response.
Definition: fetch1.cc:398
FetchRequest(Fetch1 &fetch_, InstId id_, TheISA::PCState pc_)
Definition: fetch1.hh:170
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
Definition: fetch1.hh:395
FetchRequest * FetchRequestPtr
Definition: fetch1.hh:186
bool wakeupGuard
Signal to guard against sleeping first cycle of wakeup.
Definition: fetch1.hh:280
Latch< BranchData >::Output prediction
Input port carrying branch predictions from Fetch2.
Definition: fetch1.hh:199
FetchQueue requests
Queue of address translated requests from Fetch1.
Definition: fetch1.hh:299
void moveFromRequestsToTransfers(FetchRequestPtr request)
Move a request between queues.
Definition: fetch1.cc:322
uint64_t InstSeqNum
Definition: inst_seq.hh:40
Latch< ForwardLineData >::Input out
Output port carrying read lines to Fetch2.
Definition: fetch1.hh:197
Classes for buffer, queue and FIFO behaviour.
unsigned int numFetchesInITLB
Number of requests inside the ITLB rather than in the queues.
Definition: fetch1.hh:318
unsigned int numInFlightFetches()
Returns the total number of queue occupancy, in-ITLB and in-memory system fetches.
Definition: fetch1.cc:390
A stage responsible for fetching "lines" from memory and passing them to Fetch2.
Definition: fetch1.hh:61
InstSeqNum streamSeqNum
Stream sequence number.
Definition: fetch1.hh:268
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
FetchState
Cycle-by-cycle state.
Definition: fetch1.hh:226
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
Definition: packet.hh:403
Fault fault
Fill in a fault if one happens during fetch, check this by picking apart the response packet...
Definition: fetch1.hh:140
unsigned int maxLineWidth
Maximum fetch width in bytes.
Definition: fetch1.hh:217
FetchRequestState state
Definition: fetch1.hh:121
Mode
Definition: tlb.hh:59
friend std::ostream & operator<<(std::ostream &os, Fetch1::FetchState state)
Definition: fetch1.cc:469
RequestPtr request
The underlying request that this fetch represents.
Definition: fetch1.hh:133
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:64
Fetch1ThreadInfo()
Consturctor to initialize all fields.
Definition: fetch1.hh:241
Declaration of the Packet class.
TheISA::PCState pc
Fetch PC value.
Definition: fetch1.hh:263
bool isComplete() const
Is this a complete read line or fault.
Definition: fetch1.hh:154
virtual bool recvTimingResp(PacketPtr pkt)
Memory interface.
Definition: fetch1.cc:417
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: fetch1.hh:80
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
Top level definition of the Minor in-order CPU model.
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu)
Definition: fetch1.hh:72
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
Definition: fetch1.cc:714
void tryToSendToTransfers(FetchRequestPtr request)
Try and issue a fetch for a translated request at the head of the requests queue. ...
Definition: fetch1.cc:283
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
Definition: fetch1.cc:728
InstSeqNum lineSeqNum
Sequence number for line fetch used for ordering lines to flush.
Definition: fetch1.hh:308
PacketPtr packet
FetchRequests carry packets while they&#39;re in the requests and transfers responses queues...
Definition: fetch1.hh:130
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:79
void evaluate()
Pass on input/buffer data to the output if you can.
Definition: fetch1.cc:573
Encapsulate wires on either input or output of the latch.
Definition: buffers.hh:247
FetchQueue transfers
Queue of in-memory system requests and responses.
Definition: fetch1.hh:302
void minorTrace() const
Definition: fetch1.cc:762
IcachePort icachePort
IcachePort to pass to the CPU.
Definition: fetch1.hh:206
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
unsigned int fetchLimit
Maximum number of fetches allowed in flight (in queues or memory)
Definition: fetch1.hh:220
Fetch1 & fetch
Owning fetch unit.
Definition: fetch1.hh:107
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to fetch from.
Definition: fetch1.cc:116
virtual void recvReqRetry()
Definition: fetch1.cc:454

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13