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_FORWARD_EMULATOR_H
00033 #define SIM_FORWARD_EMULATOR_H
00034
00035 #include "Types.h"
00036 #include "Interface/MemIF.h"
00037 #include "Interface/MemAccess.h"
00038
00039 #include "Sim/Foundation/Resource/ResourceNode.h"
00040 #include "Sim/System/ArchitectureState.h"
00041 #include "Sim/System/EmulationSystem/EmulationOp.h"
00042 #include "Sim/Op/OpArray/OpArray.h"
00043 #include "Sim/Memory/MemOrderManager/MemOrderOperations.h"
00044
00045 namespace Onikiri
00046 {
00047 class Thread;
00048
00049
00050
00051 class ForwardEmulator :
00052 public PhysicalResourceNode,
00053 public MemIF
00054 {
00055 public:
00056 ForwardEmulator();
00057 virtual ~ForwardEmulator();
00058
00059 void Initialize( InitPhase phase );
00060 void Finalize();
00061 void SetContext( const ArchitectureStateList& context );
00062
00063 void OnFetch( OpIterator op );
00064 void OnBranchPrediction( PC* predPC );
00065 void OnCommit( OpIterator op );
00066
00067
00068 const OpStateIF* GetExecutionResult( OpIterator op );
00069 const MemAccess* GetMemoryAccessResult( OpIterator op );
00070
00071
00072 bool IsInMissPredictedPath( OpIterator op );
00073
00074
00075
00076
00077 virtual void Read( MemAccess* access );
00078 virtual void Write( MemAccess* access );
00079
00080
00081 EmulatorIF* GetEmulator() const { return m_emulator; };
00082 bool IsEnabled() const { return m_enable; }
00083
00084
00085
00086
00087 BEGIN_PARAM_MAP("")
00088 BEGIN_PARAM_PATH( GetParamPath() )
00089 PARAM_ENTRY( "@Enable", m_enable );
00090 END_PARAM_PATH()
00091 BEGIN_PARAM_PATH( GetResultPath() )
00092 END_PARAM_PATH()
00093 END_PARAM_MAP()
00094
00095 BEGIN_RESOURCE_MAP()
00096 RESOURCE_ENTRY( EmulatorIF, "emulator", m_emulator )
00097 RESOURCE_ENTRY( Thread, "thread", m_threads )
00098 END_RESOURCE_MAP()
00099
00100
00101
00102 protected:
00103
00104 PhysicalResourceArray<Thread> m_threads;
00105 EmulatorIF* m_emulator;
00106 ArchitectureStateList m_context;
00107 MemOrderOperations m_memOperations;
00108
00109
00110 struct ThreadContext
00111 {
00112
00113
00114 u64 nextFixedRetireID;
00115 PC nextFixedPC;
00116
00117 ThreadContext() :
00118 nextFixedRetireID(0)
00119 {
00120 }
00121 };
00122
00123 struct InflightOp
00124 {
00125 EmulationOp emuOp;
00126 OpIterator simOp;
00127 MemAccess memAccess;
00128 u64 retireId;
00129 bool updatePC;
00130 bool updateMicroOpIndex;
00131 bool isStore;
00132
00133 InflightOp() :
00134 retireId( 0 ),
00135 updatePC( 0 ),
00136 updateMicroOpIndex( 0 ),
00137 isStore( false )
00138 {
00139 }
00140 };
00141
00142 typedef pool_list< InflightOp > InflightOpList;
00143 std::vector< InflightOpList > m_inflightOps;
00144 std::vector< ThreadContext > m_threadContext;
00145
00146 bool m_enable;
00147 static const s64 MAX_RID_DIFFERENCE = 1024;
00148
00149
00150 void UpdateArchContext(
00151 ArchitectureState* context,
00152 OpStateIF* state,
00153 OpInfo* info,
00154 bool updatePC,
00155 bool updateMicroOpIndex
00156 );
00157
00158
00159 InflightOp* GetInflightOp( OpIterator op, bool reverse = true );
00160
00161 InflightOp* GetProducerStore( const InflightOp& consumerLoad );
00162
00163
00164 PC GetExecutedNextPC( PC current, OpStateIF* state ) const;
00165
00166
00167 void UpdateFixedPath( OpIterator simOp );
00168 };
00169
00170 };
00171
00172 #endif // SIM_FORWARD_EMULATOR_H
00173