src/Sim/Predictor/BPred/BPred.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_PREDICTOR_BPRED_BPRED_H
00033 #define SIM_PREDICTOR_BPRED_BPRED_H
00034 
00035 #include "Sim/Foundation/Resource/ResourceNode.h"
00036 #include "Env/Param/ParamExchange.h"
00037 
00038 #include "Interface/Addr.h"
00039 
00040 #include "Sim/Op/OpArray/OpArray.h"
00041 #include "Sim/Op/OpContainer/OpExtraStateTable.h"
00042 #include "Sim/Predictor/BPred/BTB.h"
00043 #include "Sim/Foundation/Hook/HookDecl.h"
00044 
00045 
00046 namespace Onikiri
00047 {
00048     class Core;
00049     class Thread;
00050     class DirPredIF;
00051     class GlobalHistory;
00052     class RAS;
00053     class ForwardEmulator;
00054 
00055     // \SSNX
00056     // FetchernextPC
00057     class BPred : public PhysicalResourceNode
00058     {
00059     public:
00060 
00061         BEGIN_PARAM_MAP( "" )
00062             BEGIN_PARAM_PATH( GetParamPath() )
00063                 PARAM_ENTRY( "@Perfect", m_perfect )
00064             END_PARAM_PATH()
00065             BEGIN_PARAM_PATH( GetResultPath() )
00066                 CHAIN_PARAM_MAP( "Statistics", m_totalStatistics )
00067                 CHAIN_PARAM_MAP( "Statistics/Entry", m_statistics )
00068             END_PARAM_PATH()
00069         END_PARAM_MAP()
00070 
00071         BEGIN_RESOURCE_MAP()
00072             RESOURCE_ENTRY( Core, "core", m_core )
00073             RESOURCE_ENTRY( BTB,  "btb",  m_btb )
00074             RESOURCE_ENTRY( RAS,  "ras",  m_ras )
00075             RESOURCE_ENTRY( DirPredIF, "dirPred", m_dirPred )
00076             RESOURCE_ENTRY( ForwardEmulator, "forwardEmulator", m_fwdEmulator )
00077         END_RESOURCE_MAP()
00078 
00079         BPred();
00080         virtual ~BPred();
00081 
00082         void Initialize( InitPhase phase );
00083 
00084         // op\sC\
00085         //   predIndexPC : \pPCDFetch GroupPC
00086         PC Predict( OpIterator op, PC predIndexPC );
00087         void Finished( OpIterator op );
00088         void Commit( OpIterator op );
00089 
00090         // Is in a perfect prediction mode or not.
00091         bool IsPerfect() const { return m_perfect; }
00092 
00093         // --- PhysicalResourceNode
00094         virtual void ChangeSimulationMode( SimulationMode mode ){ m_mode = mode; };
00095 
00096         static HookPoint<BPred> s_branchPredictionMissHook;
00097 
00098     protected:
00099 
00100         DirPredIF*                  m_dirPred;      // \
00101         BTB*                        m_btb;          // BTB
00102         PhysicalResourceArray<RAS>  m_ras;          // RAS
00103         Core*                       m_core;
00104         ForwardEmulator*            m_fwdEmulator;
00105         
00106         // Simulation mode.
00107         SimulationMode m_mode;
00108         
00109         // Enable perfect branch prediction.
00110         bool m_perfect; 
00111 
00112         OpExtraStateTable<BTBPredict> m_btbPredTable;
00113 
00114         // Result
00115         struct Statistics : public ParamExchangeChild
00116         {
00117         public:
00118         
00119             BEGIN_PARAM_MAP("")
00120                 PARAM_ENTRY("@Name",        name)
00121                 PARAM_ENTRY("@NumHit",      numHit)
00122                 PARAM_ENTRY("@NumMiss",     numMiss)
00123                 RESULT_RATE_SUM_ENTRY("@HitRate", numHit, numHit, numMiss)
00124             END_PARAM_MAP()
00125 
00126             Statistics();
00127             void SetName( const String& name );
00128 
00129             String name;
00130             u64 numHit;
00131             u64 numMiss;
00132         };
00133 
00134         std::vector<Statistics> m_statistics;
00135         Statistics m_totalStatistics;
00136 
00137         // Detect branch miss prediction and recovery if prediction is incorrect.
00138         void RecoveryFromBPredMiss( OpIterator branch );
00139     };
00140 
00141 }; // namespace Onikiri
00142 
00143 #endif // SIM_PREDICTOR_BPRED_BPRED_H
00144 
00145 

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