43#include "debug/Decode.hh"
53 const BaseMinorCPUParams ¶ms,
61 nextStageReserve(next_stage_input_buffer),
62 outputWidth(params.executeInputWidth),
63 processMoreThanOneInput(params.decodeCycleInput),
64 decodeInfo(params.numThreads),
70 if (params.decodeInputBufferSize < 1) {
71 fatal(
"%s: decodeInputBufferSize must be >= 1 (%d)\n",
name,
72 params.decodeInputBufferSize);
76 for (
ThreadID tid = 0; tid < params.numThreads; tid++) {
79 name +
".inputBuffer" + std::to_string(tid),
"insts",
80 params.decodeInputBufferSize));
130 if (!
inp.outputWire->isBubble())
146 unsigned int output_index = 0;
156 if (inst->isBubble()) {
166 if (inst->isFault()) {
168 inst->fault->name());
196 output_inst->predictedTaken = inst->predictedTaken;
197 set(output_inst->predictedTarget,
198 inst->predictedTarget);
202 " %d output_index: %d lastMicroop: %s microopPC:"
212 parent_static_inst = static_inst;
224 " %d output_index: %d\n",
225 *output_inst, decode_info.
inputIndex, output_index);
227 parent_static_inst = static_inst;
235 output_inst->id.execSeqNum = decode_info.
execSeqNum;
238 dynInstAddTracing(output_inst, parent_static_inst,
cpu);
247 insts_out.
insts[output_index] = output_inst;
295 if (!
inp.outputWire->isBubble())
306 case enums::SingleThreaded:
307 priority_list.push_back(0);
309 case enums::RoundRobin:
316 panic(
"Unknown fetch policy");
319 for (
auto tid : priority_list) {
337 return (*
inp.outputWire).isBubble();
343 std::ostringstream
data;
348 (*
out.inputWire).reportData(
data);
void activity()
Records that there is activity this cycle.
void activateStage(const int idx)
Marks a stage as active.
virtual ThreadContext * getContext(int tn)
Given a thread num get tho thread context for it.
trace::InstTracer * getTracer()
Provide access to the tracer pointer.
ThreadID numThreads
Number of threads we're actually simulating (<= SMT_MAX_THREADS).
MinorCPU is an in-order CPU model with four fixed pipeline stages:
minor::MinorActivityRecorder * activityRecorder
Activity recording for pipeline.
std::vector< ThreadID > randomPriority()
std::vector< ThreadID > roundRobinPriority(ThreadID priority)
Thread scheduling utility functions.
enums::ThreadPolicy threadPolicy
Thread Scheduling Policy (RoundRobin, Random, etc)
Interface for things with names.
virtual std::string name() const
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
virtual void advancePC(PCStateBase &pc_state) const =0
bool isLastMicroop() const
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 ...
std::vector< InputBuffer< ForwardInstData > > inputBuffer
const ForwardInstData * getInput(ThreadID tid)
Get a piece of data to work on, or 0 if there is no data.
void popInput(ThreadID tid)
Pop an element off the input buffer, if there are any.
std::vector< InputBuffer< ForwardInstData > > & nextStageReserve
Interface to reserve space in the next stage.
Latch< ForwardInstData >::Output inp
Input port carrying macro instructions from Fetch2.
std::vector< DecodeThreadInfo > decodeInfo
unsigned int outputWidth
Width of output of this stage/input of next in instructions.
Decode(const std::string &name, MinorCPU &cpu_, const BaseMinorCPUParams ¶ms, Latch< ForwardInstData >::Output inp_, Latch< ForwardInstData >::Input out_, std::vector< InputBuffer< ForwardInstData > > &next_stage_input_buffer)
Latch< ForwardInstData >::Input out
Output port carrying micro-op decomposed instructions to Execute.
ThreadID getScheduledThread()
Use the current threading policy to determine the next thread to decode from.
MinorCPU & cpu
Pointer back to the containing CPU.
bool processMoreThanOneInput
If true, more than one input word can be processed each cycle if there is room in the output to conta...
Forward flowing data between Fetch2,Decode,Execute carrying a packet of instructions of a width appro...
ThreadID threadId
Thread associated with these instructions.
void resize(unsigned int width)
Resize a bubble/empty ForwardInstData and fill with bubbles.
bool isBubble() const
BubbleIF interface.
MinorDynInstPtr insts[MAX_FORWARD_INSTS]
Array of carried insts, ref counted.
unsigned int width() const
Number of instructions carried by this object.
ThreadID threadId
The thread to which this line/instruction belongs.
InstSeqNum execSeqNum
'Execute' sequence number.
Dynamic instruction for Minor.
trace::InstRecord * traceData
Trace information for this instruction's execution.
std::unique_ptr< PCStateBase > pc
The fetch address of this instruction.
const StaticInstPtr staticInst
void setFetchSeq(InstSeqNum seq)
virtual InstRecord * getInstRecord(Tick when, ThreadContext *tc, const StaticInstPtr staticInst, const PCStateBase &pc, const StaticInstPtr macroStaticInst=nullptr)=0
#define panic(...)
This implements a cprintf based panic() function.
#define fatal(...)
This implements a cprintf based fatal() function.
Decode collects macro-ops from Fetch2 and splits them into micro-ops passed to Execute.
void minorTrace(const char *fmt, Args ...args)
DPRINTFN for MinorTrace reporting.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
int16_t ThreadID
Thread index/ID type.
const ThreadID InvalidThreadID
Tick curTick()
The universal simulation clock.
constexpr decltype(nullptr) NoFault
Minor contains all the definitions within the MinorCPU apart from the CPU class itself.
The constructed pipeline.
Data members after this line are cycle-to-cycle state.
InstSeqNum execSeqNum
Source of execSeqNums to number instructions.
bool inMacroop
True when we're in the process of decomposing a micro-op and microopPC will be valid.
std::unique_ptr< PCStateBase > microopPC
unsigned int inputIndex
Index into the inputBuffer's head marking the start of unhandled instructions.
const std::string & name()