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
00033
00034
00035
00036
00037
00038 #ifndef SAMPLES_SAMPLE_BPRED_H
00039 #define SAMPLES_SAMPLE_BPRED_H
00040
00041
00042
00043
00044
00045
00046 #include "Sim/Foundation/Resource/ResourceNode.h"
00047 #include "Sim/Predictor/BPred/DirPredIF.h"
00048
00049
00050 namespace Onikiri
00051 {
00052 class Core;
00053
00054 class SampleAlwaysHitBrDirPredictor :
00055 public PhysicalResourceNode,
00056 public DirPredIF
00057 {
00058 public:
00059
00060 SampleAlwaysHitBrDirPredictor() :
00061 m_enableCount( false ),
00062 m_numPredicted( 0 ),
00063 m_core( 0 )
00064 {
00065 }
00066
00067 virtual ~SampleAlwaysHitBrDirPredictor()
00068 {
00069 }
00070
00071
00072
00073
00074
00075 virtual void Initialize( InitPhase phase )
00076 {
00077 if( phase == INIT_PRE_CONNECTION ){
00078
00079
00080
00081 LoadParam();
00082
00083 }
00084 else if ( phase == INIT_POST_CONNECTION ){
00085
00086
00087 if( m_core == NULL ){
00088 THROW_RUNTIME_ERROR( "'m_core' is not connected correctly." );
00089 }
00090
00091 }
00092 }
00093 virtual void Finalize()
00094 {
00095 ReleaseParam();
00096 }
00097
00098
00099
00100 BEGIN_PARAM_MAP("")
00101 BEGIN_PARAM_PATH( GetParamPath() )
00102 PARAM_ENTRY( "@EnableCount", m_enableCount )
00103 END_PARAM_PATH()
00104 BEGIN_PARAM_PATH( GetResultPath() )
00105 PARAM_ENTRY( "@NumPredicted", m_numPredicted )
00106 END_PARAM_PATH()
00107 END_PARAM_MAP()
00108
00109 BEGIN_RESOURCE_MAP()
00110 RESOURCE_ENTRY( Core, "core", m_core )
00111 END_RESOURCE_MAP()
00112
00113
00114
00115
00116 virtual bool Predict( OpIterator op, PC pc )
00117 {
00118 if( m_enableCount ){
00119 m_numPredicted++;
00120 }
00121
00122 return true;
00123 }
00124 virtual void Finished( OpIterator op ){}
00125 virtual void Retired( OpIterator op ){}
00126
00127
00128
00129 private:
00130 bool m_enableCount;
00131 s64 m_numPredicted;
00132 Core* m_core;
00133 };
00134
00135
00136 #ifdef USE_SAMPLE_BPRED
00137
00138
00139
00140
00141
00142
00143 static const char g_sampleBPredDefaultParam[] = " \n\
00144 \n\
00145 <?xml version='1.0' encoding='UTF-8'?> \n\
00146 <Session> \n\
00147 \n\
00148 <Simulator> \n\
00149 <Configurations> \n\
00150 <DefaultConfiguration> \n\
00151 \n\
00152 <Structure> \n\
00153 <Copy> \n\
00154 \n\
00155 <SampleAlwaysHitBrDirPredictor \n\
00156 Count = 'CoreCount' \n\
00157 Name = 'sampleBPred' \n\
00158 > \n\
00159 <Core Name = 'core' /> \n\
00160 </SampleAlwaysHitBrDirPredictor> \n\
00161 \n\
00162 <BPred Name = 'bPred'> \n\
00163 <Connection Name='sampleBPred' To='dirPred'/> \n\
00164 </BPred> \n\
00165 \n\
00166 </Copy> \n\
00167 </Structure> \n\
00168 \n\
00169 <Parameter> \n\
00170 \n\
00171 <SampleAlwaysHitBrDirPredictor \n\
00172 EnableCount = '1' \n\
00173 Name = 'sampleBPred' \n\
00174 > \n\
00175 </SampleAlwaysHitBrDirPredictor> \n\
00176 \n\
00177 </Parameter> \n\
00178 </DefaultConfiguration> \n\
00179 </Configurations> \n\
00180 </Simulator> \n\
00181 \n\
00182 </Session> \n\
00183 \n\
00184 \n\
00185 ";
00186 #endif // #ifdef USE_SAMPLE_BPRED
00187
00188 }
00189
00190
00191 #endif// #ifndef SAMPLES_SAMPLE_BPRED_H