• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/mcopteron/McOpteron.h

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 /// @brief Main Monte Carlo Opteron Simulation Class
00017 ///
00018 /// This class drives the entire simulation. It instantiates the CPU model,
00019 /// reads instruction definition and mix information from files, and then 
00020 /// runs the simulation cycle by cycle. The simulation is generally composed
00021 /// of working backwards up the architectural pipeline each cycle, from
00022 /// retiring instructions out of the reorder buffer and load-store queue,
00023 /// to updating the progress of the functional units, to allowing the 
00024 /// reservation queues to send new instructions to the functional units,
00025 /// to fetching and dispatching new instructions to the reservation queues.
00026 /// Instruction fetch can also be done from a trace file. 
00027 ///
00028 /// Each instruction is represented by a token object. This object has a 
00029 /// pointer to an InstructionInfo record that holds the data about the type
00030 /// of instruction it is. The token moves to the reservation queues, and
00031 /// the reorder buffer and possibly the load-store queue also hold a reference
00032 /// to it. Once the token recognizes it is completed, the reorder buffer will
00033 /// tell it it is retired, and then the reservation queue can delete it. Token
00034 /// objects are always deleted by the reservation queue that holds it.
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;      ///< Functional units list
00065    InstructionQueue *instructionQueuesHead;  ///< Instruction queues list
00066    CycleCount currentCycle;                  ///< Current simulation cycle
00067    InstructionCount totalInstructions;       ///< Total instructions so far
00068    double* instructionClassProbabilities;    ///< Instruction type CDF
00069    InstructionInfo **instructionClasses;     ///< Instruction type ptrs
00070    InstructionInfo *instructionClassesHead,  ///< Instruction type list
00071                    *instructionClassesTail;  ///< Instruction type list tail
00072    unsigned int numInstructionClasses;       ///< Number of instruction types
00073    InstructionInfo *infoLEA;  ///< direct ptr to LEA insn for fast access
00074    Dependency *dependenciesHead; ///< inter-insn operand dependency list
00075    Dependency *dependenciesTail;
00076    LoadStoreUnit *loadStoreUnit;
00077    MemoryModel *memoryModel;
00078    ReorderBuffer *reorderBuffer;
00079    ReorderBuffer *fakeIBuffer;
00080    double lastCPI;
00081    Token *lastToken; ///< Must remember last token generated but not used
00082    double probBranchMispredict;
00083    CycleCount nextAvailableFetch;
00084    unsigned long long fetchStallCycles;
00085    OffCpuIF *externalIF; ///< external interface
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

Generated on Fri Oct 22 2010 11:02:25 for SST by  doxygen 1.7.1