Changeset 78 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Victim/Victim_Pseudo_LRU/include/Types.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/Types.h
r75 r78 9 9 */ 10 10 11 #include "Behavioural/ include/Types.h"11 #include "Behavioural/Generic/Victim/include/Types.h" 12 12 13 13 namespace morpheo { … … 17 17 namespace victim_pseudo_lru { 18 18 19 typedef uint32_t Taddress_t; 20 typedef uint32_t Tentity_t; 19 class entry_t 20 { 21 // Numerotation of victim_pseudo_lru's tree 22 // Tree of Pseudo-LRU 23 // 24 // | d2 [3] | 25 // | 0_______|_______1 | 26 // | | | | 27 // | d1 [1] [5] | 28 // | 0___|___1 0___|___1 | 29 // | | | | | | 30 // | d0 [0] [2] [4] [6] | 31 // | 0_|_1 0_|_1 0_|_1 0_|_1 | 32 // | | | | | | | | | | 33 // | Way Way Way Way Way Way Way Way | 34 // | 0 1 2 3 4 5 6 7 | 35 // 36 // Access : Way N with N=2*n -> bit 2*n = 0 37 // with N=2*n+1 -> bit 2*n = 1 38 // 39 // if bit = B, depth = D, next_B = B+D if B==1 40 // = B-D if B==0 41 // 42 // Update : 43 44 private : bool * _entry; 45 private : uint32_t _size; 46 47 public : entry_t () 48 { 49 }; 50 public : entry_t (uint32_t size) : _size (size) 51 { 52 _entry = new bool [size]; 53 54 // initialisation 55 for (uint32_t i=0; i<size; i++) 56 _entry [i] = false; 57 } 58 59 public : ~entry_t () 60 { 61 delete _entry; 62 } 63 64 private : uint32_t one_access (uint32_t index, uint32_t offset) 65 { 66 bool val = _entry[index]; 67 68 // Compute next slot 69 if (val == true) 70 return index + offset; 71 else 72 return index - offset; 73 } 74 75 public : uint32_t access () 76 { 77 uint32_t index = (_size>>1)-1; // middle 78 79 for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>= 1; i--) 80 { 81 index = one_access (index,(1<<(i-1))); 82 } 83 index = one_access (index,0); 84 85 // reverse by one_access make always a reverse 86 uint32_t offset = (_entry[index]==true)?1:0; 87 88 return index+offset; 89 } 90 91 private : uint32_t one_update (uint32_t index, uint32_t offset, uint32_t value) 92 { 93 uint32_t mask = (offset==0)?1:(offset<<1); 94 bool val = ((value & mask) != 0); 95 96 // reverse 97 _entry[index] = not val; 98 99 if (val == true) 100 // Compute next slot 101 return index + offset; 102 else 103 return index - offset; 104 } 105 public : void update (uint32_t value) 106 { 107 uint32_t index = (_size>>1)-1; // middle 108 109 for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>=1; i--) 110 { 111 index = one_update (index,1<<(i-1),value); 112 } 113 index = one_update (index,0,value); 114 } 115 116 public : std::string print () 117 { 118 std::string res = ""; 119 120 for (int32_t i=static_cast<int32_t>(_size)-1; i>=0; i--) 121 res += toString(_entry[i]) + " "; 122 123 return res; 124 } 125 }; 21 126 22 127 }; // end namespace victim_pseudo_lru
Note: See TracChangeset
for help on using the changeset viewer.