src/Sim/System/ForwardEmulator.h

説明を見る。
00001 // 
00002 // Copyright (c) 2005-2008 Kenichi Watanabe.
00003 // Copyright (c) 2005-2008 Yasuhiro Watari.
00004 // Copyright (c) 2005-2008 Hironori Ichibayashi.
00005 // Copyright (c) 2008-2009 Kazuo Horio.
00006 // Copyright (c) 2009-2013 Naruki Kurata.
00007 // Copyright (c) 2005-2013 Ryota Shioya.
00008 // Copyright (c) 2005-2013 Masahiro Goshima.
00009 // 
00010 // This software is provided 'as-is', without any express or implied
00011 // warranty. In no event will the authors be held liable for any damages
00012 // arising from the use of this software.
00013 // 
00014 // Permission is granted to anyone to use this software for any purpose,
00015 // including commercial applications, and to alter it and redistribute it
00016 // freely, subject to the following restrictions:
00017 // 
00018 // 1. The origin of this software must not be misrepresented; you must not
00019 // claim that you wrote the original software. If you use this software
00020 // in a product, an acknowledgment in the product documentation would be
00021 // appreciated but is not required.
00022 // 
00023 // 2. Altered source versions must be plainly marked as such, and must not be
00024 // misrepresented as being the original software.
00025 // 
00026 // 3. This notice may not be removed or altered from any source
00027 // distribution.
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     // An emulator that executes ops on instruction fetch.
00050     // Execution is done in-order and results are used for validation.
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         // Get a pre-executed result corresponding to 'op'.
00068         const OpStateIF* GetExecutionResult( OpIterator op );
00069         const MemAccess* GetMemoryAccessResult( OpIterator op );
00070 
00071         // Returns whether 'op' is in miss predicted path or not.
00072         bool IsInMissPredictedPath( OpIterator op );
00073 
00074         //
00075         // MemIF
00076         //
00077         virtual void Read( MemAccess* access );
00078         virtual void Write( MemAccess* access );
00079 
00080         // Accessors
00081         EmulatorIF* GetEmulator() const { return m_emulator; };
00082         bool IsEnabled() const { return m_enable; }
00083 
00084         //
00085         // PhysicalResouceNode
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         // Additional contexts for a forward emulator.
00110         struct ThreadContext
00111         {
00112             // Branch prediction is correctly done to these retirement id/PC.
00113             // These are used for detecting whether an op is in miss predicted path or not.
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         // Update architecture state.
00150         void UpdateArchContext( 
00151             ArchitectureState* context, 
00152             OpStateIF* state, 
00153             OpInfo* info, 
00154             bool updatePC, 
00155             bool updateMicroOpIndex
00156         );
00157 
00158         // When 'reverse' is true, an in-flight op is searched from the back of 'inflightOps'.
00159         InflightOp* GetInflightOp( OpIterator op, bool reverse = true );
00160 
00161         InflightOp* GetProducerStore( const InflightOp& consumerLoad );
00162 
00163         // Calculate a next PC from the executed state of an op.
00164         PC GetExecutedNextPC( PC current, OpStateIF* state ) const;
00165 
00166         // Update fixed pc/retirement id with execution results.
00167         void UpdateFixedPath( OpIterator simOp );
00168     };
00169 
00170 }; // namespace Onikiri
00171 
00172 #endif // SIM_FORWARD_EMULATOR_H
00173 

Onikiri2に対してTue Jun 18 14:34:26 2013に生成されました。  doxygen 1.4.7