gem5  v20.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 "cpu/minor/buffers.hh"
49 #include "cpu/minor/cpu.hh"
50 #include "cpu/minor/pipe_data.hh"
51 #include "cpu/base.hh"
52 #include "mem/packet.hh"
53 
54 namespace Minor
55 {
56 
59 class Fetch1 : public Named
60 {
61  protected:
64  {
65  protected:
68 
69  public:
70  IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu) :
71  MinorCPU::MinorCPUPort(name, cpu), fetch(fetch_)
72  { }
73 
74  protected:
76  { return fetch.recvTimingResp(pkt); }
77 
79  };
80 
99  class FetchRequest :
100  public BaseTLB::Translation, /* For TLB lookups */
101  public Packet::SenderState /* For packing into a Packet */
102  {
103  protected:
106 
107  public:
111  {
112  NotIssued, /* Just been made */
113  InTranslation, /* Issued to ITLB, must wait for reqply */
114  Translated, /* Translation complete */
115  RequestIssuing, /* Issued to memory, must wait for response */
116  Complete /* Complete. Either a fault, or a fetched line */
117  };
118 
120 
123 
129 
132 
135 
139 
141  void makePacket();
142 
144  void reportData(std::ostream &os) const;
145 
149  bool isDiscardable() const;
150 
152  bool isComplete() const { return state == Complete; }
153 
154  protected:
159  void markDelayed() { }
160 
164  void finish(const Fault &fault_, const RequestPtr &request_,
166 
167  public:
169  SenderState(),
170  fetch(fetch_),
171  state(NotIssued),
172  id(id_),
173  packet(NULL),
174  request(),
175  pc(pc_),
176  fault(NoFault)
177  {
178  request = std::make_shared<Request>();
179  }
180 
181  ~FetchRequest();
182  };
183 
185 
186  protected:
191 
198 
201 
205 
209  unsigned int lineSnap;
210 
215  unsigned int maxLineWidth;
216 
218  unsigned int fetchLimit;
219 
220  protected:
225  {
226  FetchHalted, /* Not fetching, waiting to be woken by transition
227  to FetchWaitingForPC. The PC is not valid in this state */
228  FetchWaitingForPC, /* Not fetching, waiting for stream change.
229  This doesn't stop issued fetches from being returned and
230  processed or for branches to change the state to Running. */
231  FetchRunning /* Try to fetch, when possible */
232  };
233 
237 
241  pc(TheISA::PCState(0)),
242  streamSeqNum(InstId::firstStreamSeqNum),
243  predictionSeqNum(InstId::firstPredictionSeqNum),
244  blocked(false),
245  wakeupGuard(false)
246  { }
247 
249  state(other.state),
250  pc(other.pc),
251  streamSeqNum(other.streamSeqNum),
253  blocked(other.blocked)
254  { }
255 
257 
262 
267 
273 
275  bool blocked;
276 
279  };
280 
283 
286  {
287  IcacheRunning, /* Default. Step icache queues when possible */
288  IcacheNeedsRetry /* Request rejected, will be asked to retry */
289  };
290 
291  typedef Queue<FetchRequestPtr,
295 
298 
301 
304 
307 
316  unsigned int numFetchesInITLB;
317 
318  protected:
319  friend std::ostream &operator <<(std::ostream &os,
320  Fetch1::FetchState state);
321 
323  void changeStream(const BranchData &branch);
324 
328  void updateExpectedSeqNums(const BranchData &branch);
329 
331  void processResponse(FetchRequestPtr response,
332  ForwardLineData &line);
333 
334  friend std::ostream &operator <<(std::ostream &os,
335  IcacheState state);
336 
337 
341 
345  void fetchLine(ThreadID tid);
346 
351 
355  bool tryToSend(FetchRequestPtr request);
356 
359 
361  void stepQueues();
362 
365  void popAndDiscard(FetchQueue &queue);
366 
368  void handleTLBResponse(FetchRequestPtr response);
369 
372  unsigned int numInFlightFetches();
373 
375  void minorTraceResponseLine(const std::string &name,
376  FetchRequestPtr response) const;
377 
379  virtual bool recvTimingResp(PacketPtr pkt);
380  virtual void recvReqRetry();
381 
382  public:
383  Fetch1(const std::string &name_,
384  MinorCPU &cpu_,
385  MinorCPUParams &params,
388  Latch<BranchData>::Output prediction_,
389  std::vector<InputBuffer<ForwardLineData>> &next_stage_input_buffer);
390 
391  public:
394 
396  void evaluate();
397 
399  void wakeupFetch(ThreadID tid);
400 
401  void minorTrace() const;
402 
405  bool isDrained();
406 };
407 
408 }
409 
410 #endif /* __CPU_MINOR_FETCH1_HH__ */
pipe_data.hh
X86ISA::os
Bitfield< 17 > os
Definition: misc.hh:803
Minor::Fetch1::icachePort
IcachePort icachePort
IcachePort to pass to the CPU.
Definition: fetch1.hh:204
MinorCPU::MinorCPUPort::cpu
MinorCPU & cpu
The enclosing cpu.
Definition: cpu.hh:102
Minor::Fetch1::nextStageReserve
std::vector< InputBuffer< ForwardLineData > > & nextStageReserve
Interface to reserve space in the next stage.
Definition: fetch1.hh:200
Minor::Fetch1::FetchRequest::NotIssued
@ NotIssued
Definition: fetch1.hh:112
Minor::Fetch1::evaluate
void evaluate()
Pass on input/buffer data to the output if you can.
Definition: fetch1.cc:563
ThreadID
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
Minor::Fetch1::icacheState
IcacheState icacheState
Retry state of icache_port.
Definition: fetch1.hh:303
Minor::Latch::Input
Encapsulate wires on either input or output of the latch.
Definition: buffers.hh:245
Minor::Fetch1::requests
FetchQueue requests
Queue of address translated requests from Fetch1.
Definition: fetch1.hh:297
Minor::Fetch1::FetchRequest::fault
Fault fault
Fill in a fault if one happens during fetch, check this by picking apart the response packet.
Definition: fetch1.hh:138
TheISA
Definition: decode_cache.hh:37
Minor::ForwardLineData
Line fetch data in the forward direction.
Definition: pipe_data.hh:171
Minor::Fetch1::IcachePort::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: fetch1.hh:75
Minor::Fetch1::Fetch1ThreadInfo::predictionSeqNum
InstSeqNum predictionSeqNum
Prediction sequence number.
Definition: fetch1.hh:272
BaseTLB::Mode
Mode
Definition: tlb.hh:57
Minor::Fetch1::Fetch1ThreadInfo::streamSeqNum
InstSeqNum streamSeqNum
Stream sequence number.
Definition: fetch1.hh:266
Minor::Fetch1::handleTLBResponse
void handleTLBResponse(FetchRequestPtr response)
Handle pushing a TLB response onto the right queue.
Definition: fetch1.cc:243
Minor::Fetch1::recvReqRetry
virtual void recvReqRetry()
Definition: fetch1.cc:444
cpu.hh
Minor::Fetch1::cpu
MinorCPU & cpu
Construction-assigned data members.
Definition: fetch1.hh:190
Minor::Fetch1::FetchRequest::isComplete
bool isComplete() const
Is this a complete read line or fault.
Definition: fetch1.hh:152
Minor::Fetch1::processResponse
void processResponse(FetchRequestPtr response, ForwardLineData &line)
Convert a response to a ForwardLineData.
Definition: fetch1.cc:529
RequestPtr
std::shared_ptr< Request > RequestPtr
Definition: request.hh:82
Minor::Fetch1::numFetchesInITLB
unsigned int numFetchesInITLB
Number of requests inside the ITLB rather than in the queues.
Definition: fetch1.hh:316
std::vector
STL vector class.
Definition: stl.hh:37
Minor::Fetch1::FetchRequest::fetch
Fetch1 & fetch
Owning fetch unit.
Definition: fetch1.hh:105
Minor::Fetch1::FetchState
FetchState
Cycle-by-cycle state.
Definition: fetch1.hh:224
Minor::Fetch1::prediction
Latch< BranchData >::Output prediction
Input port carrying branch predictions from Fetch2.
Definition: fetch1.hh:197
Minor::ReportTraitsPtrAdaptor
A similar adaptor but for elements held by pointer ElemType should implement ReportIF.
Definition: buffers.hh:101
Minor::Fetch1::popAndDiscard
void popAndDiscard(FetchQueue &queue)
Pop a request from the given queue and correctly deallocate and discard it.
Definition: fetch1.cc:371
Minor::Fetch1::changeStream
void changeStream(const BranchData &branch)
Start fetching from a new address.
Definition: fetch1.cc:479
Minor
Definition: activity.cc:44
Minor::Fetch1::FetchRequest::makePacket
void makePacket()
Make a packet to use with the memory transaction.
Definition: fetch1.cc:218
Minor::Fetch1::Fetch1ThreadInfo::blocked
bool blocked
Blocked indication for report.
Definition: fetch1.hh:275
packet.hh
Minor::Fetch1
A stage responsible for fetching "lines" from memory and passing them to Fetch2.
Definition: fetch1.hh:59
Minor::Fetch1::moveFromRequestsToTransfers
void moveFromRequestsToTransfers(FetchRequestPtr request)
Move a request between queues.
Definition: fetch1.cc:312
Minor::Fetch1::wakeupFetch
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
Definition: fetch1.cc:704
Minor::Fetch1::fetchLimit
unsigned int fetchLimit
Maximum number of fetches allowed in flight (in queues or memory)
Definition: fetch1.hh:218
Minor::Fetch1::FetchRequest::Translated
@ Translated
Definition: fetch1.hh:114
Minor::Fetch1::getIcachePort
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
Definition: fetch1.hh:393
Minor::Fetch1::FetchRequest::FetchRequestState
FetchRequestState
Progress of this request through address translation and memory.
Definition: fetch1.hh:110
Minor::Fetch1::recvTimingResp
virtual bool recvTimingResp(PacketPtr pkt)
Memory interface.
Definition: fetch1.cc:407
Minor::Fetch1::out
Latch< ForwardLineData >::Input out
Output port carrying read lines to Fetch2.
Definition: fetch1.hh:195
Minor::Fetch1::FetchWaitingForPC
@ FetchWaitingForPC
Definition: fetch1.hh:228
Minor::Fetch1::threadPriority
ThreadID threadPriority
Definition: fetch1.hh:282
Minor::Fetch1::FetchRequest::request
RequestPtr request
The underlying request that this fetch represents.
Definition: fetch1.hh:131
Minor::Fetch1::IcachePort::fetch
Fetch1 & fetch
My owner.
Definition: fetch1.hh:67
Minor::Fetch1::FetchRequest::packet
PacketPtr packet
FetchRequests carry packets while they're in the requests and transfers responses queues.
Definition: fetch1.hh:128
Minor::Fetch1::FetchRequest::RequestIssuing
@ RequestIssuing
Definition: fetch1.hh:115
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
Minor::Fetch1::inp
Latch< BranchData >::Output inp
Input port carrying branch requests from Execute.
Definition: fetch1.hh:193
Minor::Fetch1::FetchRequest::reportData
void reportData(std::ostream &os) const
Report interface.
Definition: fetch1.cc:736
Packet::SenderState
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:431
Minor::Fetch1::IcacheNeedsRetry
@ IcacheNeedsRetry
Definition: fetch1.hh:288
MinorCPU
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Definition: cpu.hh:77
Minor::Latch::Output
Definition: buffers.hh:256
Minor::Fetch1::lineSeqNum
InstSeqNum lineSeqNum
Sequence number for line fetch used for ordering lines to flush.
Definition: fetch1.hh:306
Minor::Queue
Wrapper for a queue type to act as a pipeline stage input queue.
Definition: buffers.hh:397
Minor::Fetch1::Fetch1ThreadInfo::Fetch1ThreadInfo
Fetch1ThreadInfo(const Fetch1ThreadInfo &other)
Definition: fetch1.hh:248
Minor::Fetch1::numInFlightFetches
unsigned int numInFlightFetches()
Returns the total number of queue occupancy, in-ITLB and in-memory system fetches.
Definition: fetch1.cc:380
Minor::Fetch1::operator<<
friend std::ostream & operator<<(std::ostream &os, Fetch1::FetchState state)
Definition: fetch1.cc:459
Minor::Fetch1::FetchRunning
@ FetchRunning
Definition: fetch1.hh:231
Fault
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
Minor::Fetch1::FetchRequest::isDiscardable
bool isDiscardable() const
Is this line out of date with the current stream/prediction sequence and can it be discarded without ...
Definition: fetch1.cc:741
MinorCPU::MinorCPUPort::MinorCPUPort
MinorCPUPort(const std::string &name_, MinorCPU &cpu_)
Definition: cpu.hh:105
Minor::Fetch1::IcachePort
Exposable fetch port.
Definition: fetch1.hh:63
Minor::Fetch1::FetchRequest::InTranslation
@ InTranslation
Definition: fetch1.hh:113
RubyTester::SenderState
Definition: RubyTester.hh:86
Minor::Fetch1::FetchRequest
Memory access queuing.
Definition: fetch1.hh:99
ArmISA::mode
Bitfield< 4, 0 > mode
Definition: miscregs_types.hh:70
MinorCPU::MinorCPUPort
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
Definition: cpu.hh:98
BaseTLB::Translation
Definition: tlb.hh:59
Minor::Fetch1::tryToSend
bool tryToSend(FetchRequestPtr request)
Try to send (or resend) a memory request's next/only packet to the memory system.
Definition: fetch1.cc:321
Minor::InputBuffer
Like a Queue but with a restricted interface and a setTail function which, when the queue is empty,...
Definition: buffers.hh:565
Minor::Fetch1::getScheduledThread
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to fetch from.
Definition: fetch1.cc:114
InstSeqNum
uint64_t InstSeqNum
Definition: inst_seq.hh:37
NoFault
constexpr decltype(nullptr) NoFault
Definition: types.hh:245
Minor::Fetch1::Fetch1
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:53
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
Minor::Fetch1::IcacheRunning
@ IcacheRunning
Definition: fetch1.hh:287
Minor::Fetch1::fetchLine
void fetchLine(ThreadID tid)
Insert a line fetch into the requests.
Definition: fetch1.cc:146
Minor::Fetch1::FetchHalted
@ FetchHalted
Definition: fetch1.hh:226
Minor::Fetch1::Fetch1ThreadInfo
Stage cycle-by-cycle state.
Definition: fetch1.hh:236
Minor::Fetch1::fetchInfo
std::vector< Fetch1ThreadInfo > fetchInfo
Definition: fetch1.hh:281
Minor::Fetch1::tryToSendToTransfers
void tryToSendToTransfers(FetchRequestPtr request)
Try and issue a fetch for a translated request at the head of the requests queue.
Definition: fetch1.cc:273
Named
Definition: trace.hh:147
Minor::Fetch1::stepQueues
void stepQueues()
Step requests along between requests and transfers queues.
Definition: fetch1.cc:349
Minor::Fetch1::Fetch1ThreadInfo::state
FetchState state
Definition: fetch1.hh:256
Minor::Fetch1::FetchRequest::pc
TheISA::PCState pc
PC to fixup with line address.
Definition: fetch1.hh:134
Minor::Fetch1::FetchRequest::Complete
@ Complete
Definition: fetch1.hh:116
Minor::BranchData
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
Definition: pipe_data.hh:62
Minor::Fetch1::Fetch1ThreadInfo::pc
TheISA::PCState pc
Fetch PC value.
Definition: fetch1.hh:261
Minor::Fetch1::updateExpectedSeqNums
void updateExpectedSeqNums(const BranchData &branch)
Update streamSeqNum and predictionSeqNum from the given branch (and assume these have changed and dis...
Definition: fetch1.cc:511
base.hh
Minor::Fetch1::transfers
FetchQueue transfers
Queue of in-memory system requests and responses.
Definition: fetch1.hh:300
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
Minor::Fetch1::numFetchesInMemorySystem
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:312
Minor::Fetch1::minorTrace
void minorTrace() const
Definition: fetch1.cc:752
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Minor::Fetch1::FetchRequest::finish
void finish(const Fault &fault_, const RequestPtr &request_, ThreadContext *tc, BaseTLB::Mode mode)
Interface for ITLB responses.
Definition: fetch1.cc:230
Minor::Fetch1::isDrained
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
Definition: fetch1.cc:718
Minor::Fetch1::lineSnap
unsigned int lineSnap
Line snap size in bytes.
Definition: fetch1.hh:209
Minor::Fetch1::minorTraceResponseLine
void minorTraceResponseLine(const std::string &name, FetchRequestPtr response) const
Print the appropriate MinorLine line for a fetch response.
Definition: fetch1.cc:388
Minor::Fetch1::maxLineWidth
unsigned int maxLineWidth
Maximum fetch width in bytes.
Definition: fetch1.hh:215
Minor::NoBubbleTraits
...
Definition: buffers.hh:115
buffers.hh
Minor::Fetch1::FetchRequest::FetchRequest
FetchRequest(Fetch1 &fetch_, InstId id_, TheISA::PCState pc_)
Definition: fetch1.hh:168
Named::name
const std::string & name() const
Definition: trace.hh:156
Minor::Fetch1::FetchRequest::markDelayed
void markDelayed()
BaseTLB::Translation interface.
Definition: fetch1.hh:159
Minor::Fetch1::FetchRequest::id
InstId id
Identity of the line that this request will generate.
Definition: fetch1.hh:122
Minor::Fetch1::IcachePort::recvReqRetry
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: fetch1.hh:78
Minor::Fetch1::FetchRequest::state
FetchRequestState state
Definition: fetch1.hh:119
Minor::Fetch1::FetchRequestPtr
FetchRequest * FetchRequestPtr
Definition: fetch1.hh:184
Minor::Fetch1::IcachePort::IcachePort
IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu)
Definition: fetch1.hh:70
Minor::InstId
Id for lines and instructions.
Definition: dyn_inst.hh:68
Minor::Fetch1::Fetch1ThreadInfo::Fetch1ThreadInfo
Fetch1ThreadInfo()
Consturctor to initialize all fields.
Definition: fetch1.hh:239
Minor::Fetch1::Fetch1ThreadInfo::wakeupGuard
bool wakeupGuard
Signal to guard against sleeping first cycle of wakeup.
Definition: fetch1.hh:278
Minor::Fetch1::FetchQueue
Queue< FetchRequestPtr, ReportTraitsPtrAdaptor< FetchRequestPtr >, NoBubbleTraits< FetchRequestPtr > > FetchQueue
Definition: fetch1.hh:294
Minor::Fetch1::IcacheState
IcacheState
State of memory access for head instruction fetch.
Definition: fetch1.hh:285
Minor::Fetch1::FetchRequest::~FetchRequest
~FetchRequest()
Definition: fetch1.cc:266

Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17