Go to the documentation of this file.
46 #include "debug/Drain.hh"
47 #include "debug/Fetch.hh"
48 #include "debug/MinorTrace.hh"
55 MinorCPUParams ¶ms,
64 prediction(prediction_),
65 nextStageReserve(next_stage_input_buffer),
66 icachePort(name_ +
".icache_port", *this, cpu_),
67 lineSnap(params.fetch1LineSnapWidth),
68 maxLineWidth(params.fetch1LineWidth),
69 fetchLimit(params.fetch1FetchLimit),
70 fetchInfo(params.numThreads),
72 requests(name_ +
".requests",
"lines", params.fetch1FetchLimit),
73 transfers(name_ +
".transfers",
"lines", params.fetch1FetchLimit),
74 icacheState(IcacheRunning),
75 lineSeqNum(
InstId::firstLineSeqNum),
76 numFetchesInMemorySystem(0),
81 DPRINTF(Fetch,
"lineSnap set to cache line size of: %d\n",
87 DPRINTF(Fetch,
"maxLineWidth set to cache line size of: %d\n",
93 fatal(
"%s: fetch1LineSnapWidth must be a multiple "
94 "of sizeof(TheISA::MachInst) (%d)\n", name_,
101 fatal(
"%s: fetch1LineWidth must be a multiple of"
102 " sizeof(TheISA::MachInst)"
103 " (%d), and >= fetch1LineSnapWidth (%d)\n",
108 fatal(
"%s: fetch1FetchLimit must be >= 1 (%d)\n", name_,
120 case Enums::SingleThreaded:
121 priority_list.push_back(0);
123 case Enums::RoundRobin:
130 panic(
"Unknown fetch policy");
133 for (
auto tid : priority_list) {
155 unsigned int line_offset = aligned_pc %
lineSnap;
165 DPRINTF(Fetch,
"Inserting fetch into the fetch queue "
166 "%s addr: 0x%x pc: %s line_offset: %d request_size: %d\n",
167 request_id, aligned_pc, thread.
pc, line_offset, request_size);
173 thread.
pc.instAddr());
175 DPRINTF(Fetch,
"Submitting ITLB request\n");
197 thread.
pc.set(aligned_pc + request_size);
205 os <<
"IcacheRunning";
208 os <<
"IcacheNeedsRetry";
211 os <<
"IcacheState-" <<
static_cast<int>(state);
236 fetch.handleTLBResponse(
this);
248 DPRINTF(Fetch,
"Fault in address ITLB translation: %s, "
249 "paddr: 0x%x, vaddr: 0x%x\n",
250 response->
fault->name(),
251 (response->
request->hasPaddr() ?
252 response->
request->getPaddr() : 0),
253 response->
request->getVaddr());
258 DPRINTF(Fetch,
"Got ITLB response\n");
276 DPRINTF(Fetch,
"Fetch not at front of requests queue, can't"
277 " issue to memory\n");
282 DPRINTF(Fetch,
"Fetch still in translation, not issuing to"
307 DPRINTF(Fetch,
"Not advancing line fetch\n");
335 DPRINTF(Fetch,
"Issued fetch request to memory: %s\n",
341 DPRINTF(Fetch,
"Line fetch needs to retry: %s\n",
365 DPRINTF(Fetch,
"Step in state %s moving to state %s\n",
373 if (!queue.
empty()) {
374 delete queue.
front();
394 MINORLINE(
this,
"id=F;%s vaddr=0x%x fault=\"error packet\"\n",
395 response->
id, request->getVaddr());
397 MINORLINE(
this,
"id=F;%s vaddr=0x%x fault=\"%s\"\n",
398 response->
id, request->getVaddr(), response->
fault->name());
400 MINORLINE(
this,
"id=%s size=%d vaddr=0x%x paddr=0x%x\n",
401 response->
id, request->getSize(),
402 request->getVaddr(), request->getPaddr());
418 assert(!fetch_request->
packet);
419 fetch_request->
packet = response;
428 DPRINTF(Fetch,
"Received error response packet: %s\n",
466 os <<
"FetchWaitingForPC";
469 os <<
"FetchRunning";
472 os <<
"FetchState-" <<
static_cast<int>(state);
490 DPRINTF(Fetch,
"Not suspending fetch due to guard: %s\n",
493 DPRINTF(Fetch,
"Suspending fetch: %s\n", branch);
499 DPRINTF(Fetch,
"Halting fetch\n");
503 DPRINTF(Fetch,
"Changing stream on branch: %s\n", branch);
515 DPRINTF(Fetch,
"Updating streamSeqNum from: %d to %d,"
516 " predictionSeqNum from: %d to %d\n",
539 line.
id = response->
id;
541 line.
pc = response->
pc;
551 DPRINTF(Fetch,
"Stopping line fetch because of fault: %s\n",
552 response->
fault->name());
584 DPRINTF(Fetch,
"Halted, ignoring branch: %s\n", execute_branch);
590 DPRINTF(Fetch,
"Ignoring simultaneous prediction: %s\n",
602 DPRINTF(Fetch,
"Not changing stream on prediction: %s,"
603 " streamSeqNum mismatch\n",
615 DPRINTF(Fetch,
"Halted, ignoring branch: %s\n", execute_branch);
625 DPRINTF(Fetch,
"Halted, ignoring branch: %s\n", fetch2_branch);
627 DPRINTF(Fetch,
"Not changing stream on prediction: %s,"
628 " streamSeqNum mismatch\n", fetch2_branch);
639 DPRINTF(Fetch,
"Fetching from thread %d\n", fetch_tid);
646 DPRINTF(Fetch,
"No active threads available to fetch from\n");
665 DPRINTF(Fetch,
"Discarding translated fetch as it's for"
672 DPRINTF(Fetch,
"Processing fetched line: %s\n",
699 thread.wakeupGuard =
false;
711 DPRINTF(Fetch,
"[tid:%d]: Changing stream wakeup %s\n",
723 DPRINTF(Drain,
"isDrained[tid:%d]: %s %s%s\n",
727 ((*
out.inputWire).isBubble() ?
"" :
"outputtingLine"));
746 return state != InTranslation && state != RequestIssuing &&
758 std::ostringstream
data;
763 (*
out.inputWire).reportData(
data);
765 MINORTRACE(
"state=%s icacheState=%s in_tlb_mem=%s/%s"
const ThreadID InvalidThreadID
#define fatal(...)
This implements a cprintf based fatal() function.
ThreadID threadId
ThreadID associated with branch.
TheISA::PCState target
Starting PC of that stream.
void wakeupOnEvent(unsigned int stage_id)
Interface for stages to signal that they have become active after a callback or eventq event where th...
IcachePort icachePort
IcachePort to pass to the CPU.
std::vector< InputBuffer< ForwardLineData > > & nextStageReserve
Interface to reserve space in the next stage.
void evaluate()
Pass on input/buffer data to the output if you can.
int16_t ThreadID
Thread index/ID type.
IcacheState icacheState
Retry state of icache_port.
FetchQueue requests
Queue of address translated requests from Fetch1.
Minor::MinorActivityRecorder * activityRecorder
Activity recording for pipeline.
void adoptPacketData(Packet *packet)
Use the data from a packet as line instead of allocating new space.
InstSeqNum newStreamSeqNum
Sequence number of new stream/prediction to be adopted.
Fault fault
Fill in a fault if one happens during fetch, check this by picking apart the response packet.
Line fetch data in the forward direction.
unsigned int cacheLineSize() const
Get the cache line size of the system.
InstSeqNum predictionSeqNum
Prediction sequence number.
InstSeqNum streamSeqNum
Stream sequence number.
void handleTLBResponse(FetchRequestPtr response)
Handle pushing a TLB response onto the right queue.
virtual void recvReqRetry()
MinorCPU & cpu
Construction-assigned data members.
Enums::ThreadPolicy threadPolicy
Thread Scheduling Policy (RoundRobin, Random, etc)
bool isComplete() const
Is this a complete read line or fault.
void processResponse(FetchRequestPtr response, ForwardLineData &line)
Convert a response to a ForwardLineData.
std::shared_ptr< Request > RequestPtr
unsigned int numFetchesInITLB
Number of requests inside the ITLB rather than in the queues.
Reason reason
Explanation for this branch.
#define MINORTRACE(...)
DPRINTFN for MinorTrace reporting.
bool empty() const
Is the queue empty?
InstId id
Thread, stream, prediction ...
void push(ElemType &data)
Push an element into the buffer if it isn't a bubble.
FetchState
Cycle-by-cycle state.
virtual ThreadContext * getContext(int tn)
Given a thread num get tho thread context for it.
static bool isStreamChange(const BranchData::Reason reason)
Is a request with this reason actually a request to change the PC rather than a bubble or branch pred...
Latch< BranchData >::Output prediction
Input port carrying branch predictions from Fetch2.
void popAndDiscard(FetchQueue &queue)
Pop a request from the given queue and correctly deallocate and discard it.
void changeStream(const BranchData &branch)
Start fetching from a new address.
void reserve()
Reserve space in the queue for future pushes.
void makePacket()
Make a packet to use with the memory transaction.
@ INST_FETCH
The request was an instruction fetch.
bool blocked
Blocked indication for report.
std::vector< Minor::MinorThread * > threads
These are thread state-representing objects for this CPU.
void moveFromRequestsToTransfers(FetchRequestPtr request)
Move a request between queues.
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
unsigned int fetchLimit
Maximum number of fetches allowed in flight (in queues or memory)
virtual bool recvTimingResp(PacketPtr pkt)
Memory interface.
Latch< ForwardLineData >::Input out
Output port carrying read lines to Fetch2.
RequestPtr request
The underlying request that this fetch represents.
PacketPtr packet
FetchRequests carry packets while they're in the requests and transfers responses queues.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Latch< BranchData >::Output inp
Input port carrying branch requests from Execute.
void reportData(std::ostream &os) const
Report interface.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the responder port by calling its corresponding receive function.
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Addr lineBaseAddr
First byte address in the line.
InstSeqNum lineSeqNum
Sequence number for line fetch used for ordering lines to flush.
unsigned int numInFlightFetches()
Returns the total number of queue occupancy, in-ITLB and in-memory system fetches.
friend std::ostream & operator<<(std::ostream &os, Fetch1::FetchState state)
void setFault(Fault fault_)
Set fault and possible clear the bubble flag.
std::shared_ptr< FaultBase > Fault
#define MINORLINE(sim_object,...)
DPRINTFN for MinorTrace MinorLine line reporting.
bool isDiscardable() const
Is this line out of date with the current stream/prediction sequence and can it be discarded without ...
bool needsResponse() const
bool tryToSend(FetchRequestPtr request)
Try to send (or resend) a memory request's next/only packet to the memory system.
ElemType & front()
Head value.
void pop()
Pop the head item.
ThreadID threadId
The thread to which this line/instruction belongs.
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to fetch from.
constexpr decltype(nullptr) NoFault
virtual Status status() const =0
ProbePointArg< PacketInfo > Packet
Packet probe point.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
unsigned int occupiedSpace() const
Number of slots already occupied in this buffer.
Fetch1(const std::string &name_, MinorCPU &cpu_, MinorCPUParams ¶ms, Latch< BranchData >::Output inp_, Latch< ForwardLineData >::Input out_, Latch< BranchData >::Output prediction_, std::vector< InputBuffer< ForwardLineData >> &next_stage_input_buffer)
InstSeqNum newPredictionSeqNum
void fetchLine(ThreadID tid)
Insert a line fetch into the requests.
Stage cycle-by-cycle state.
std::vector< Fetch1ThreadInfo > fetchInfo
void tryToSendToTransfers(FetchRequestPtr request)
Try and issue a fetch for a translated request at the head of the requests queue.
virtual TheISA::PCState pcState() const =0
void stepQueues()
Step requests along between requests and transfers queues.
TheISA::PCState pc
PC to fixup with line address.
RequestorID instRequestorId() const
Reads this CPU's unique instruction requestor ID.
Forward data betwen Execute and Fetch1 carrying change-of-address/stream information.
TheISA::PCState pc
Fetch PC value.
std::ostream & operator<<(std::ostream &os, const InstId &id)
Print this id in the usual slash-separated format expected by MinorTrace.
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
void updateExpectedSeqNums(const BranchData &branch)
Update streamSeqNum and predictionSeqNum from the given branch (and assume these have changed and dis...
FetchQueue transfers
Queue of in-memory system requests and responses.
void activity()
Records that there is activity this cycle.
std::vector< ThreadID > roundRobinPriority(ThreadID priority)
Thread scheduling utility functions.
unsigned int numFetchesInMemorySystem
Count of the number fetches which have left the transfers queue and are in the 'wild' in the memory s...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void finish(const Fault &fault_, const RequestPtr &request_, ThreadContext *tc, BaseTLB::Mode mode)
Interface for ITLB responses.
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
TheISA::PCState pc
PC of the first requested inst within this line.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
unsigned int lineSnap
Line snap size in bytes.
void minorTraceResponseLine(const std::string &name, FetchRequestPtr response) const
Print the appropriate MinorLine line for a fetch response.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
unsigned int maxLineWidth
Maximum fetch width in bytes.
std::vector< ThreadID > randomPriority()
const std::string & name() const
void allocate()
Allocate memory for the packet.
InstId id
Identity of the line that this request will generate.
Id for lines and instructions.
bool wakeupGuard
Signal to guard against sleeping first cycle of wakeup.
#define panic(...)
This implements a cprintf based panic() function.
IcacheState
State of memory access for head instruction fetch.
Generated on Wed Sep 30 2020 14:02:08 for gem5 by doxygen 1.8.17