00001
00002 #ifndef MCOPTERON_H
00003 #define MCOPTERON_H
00004
00005 #include <Token.h>
00006 #include <OffCpuIF.h>
00007
00008 class FunctionalUnit;
00009 class InstructionQueue;
00010 class LoadStoreUnit;
00011 class MemoryModel;
00012 class ReorderBuffer;
00013 class ConfigVars;
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class McOpteron
00037 {
00038 public:
00039 McOpteron();
00040 ~McOpteron();
00041 void setOutputFiles(const char* outFilename, const char* debugFilename);
00042 int init(const char* definitionFilename, const char* mixFilename,
00043 const char* cpuIniFilename, const char* appIniFilename,
00044 OffCpuIF *extif, const char *traceFilename=0);
00045 int finish(bool printInstMix);
00046 int simCycle();
00047 CycleCount currentCycles();
00048 double currentCPI();
00049
00050 private:
00051 Token* generateToken();
00052 Token* getNextTraceToken();
00053 bool allQueuesEmpty();
00054 int updateFunctionalUnits();
00055 int scheduleNewInstructions();
00056 int refillInstructionQueues();
00057 Dependency* checkForDependencies(InstructionCount insn);
00058 Dependency* addNewDependency(InstructionCount insn);
00059 int readConfigFile(const char* filename);
00060 int readIMixFile(const char *filename);
00061 int readIDefFile(const char *filename);
00062 void createInstructionMixCDF();
00063
00064 FunctionalUnit *functionalUnitsHead;
00065 InstructionQueue *instructionQueuesHead;
00066 CycleCount currentCycle;
00067 InstructionCount totalInstructions;
00068 double* instructionClassProbabilities;
00069 InstructionInfo **instructionClasses;
00070 InstructionInfo *instructionClassesHead,
00071 *instructionClassesTail;
00072 unsigned int numInstructionClasses;
00073 InstructionInfo *infoLEA;
00074 Dependency *dependenciesHead;
00075 Dependency *dependenciesTail;
00076 LoadStoreUnit *loadStoreUnit;
00077 MemoryModel *memoryModel;
00078 ReorderBuffer *reorderBuffer;
00079 ReorderBuffer *fakeIBuffer;
00080 double lastCPI;
00081 Token *lastToken;
00082 double probBranchMispredict;
00083 CycleCount nextAvailableFetch;
00084 unsigned long long fetchStallCycles;
00085 OffCpuIF *externalIF;
00086 FILE *traceF;
00087 Address fakeAddress;
00088 ConfigVars *config;
00089 };
00090
00091 #define READIntConfigVar(name, variable) \
00092 if ((v = config->findVariable(name))) \
00093 variable = atoi(v); \
00094 else { \
00095 fprintf(stderr, "Error: must specify var (%s)...quitting\n", name); \
00096 exit(1); \
00097 }
00098 #define READStringConfigVar(name, variable) \
00099 if ((v = config->findVariable(name))) \
00100 variable = strdup(v); \
00101 else { \
00102 fprintf(stderr, "Error: must specify var (%s)...quitting\n", name); \
00103 exit(1); \
00104 }
00105 #define READRealConfigVar(name, variable) \
00106 if ((v = config->findVariable(name))) \
00107 variable = atof(v); \
00108 else { \
00109 fprintf(stderr, "Error: must specify var (%s)...quitting\n", name); \
00110 exit(1); \
00111 }
00112
00113
00114 #endif