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
00039 #ifndef SAMPLES_SAMPLE_PREFETCHER_H
00040 #define SAMPLES_SAMPLE_PREFETCHER_H
00041
00042
00043
00044
00045
00046
00047 #include "Sim/Foundation/Resource/ResourceNode.h"
00048 #include "Sim/Memory/Prefetcher/PrefetcherBase.h"
00049
00050
00051 namespace Onikiri
00052 {
00053 class Core;
00054
00055
00056
00057 class SamplePrefetcher : public PrefetcherBase
00058 {
00059 public:
00060
00061 SamplePrefetcher()
00062 {
00063 }
00064 virtual ~SamplePrefetcher()
00065 {
00066 }
00067
00068
00069
00070
00071
00072 virtual void Initialize( InitPhase phase )
00073 {
00074
00075 PrefetcherBase::Initialize( 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
00088 virtual void Finalize()
00089 {
00090 ReleaseParam();
00091
00092
00093 PrefetcherBase::Finalize();
00094 }
00095
00096 virtual void OnCacheAccess( Cache* cache, const CacheAccess& access, bool hit )
00097 {
00098
00099 if( !hit ){
00100 CacheAccess prefetch = access;
00101
00102
00103
00104
00105
00106 prefetch.type = CacheAccess::OT_PREFETCH;
00107 prefetch.address.address += PrefetcherBase::m_lineSize;
00108
00109
00110 Prefetch( prefetch );
00111 }
00112 }
00113
00114
00115
00116 BEGIN_PARAM_MAP("")
00117 BEGIN_PARAM_PATH( GetParamPath() )
00118 END_PARAM_PATH()
00119 BEGIN_PARAM_PATH( GetResultPath() )
00120 END_PARAM_PATH()
00121
00122
00123 CHAIN_BASE_PARAM_MAP( PrefetcherBase )
00124 END_PARAM_MAP()
00125
00126 BEGIN_RESOURCE_MAP()
00127
00128 CHAIN_BASE_RESOURCE_MAP( PrefetcherBase )
00129 END_RESOURCE_MAP()
00130
00131 };
00132
00133
00134
00135
00136
00137
00138 #ifdef USE_SAMPLE_PREFETCHER
00139
00140 static char g_samplePrefetcherParam[] = " \n\
00141 \n\
00142 <?xml version='1.0' encoding='UTF-8'?> \n\
00143 <Session> \n\
00144 \n\
00145 <Simulator> \n\
00146 <Configurations> \n\
00147 <DefaultConfiguration> \n\
00148 \n\
00149 <Structure> \n\
00150 <Copy> \n\
00151 \n\
00152 <SamplePrefetcher \n\
00153 Count = 'CoreCount' \n\
00154 Name = 'samplePrefetcher' \n\
00155 > \n\
00156 <Connection \n\
00157 Name = 'cacheL2' \n\
00158 To = 'target' \n\
00159 /> \n\
00160 </SamplePrefetcher> \n\
00161 \n\
00162 <Cache Name = 'cacheL1D' /> \n\
00163 <Cache Name = 'cacheL1I' /> \n\
00164 <Cache Name = 'cacheL2' > \n\
00165 <Connection \n\
00166 Name = 'samplePrefetcher' \n\
00167 To = 'prefetcher' \n\
00168 /> \n\
00169 </Cache> \n\
00170 \n\
00171 \n\
00172 </Copy> \n\
00173 </Structure> \n\
00174 \n\
00175 <Parameter> \n\
00176 \n\
00177 <SamplePrefetcher \n\
00178 EnablePrefetch = '1' \n\
00179 OffsetBitSize = '6' \n\
00180 Name = 'samplePrefetcher' \n\
00181 > \n\
00182 </SamplePrefetcher> \n\
00183 \n\
00184 </Parameter> \n\
00185 </DefaultConfiguration> \n\
00186 </Configurations> \n\
00187 </Simulator> \n\
00188 \n\
00189 </Session> \n\
00190 \n\
00191 \n\
00192 ";
00193
00194 #endif // #ifdef USE_SAMPLE_PREFETCHER
00195
00196
00197 }
00198
00199
00200 #endif