46#include "debug/Drain.hh"
47#include "debug/MinorCPU.hh"
48#include "debug/MinorTrace.hh"
49#include "debug/Quiesce.hh"
60 allow_idling(params.enableIdling),
61 f1ToF2(cpu.
name() +
".f1ToF2",
"lines",
62 params.fetch1ToFetch2ForwardDelay),
63 f2ToF1(cpu.
name() +
".f2ToF1",
"prediction",
64 params.fetch1ToFetch2BackwardDelay, true),
65 f2ToD(cpu.
name() +
".f2ToD",
"insts",
66 params.fetch2ToDecodeForwardDelay),
67 dToE(cpu.
name() +
".dToE",
"insts",
68 params.decodeToExecuteForwardDelay),
69 eToF1(cpu.
name() +
".eToF1",
"branch",
70 params.executeBranchDelay),
71 execute(cpu.
name() +
".execute", cpu, params,
72 dToE.
output(), eToF1.input()),
73 decode(cpu.
name() +
".decode", cpu, params,
74 f2ToD.
output(), dToE.input(), execute.inputBuffer),
75 fetch2(cpu.
name() +
".fetch2", cpu, params,
76 f1ToF2.
output(), eToF1.
output(), f2ToF1.input(), f2ToD.input(),
78 fetch1(cpu.
name() +
".fetch1", cpu, params,
79 eToF1.
output(), f1ToF2.input(), f2ToF1.
output(), fetch2.inputBuffer),
80 activityRecorder(cpu.
name() +
".activity", Num_StageId,
82 std::max(params.fetch1ToFetch2ForwardDelay,
83 std::max(params.fetch2ToDecodeForwardDelay,
84 std::max(params.decodeToExecuteForwardDelay,
85 params.executeBranchDelay)))),
86 needToSignalDrained(false)
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");
204 " Execution should drain naturally\n");
219 DPRINTF(Drain,
"Drain resume\n");
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")
void deactivateStage(const int idx)
Deactivates a stage.
bool active()
Returns if the CPU should be active.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
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:
void signalDrainDone()
Signal from Pipeline that MinorCPU should signal that a drain is complete and set its drainState.
void tick()
The tick method in the MinorCPU is simply updating the cycle counters as the ticking of the pipeline ...
virtual std::string name() const
Ticked attaches gem5's event queue/scheduler to evaluate calls and provides a start/stop interface to...
void stop()
Cancel the next tick event and issue no more.
void evaluate()
Pass on input/buffer data to the output if you can.
bool isDrained()
Is this stage drained? For Decoed, draining is initiated by Execute halting Fetch1 causing Fetch2 to ...
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.
bool isDrained()
After thread suspension, has Execute been drained of in-flight instructions and memory accesses.
MinorCPU::MinorCPUPort & getIcachePort()
Returns the IcachePort owned by this Fetch1.
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...
void evaluate()
Pass on input/buffer data to the output if you can.
void evaluate()
Pass on input/buffer data to the output if you can.
bool isDrained()
Is this stage drained? For Fetch2, draining is initiated by Execute halting Fetch1 causing Fetch2 to ...
void evaluate()
Ticked interface.
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...
#define fatal(...)
This implements a cprintf based fatal() function.
Decode collects macro-ops from Fetch2 and splits them into micro-ops passed to Execute.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
int16_t ThreadID
Thread index/ID type.
static void output(const char *filename)
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
Overload hash function for BasicBlockRange type.
The constructed pipeline.
const std::string & name()