Changeset 78 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Victim/Victim_Pseudo_LRU/include/Victim_Pseudo_LRU.h
- Timestamp:
- Mar 27, 2008, 11:04:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Victim/Victim_Pseudo_LRU/include/Victim_Pseudo_LRU.h
r75 r78 5 5 * $Id$ 6 6 * 7 * [ 7 * [ Description ] 8 8 * 9 9 */ … … 53 53 #endif 54 54 { 55 // -----[ internal class ]-------------------------------------------- 56 protected : class entry_t 57 { 58 // Numerotation of victim_pseudo_lru's tree 59 // Tree of Pseudo-LRU 60 // 61 // | d2 [3] | 62 // | 0_______|_______1 | 63 // | | | | 64 // | d1 [1] [5] | 65 // | 0___|___1 0___|___1 | 66 // | | | | | | 67 // | d0 [0] [2] [4] [6] | 68 // | 0_|_1 0_|_1 0_|_1 0_|_1 | 69 // | | | | | | | | | | 70 // | Way Way Way Way Way Way Way Way | 71 // | 0 1 2 3 4 5 6 7 | 72 // 73 // Access : Way N with N=2*n -> bit 2*n = 0 74 // with N=2*n+1 -> bit 2*n = 1 75 // 76 // if bit = B, depth = D, next_B = B+D if B==1 77 // = B-D if B==0 78 // 79 // Update : 55 // -----[ fields ]---------------------------------------------------- 56 // Parameters 57 protected : const std::string _name; 80 58 81 private : bool * _entry; 82 private : uint32_t _size; 83 84 public : entry_t () 85 { 86 }; 87 public : entry_t (uint32_t size) : _size (size) 88 { 89 _entry = new bool [size]; 90 91 // initialisation 92 for (uint32_t i=0; i<size; i++) 93 _entry [i] = false; 94 } 95 96 public : ~entry_t () 97 { 98 delete _entry; 99 } 100 101 private : uint32_t one_access (uint32_t index, uint32_t offset) 102 { 103 bool val = _entry[index]; 104 105 // Compute next slot 106 if (val == true) 107 return index + offset; 108 else 109 return index - offset; 110 } 111 112 public : uint32_t access () 113 { 114 uint32_t index = (_size>>1)-1; // medium 115 116 for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>= 1; i--) 117 { 118 index = one_access (index,(1<<(i-1))); 119 } 120 index = one_access (index,0); 121 122 // reverse by one_access make always a reverse 123 uint32_t offset = (_entry[index]==true)?1:0; 124 125 return index+offset; 126 } 127 128 private : uint32_t one_update (uint32_t index, uint32_t offset, uint32_t value) 129 { 130 uint32_t mask = (offset==0)?1:(offset<<1); 131 bool val = ((value & mask) != 0); 132 133 // reverse 134 _entry[index] = not val; 135 136 if (val == true) 137 // Compute next slot 138 return index + offset; 139 else 140 return index - offset; 141 } 142 public : void update (uint32_t value) 143 { 144 uint32_t index = (_size>>1)-1; // medium 145 146 for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>=1; i--) 147 { 148 index = one_update (index,1<<(i-1),value); 149 } 150 index = one_update (index,0,value); 151 } 152 153 public : std::string print () 154 { 155 std::string res = ""; 156 157 for (int32_t i=static_cast<int32_t>(_size)-1; i>=0; i--) 158 res += toString(_entry[i]) + " "; 159 160 return res; 161 } 162 163 }; 164 // -----[ fields ]---------------------------------------------------- 165 // Parameters 166 protected : const std::string _name; 167 168 protected : const Parameters _param; 59 protected : const Parameters * _param; 169 60 #ifdef STATISTICS 170 61 public : Stat * _stat; … … 175 66 176 67 #ifdef SYSTEMC 177 // ~~~~~[ 68 // ~~~~~[ Interface ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 178 69 // Interface 179 70 public : SC_CLOCK * in_CLOCK ; … … 184 75 public : SC_OUT(Tcontrol_t) ** out_ACCESS_ACK ; 185 76 public : SC_IN (Taddress_t) ** in_ACCESS_ADDRESS; 186 public : SC_OUT(Tentity_t ) ** out_ACCESS_ENTITY ; 187 // Interface update 188 public : SC_IN (Tcontrol_t) ** in_UPDATE_VAL ; 189 public : SC_OUT(Tcontrol_t) ** out_UPDATE_ACK ; 190 public : SC_IN (Taddress_t) ** in_UPDATE_ADDRESS; 191 public : SC_IN (Tentity_t ) ** in_UPDATE_ENTITY ; 77 public : SC_IN (Tcontrol_t) ** in_ACCESS_HIT ; // hit = 1 : update next_victim with in_entity else with out_victim 78 public : SC_IN (Tentity_t ) ** in_ACCESS_ENTITY ; 79 public : SC_OUT(Tentity_t ) ** out_ACCESS_VICTIM ; 192 80 193 81 // Interface update 194 // ~~~~~[ 82 // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 195 83 private : entry_t ** reg_TABLE; 196 84 197 // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 198 private : Tentity_t * internal_ACCESS_ENTITY; 85 // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 86 private : Tcontrol_t * internal_ACCESS_ACK ; 87 private : Tentity_t * internal_ACCESS_VICTIM; 199 88 #endif 200 89 201 // -----[ 90 // -----[ methods ]--------------------------------------------------- 202 91 203 92 #ifdef SYSTEMC … … 205 94 #endif 206 95 207 public : Victim_Pseudo_LRU ( 96 public : Victim_Pseudo_LRU 97 ( 208 98 #ifdef SYSTEMC 209 99 sc_module_name name, 210 100 #else 211 101 std::string name, 212 102 #endif 213 103 #ifdef STATISTICS 214 104 morpheo::behavioural::Parameters_Statistics * param_statistics, 215 105 #endif 216 Parametersparam );106 Parameters * param ); 217 107 218 108 public : Victim_Pseudo_LRU (Parameters param ); … … 224 114 225 115 public : void transition (void); 226 public : void genM ealy_access(void);116 public : void genMoore (void); 227 117 #endif 228 118
Note: See TracChangeset
for help on using the changeset viewer.