00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef SIM_PIPLINE_RETIRER_RETIRER_H
00033 #define SIM_PIPLINE_RETIRER_RETIRER_H
00034
00035 #include "Types.h"
00036 #include "Sim/Foundation/Hook/HookDecl.h"
00037 #include "Sim/Op/OpArray/OpArray.h"
00038 #include "Sim/Op/OpStatus.h"
00039 #include "Sim/Pipeline/PipelineNodeBase.h"
00040 #include "Utility/Collection/fixed_size_buffer.h"
00041
00042 namespace Onikiri
00043 {
00044 class Thread;
00045 class ForwardEmulator;
00046 class InorderList;
00047
00048 class Retirer : public PipelineNodeBase
00049 {
00050 public:
00051
00052
00053 struct CommitSteeringHookParam
00054 {
00055 PhysicalResourceArray<Thread>* threadList;
00056 Thread* targetThread;
00057 };
00058
00059
00060 struct CommitDecisionHookParam
00061 {
00062 OpIterator op;
00063 bool canCommit;
00064 };
00065
00066
00067 BEGIN_PARAM_MAP("")
00068
00069 BEGIN_PARAM_PATH( GetParamPath() )
00070
00071 PARAM_ENTRY( "@CommitWidth", m_commitWidth )
00072 PARAM_ENTRY( "@RetireWidth", m_retireWidth )
00073 PARAM_ENTRY( "@NoRetireLimit", m_noCommitLimit )
00074 PARAM_ENTRY( "@CommitLatency", m_commitLatency )
00075 PARAM_ENTRY( "@FixCommitLatency", m_fixCommitLatency )
00076
00077 BEGIN_PARAM_BINDING( "@CommittableStatus", m_committableStatus, OpStatus )
00078 PARAM_BINDING_ENTRY( "WRITTENBACK", OpStatus::OS_WRITTEN_BACK )
00079 PARAM_BINDING_ENTRY( "COMPLETED", OpStatus::OS_COMPLETED )
00080 END_PARAM_BINDING()
00081
00082 END_PARAM_PATH()
00083
00084 BEGIN_PARAM_PATH( GetResultPath() )
00085 PARAM_ENTRY( "@NumCommittedOps", m_numCommittedOps )
00086 PARAM_ENTRY( "@NumCommittedInsns", m_numCommittedInsns )
00087 PARAM_ENTRY( "@NumRetiredOps", m_numRetiredOps )
00088 PARAM_ENTRY( "@NumRetiredInsns", m_numRetiredInsns )
00089 PARAM_ENTRY( "@NumStorePortFullStalledCycles", m_numStorePortFullStalledCycles )
00090 END_PARAM_PATH()
00091
00092 END_PARAM_MAP()
00093
00094 BEGIN_RESOURCE_MAP()
00095 RESOURCE_ENTRY( Thread, "thread", m_thread )
00096 RESOURCE_ENTRY( Core, "core", m_core )
00097 RESOURCE_ENTRY( EmulatorIF, "emulator", m_emulator )
00098 RESOURCE_ENTRY( ForwardEmulator, "forwardEmulator", m_forwardEmulator )
00099 END_RESOURCE_MAP()
00100
00101
00102 Retirer();
00103 virtual ~Retirer();
00104
00105 virtual void Initialize(InitPhase phase);
00106
00107
00108 virtual void Evaluate();
00109 virtual void Transition();
00110 virtual void Update();
00111
00112
00113 bool IsEndOfProgram() const { return m_endOfProgram; }
00114 s64 GetNumRetiredOp() const { return m_numRetiredOps; }
00115 s64 GetNumRetiredInsns() const { return m_numRetiredInsns; }
00116
00117
00118
00119 void SetInitialNumRetiredOp( s64 numInsns, s64 numOp, s64 simulationEndInsns );
00120
00121
00122
00123
00124 void Retire( OpIterator op );
00125
00126
00127 void Flush( OpIterator op );
00128
00129
00130
00131
00132 typedef HookPoint<Retirer> CommitHookPoint;
00133 static CommitHookPoint s_commitHook;
00134
00135
00136
00137 typedef HookPoint<Retirer, CommitSteeringHookParam> CommitSteeringHookPoint;
00138 static CommitSteeringHookPoint s_commitSteeringHook;
00139
00140
00141
00142 typedef HookPoint<Retirer, CommitDecisionHookParam> CommitDecisionHookPoint;
00143 static CommitDecisionHookPoint s_commitDecisionHook;
00144
00145 typedef HookPoint<Retirer> RetireHookPoint;
00146 static RetireHookPoint s_retireHook;
00147
00148
00149 protected:
00150 typedef PipelineNodeBase BaseType;
00151
00152
00153 int m_commitWidth;
00154 int m_retireWidth;
00155 int m_noCommitLimit;
00156 int m_commitLatency;
00157 bool m_fixCommitLatency;
00158 OpStatus m_committableStatus;
00159
00160
00161 s64 m_numCommittedOps;
00162 s64 m_numCommittedInsns;
00163 s64 m_numRetiredOps;
00164 s64 m_numRetiredInsns;
00165
00166
00167 s64 m_numStorePortFullStalledCycles;
00168
00169 int m_noCommittedCycle;
00170 s64 m_numSimulationEndInsns;
00171
00172
00173 int m_currentRetireThread;
00174 bool m_endOfProgram;
00175
00176 EmulatorIF* m_emulator;
00177 ForwardEmulator* m_forwardEmulator;
00178
00179
00180
00181 typedef pool_list< OpIterator > CommitingOps;
00182 struct Evaluated
00183 {
00184 CommitingOps committing;
00185
00186 bool exceptionOccur;
00187 OpIterator exceptionCauser;
00188 bool evaluated;
00189 bool storePortFull;
00190
00191 void Reset();
00192 }
00193 m_evaluated;
00194
00195
00196
00197
00198
00199 bool CanCommitOp( OpIterator op );
00200
00201
00202 bool CanCommitInsn( OpIterator op );
00203
00204
00205 Thread* GetCommitableThread();
00206
00207 void Commit( OpIterator op );
00208 void EvaluateCommit();
00209 void UpdateCommit();
00210 void UpdateException();
00211
00212
00213 void CheckCommitCounters( int retiredOps, InorderList* inorderList );
00214
00215
00216 void FinishThread( Thread* tread );
00217
00218 };
00219
00220 };
00221
00222 #endif // SIM_PIPLINE_RETIRER_RETIRER_H
00223