48 #include "debug/Drain.hh"
49 #include "debug/MinorCPU.hh"
50 #include "debug/MinorTrace.hh"
51 #include "debug/Quiesce.hh"
59 allow_idling(params.enableIdling),
60 f1ToF2(cpu.
name() +
".f1ToF2",
"lines",
61 params.fetch1ToFetch2ForwardDelay),
62 f2ToF1(cpu.
name() +
".f2ToF1",
"prediction",
63 params.fetch1ToFetch2BackwardDelay, true),
64 f2ToD(cpu.
name() +
".f2ToD",
"insts",
65 params.fetch2ToDecodeForwardDelay),
66 dToE(cpu.
name() +
".dToE",
"insts",
67 params.decodeToExecuteForwardDelay),
68 eToF1(cpu.
name() +
".eToF1",
"branch",
69 params.executeBranchDelay),
70 execute(cpu.
name() +
".execute", cpu, params,
71 dToE.
output(), eToF1.input()),
72 decode(cpu.
name() +
".decode", cpu, params,
73 f2ToD.
output(), dToE.input(), execute.inputBuffer),
74 fetch2(cpu.
name() +
".fetch2", cpu, params,
75 f1ToF2.
output(), eToF1.
output(), f2ToF1.input(), f2ToD.input(),
77 fetch1(cpu.
name() +
".fetch1", cpu, params,
78 eToF1.
output(), f1ToF2.input(), f2ToF1.
output(), fetch2.inputBuffer),
79 activityRecorder(cpu.
name() +
".activity", Num_StageId,
81 std::max(params.fetch1ToFetch2ForwardDelay,
82 std::max(params.fetch2ToDecodeForwardDelay,
83 std::max(params.decodeToExecuteForwardDelay,
84 params.executeBranchDelay)))),
85 needToSignalDrained(false)
87 if (params.fetch1ToFetch2ForwardDelay < 1) {
88 fatal(
"%s: fetch1ToFetch2ForwardDelay must be >= 1 (%d)\n",
89 cpu.name(), params.fetch1ToFetch2ForwardDelay);
92 if (params.fetch2ToDecodeForwardDelay < 1) {
93 fatal(
"%s: fetch2ToDecodeForwardDelay must be >= 1 (%d)\n",
94 cpu.name(), params.fetch2ToDecodeForwardDelay);
97 if (params.decodeToExecuteForwardDelay < 1) {
98 fatal(
"%s: decodeToExecuteForwardDelay must be >= 1 (%d)\n",
99 cpu.name(), params.decodeToExecuteForwardDelay);
102 if (params.executeBranchDelay < 1) {
103 fatal(
"%s: executeBranchDelay must be >= 1\n",
104 cpu.name(), params.executeBranchDelay);
151 DPRINTF(Quiesce,
"Suspending as the processor is idle\n");
168 DPRINTF(Drain,
"Still draining\n");
170 DPRINTF(Drain,
"Signalling end of draining\n");
200 " Execution should drain naturally\n");
215 DPRINTF(Drain,
"Drain resume\n");
217 for (
ThreadID tid = 0; tid <
cpu.numThreads; tid++) {
232 bool f1_to_f2_drained =
f1ToF2.empty();
233 bool f2_to_f1_drained =
f2ToF1.empty();
234 bool f2_to_d_drained =
f2ToD.empty();
235 bool d_to_e_drained =
dToE.empty();
237 bool ret = fetch1_drained && fetch2_drained &&
238 decode_drained && execute_drained &&
239 f1_to_f2_drained && f2_to_f1_drained &&
240 f2_to_d_drained && d_to_e_drained;
242 DPRINTF(
MinorCPU,
"Pipeline undrained stages state:%s%s%s%s%s%s%s%s\n",
243 (fetch1_drained ?
"" :
" Fetch1"),
244 (fetch2_drained ?
"" :
" Fetch2"),
245 (decode_drained ?
"" :
" Decode"),
246 (execute_drained ?
"" :
" Execute"),
247 (f1_to_f2_drained ?
"" :
" F1->F2"),
248 (f2_to_f1_drained ?
"" :
" F2->F1"),
249 (f2_to_d_drained ?
"" :
" F2->D"),
250 (d_to_e_drained ?
"" :
" D->E")
void signalDrainDone()
Signal from Pipeline that MinorCPU should signal that a drain is complete and set its drainState...
const std::string & name()
static void output(const char *filename)
Latch< ForwardInstData > f2ToD
Latch< BranchData > f2ToF1
All the fun of executing instructions from Decode and sending branch/new instruction stream info...
MinorCPU::MinorCPUPort & getInstPort()
Functions below here are BaseCPU operations passed on to pipeline stages.
Fetch2 receives lines of data from Fetch1, separates them into instructions and passes them to Decode...
MinorCPU::MinorCPUPort & getDataPort()
Return the DcachePort belonging to Execute for the CPU.
Latch< ForwardInstData > dToE
Latch< BranchData > eToF1
bool isDrained()
Test to see if the CPU is drained.
bool isDrained()
Is this stage drained? For Decoed, draining is initiated by Execute halting Fetch1 causing Fetch2 to ...
Latch< ForwardLineData > f1ToF2
Decode collects macro-ops from Fetch2 and splits them into micro-ops passed to Execute.
MinorActivityRecorder activityRecorder
Activity recording for the pipeline.
void deactivateStage(const int idx)
Deactivates a stage.
Ticked attaches gem5's event queue/scheduler to evaluate calls and provides a start/stop interface to...
Provide a non-protected base class for Minor's Ports as derived classes are created by Fetch1 and Exe...
bool needToSignalDrained
True after drain is called but draining isn't complete.
void stop()
Cancel the next tick event and issue no more.
bool drain()
Try to drain the CPU.
bool isDrained()
Is this stage drained? For Fetch2, draining is initiated by Execute halting Fetch1 causing Fetch2 to ...
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
void evaluate()
Ticked interface.
Fetch1 is responsible for fetching "lines" from memory and passing them to Fetch2.
void wakeupFetch(ThreadID tid)
Wake up the Fetch unit.
int16_t ThreadID
Thread index/ID type.
void evaluate()
Pass on input/buffer data to the output if you can.
Pipeline(MinorCPU &cpu_, MinorCPUParams ¶ms)
bool allow_idling
Allow cycles to be skipped when the pipeline is idle.
bool active()
Returns if the CPU should be active.
The constructed pipeline.
void wakeupFetch(ThreadID tid)
Initiate fetch1 fetching.
bool isDrained()
Is this stage drained? For Fetch1, draining is initiated by Execute signalling a branch with the reas...
MinorCPU is an in-order CPU model with four fixed pipeline stages:
void evaluate()
Pass on input/buffer data to the output if you can.
bool isDrained()
After thread suspension, has Execute been drained of in-flight instructions and memory accesses...
void evaluate() override
A custom evaluate allows report in the right place (between stages and pipeline advance) ...
void evaluate()
Pass on input/buffer data to the output if you can.
unsigned int drain()
Like the drain interface on SimObject.
MinorCPU::MinorCPUPort & getDcachePort()
Returns the DcachePort owned by this Execute to pass upwards.
void evaluate()
Pass on input/buffer data to the output if you can.