46#include "debug/Drain.hh"
47#include "debug/MinorCPU.hh"
48#include "debug/MinorTrace.hh"
49#include "debug/Quiesce.hh"
62 params.fetch1ToFetch2ForwardDelay),
64 params.fetch1ToFetch2BackwardDelay, true),
66 params.fetch2ToDecodeForwardDelay),
68 params.decodeToExecuteForwardDelay),
70 params.executeBranchDelay),
82 std::max(params.fetch1ToFetch2ForwardDelay,
83 std::max(params.fetch2ToDecodeForwardDelay,
84 std::max(params.decodeToExecuteForwardDelay,
85 params.executeBranchDelay)))),
88 if (params.fetch1ToFetch2ForwardDelay < 1) {
89 fatal(
"%s: fetch1ToFetch2ForwardDelay must be >= 1 (%d)\n",
90 cpu.name(), params.fetch1ToFetch2ForwardDelay);
93 if (params.fetch2ToDecodeForwardDelay < 1) {
94 fatal(
"%s: fetch2ToDecodeForwardDelay must be >= 1 (%d)\n",
95 cpu.name(), params.fetch2ToDecodeForwardDelay);
98 if (params.decodeToExecuteForwardDelay < 1) {
99 fatal(
"%s: decodeToExecuteForwardDelay must be >= 1 (%d)\n",
100 cpu.name(), params.decodeToExecuteForwardDelay);
103 if (params.executeBranchDelay < 1) {
104 fatal(
"%s: executeBranchDelay must be >= 1\n",
105 cpu.name(), params.executeBranchDelay);
138 if (debug::MinorTrace)
155 DPRINTF(Quiesce,
"Suspending as the processor is idle\n");
172 DPRINTF(Drain,
"Still draining\n");
174 DPRINTF(Drain,
"Signalling end of draining\n");
175 cpu.signalDrainDone();
185 return fetch1.getIcachePort();
191 return execute.getDcachePort();
204 " Execution should drain naturally\n");
219 DPRINTF(Drain,
"Drain resume\n");
221 for (
ThreadID tid = 0; tid <
cpu.numThreads; tid++) {
231 bool fetch1_drained =
fetch1.isDrained();
232 bool fetch2_drained =
fetch2.isDrained();
233 bool decode_drained =
decode.isDrained();
234 bool execute_drained =
execute.isDrained();
236 bool f1_to_f2_drained =
f1ToF2.empty();
237 bool f2_to_f1_drained =
f2ToF1.empty();
238 bool f2_to_d_drained =
f2ToD.empty();
239 bool d_to_e_drained =
dToE.empty();
241 bool ret = fetch1_drained && fetch2_drained &&
242 decode_drained && execute_drained &&
243 f1_to_f2_drained && f2_to_f1_drained &&
244 f2_to_d_drained && d_to_e_drained;
246 DPRINTF(
MinorCPU,
"Pipeline undrained stages state:%s%s%s%s%s%s%s%s\n",
247 (fetch1_drained ?
"" :
" Fetch1"),
248 (fetch2_drained ?
"" :
" Fetch2"),
249 (decode_drained ?
"" :
" Decode"),
250 (execute_drained ?
"" :
" Execute"),
251 (f1_to_f2_drained ?
"" :
" F1->F2"),
252 (f2_to_f1_drained ?
"" :
" F2->F1"),
253 (f2_to_d_drained ?
"" :
" F2->D"),
254 (d_to_e_drained ?
"" :
" D->E")
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
MinorCPU is an in-order CPU model with four fixed pipeline stages:
Ticked(ClockedObject &object_, statistics::Scalar *imported_num_cycles=NULL, Event::Priority priority=Event::CPU_Tick_Pri)
statistics::Scalar & numCycles
Total number of cycles either ticked or spend stopped.
void stop()
Cancel the next tick event and issue no more.
Latch< BranchData > f2ToF1
Pipeline(MinorCPU &cpu_, const BaseMinorCPUParams ¶ms)
Latch< ForwardLineData > f1ToF2
MinorCPU::MinorCPUPort & getDataPort()
Return the DcachePort belonging to Execute for the CPU.
bool allow_idling
Allow cycles to be skipped when the pipeline is idle.
bool needToSignalDrained
True after drain is called but draining isn't complete.
MinorActivityRecorder activityRecorder
Activity recording for the pipeline.
void evaluate() override
A custom evaluate allows report in the right place (between stages and pipeline advance)
MinorCPU::MinorCPUPort & getInstPort()
Functions below here are BaseCPU operations passed on to pipeline stages.
void wakeupFetch(ThreadID tid)
Wake up the Fetch unit.
Latch< BranchData > eToF1
Latch< ForwardInstData > dToE
bool drain()
Try to drain the CPU.
Latch< ForwardInstData > f2ToD
bool isDrained()
Test to see if the CPU is drained.
All the fun of executing instructions from Decode and sending branch/new instruction stream info.
Fetch1 is responsible for fetching "lines" from memory and passing them to Fetch2.
Fetch2 receives lines of data from Fetch1, separates them into instructions and passes them to Decode...
Decode collects macro-ops from Fetch2 and splits them into micro-ops passed to Execute.
Copyright (c) 2024 Arm Limited All rights reserved.
int16_t ThreadID
Thread index/ID type.
static void output(const char *filename)
Overload hash function for BasicBlockRange type.
The constructed pipeline.
const std::string & name()