Represents an instruction queue in the CPU. More...
#include <InstructionQueue.h>
Public Types | |
enum | QType { INT, INTMUL, INTSP, FLOAT } |
Public Member Functions | |
InstructionQueue (QType type, char *name, unsigned int id, unsigned int size) | |
Constructor. | |
~InstructionQueue () | |
Destructor. | |
void | setNext (InstructionQueue *other) |
Create list link. | |
InstructionQueue * | getNext () |
Retrieve list link. | |
int | addFunctionalUnit (FunctionalUnit *fu) |
Attach a functional unit to this queue. | |
int | scheduleInstructions (CycleCount currentCycle) |
Schedule instructions onto functional units. | |
bool | canHandleInstruction (Token *token) |
Check if instruction can be assigned to this queue. | |
int | assignInstruction (Token *token, CycleCount atCycle) |
Assign an instruction to this queue. | |
bool | isFull () |
bool | isEmpty () |
void | incFullStall () |
void | incAlreadyAssignedStall () |
bool | alreadyAssigned (CycleCount currentCycle) |
Check if instruction was already assigned this cycle. | |
double | averageOccupancy (CycleCount cycles) |
Return average occupancy of this queue. |
Represents an instruction queue in the CPU.
This class implements the instruction queue concept. One object represents one queue. Each queue has some functional units that it supervises. This class really is the heart of simulating the execution of an instruction, since it assigns instructions to functional units and retires them when they are done.
int InstructionQueue::addFunctionalUnit | ( | FunctionalUnit * | fu | ) |
Attach a functional unit to this queue.
Functional units should only belong to one queue; this attaches a unit to the queue it is called on.
Referenced by McOpteron::init().
bool InstructionQueue::alreadyAssigned | ( | CycleCount | currentCycle | ) |
Check if instruction was already assigned this cycle.
Only one instruction can be placed on a queue per cycle, so it it already happened on this queue we need to block others.
int InstructionQueue::assignInstruction | ( | Token * | token, | |
CycleCount | atCycle | |||
) |
Assign an instruction to this queue.
This assumes canHandleInstruction() has already been called and it has been verified that the instruction can be placed on this queue
int InstructionQueue::scheduleInstructions | ( | CycleCount | currentCycle | ) |
Schedule instructions onto functional units.
This is the main functionality of a queue; it iterates through the instructions in the queue and assigns them to functional units if they are available and can be used.
References Token::aguOperandsReady(), Token::allOperandsReady(), InstructionInfo::dumpDebugInfo(), Token::executionStart(), FunctionalUnit::getType(), FunctionalUnit::isAvailable(), Token::isCompleted(), Token::isExecuting(), Token::needsAddressGeneration(), Token::needsFunctionalUnit(), and FunctionalUnit::occupy().