00001
00002 #ifndef INSTRUCTIONQUEUE_H
00003 #define INSTRUCTIONQUEUE_H
00004
00005 #include <OpteronDefs.h>
00006
00007 class FunctionalUnit;
00008 class Token;
00009
00010 #define MAXFUNITS 5
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 class InstructionQueue
00023 {
00024 public:
00025 enum QType {INT, INTMUL, INTSP, FLOAT};
00026 InstructionQueue(QType type, char *name, unsigned int id, unsigned int size);
00027 ~InstructionQueue();
00028 void setNext(InstructionQueue *other);
00029 InstructionQueue* getNext();
00030 int addFunctionalUnit(FunctionalUnit *fu);
00031 int scheduleInstructions(CycleCount currentCycle);
00032 bool canHandleInstruction(Token *token);
00033 int assignInstruction(Token *token, CycleCount atCycle);
00034 bool isFull() {return (numInstructions >= size);};
00035 bool isEmpty() {return (numInstructions == 0);};
00036 void incFullStall() {fullStalls++;}
00037 void incAlreadyAssignedStall() {assignedStalls++;}
00038 bool alreadyAssigned(CycleCount currentCycle);
00039 double averageOccupancy(CycleCount cycles);
00040 private:
00041 char *name;
00042 QType type;
00043 unsigned int id;
00044 unsigned int size;
00045 FunctionalUnit* myUnits[MAXFUNITS];
00046 Token **queuedInstructions;
00047 InstructionCount totalInstructions;
00048 InstructionCount finishedInstructions;
00049 unsigned long long fullStalls, assignedStalls;
00050 unsigned long long occupancyXCycles, totalCycles;
00051 unsigned int numInstructions;
00052 CycleCount lastAssignedCycle;
00053 class InstructionQueue *next;
00054 };
00055
00056 #endif