[57] | 1 | #ifndef morpheo_behavioural_Types_h |
---|
| 2 | #define morpheo_behavioural_Types_h |
---|
| 3 | |
---|
| 4 | #include "Common/include/Types.h" |
---|
[77] | 5 | #include "Common/include/ToString.h" |
---|
[78] | 6 | #include "Common/include/FromString.h" |
---|
| 7 | #include "Common/include/ErrorMorpheo.h" |
---|
[59] | 8 | #include "Behavioural/include/Constants.h" |
---|
[57] | 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | |
---|
[59] | 13 | //============================================ |
---|
| 14 | // Type definition |
---|
| 15 | //============================================ |
---|
| 16 | |
---|
| 17 | // ***** general |
---|
[81] | 18 | typedef uint32_t Tinstruction_t; |
---|
| 19 | typedef bool Tcontrol_t; |
---|
| 20 | typedef uint8_t Texception_t; |
---|
| 21 | typedef uint8_t Tcontext_t; |
---|
| 22 | typedef uint8_t Tpacket_t; |
---|
| 23 | typedef uint8_t Toperation_t; |
---|
| 24 | typedef uint8_t Ttype_t; |
---|
| 25 | typedef uint8_t Tcounter_t; // universal counter |
---|
| 26 | typedef uint8_t Tptr_t; // universal pointer |
---|
| 27 | |
---|
| 28 | //typedef uint32_t Tdestination1_t; |
---|
| 29 | //typedef uint32_t Tdestination2_t; |
---|
| 30 | //typedef uint32_t Texec_flag_t; |
---|
| 31 | //typedef bool Texec_excep_t; |
---|
| 32 | |
---|
| 33 | // ***** Event |
---|
| 34 | typedef uint8_t Tevent_state_t; |
---|
| 35 | typedef uint8_t Tevent_type_t; |
---|
| 36 | |
---|
| 37 | // ***** Register |
---|
| 38 | typedef uint32_t Tgeneral_address_t; |
---|
| 39 | typedef uint32_t Tgeneral_data_t; |
---|
| 40 | typedef uint32_t Tspecial_address_t; |
---|
| 41 | typedef uint32_t Tspecial_data_t; |
---|
| 42 | |
---|
| 43 | // ~~~~~ prediction_unit |
---|
| 44 | typedef uint8_t Thistory_t; |
---|
| 45 | typedef Tptr_t Tprediction_ptr_t; |
---|
| 46 | typedef uint8_t Tbranch_state_t; |
---|
| 47 | typedef uint8_t Tbranch_condition_t; |
---|
| 48 | typedef Tprediction_ptr_t Tdepth_t; |
---|
| 49 | typedef Tgeneral_data_t Taddress_t; |
---|
[57] | 50 | |
---|
[78] | 51 | // ***** component dependant |
---|
| 52 | // ~~~~~ load store queue |
---|
[81] | 53 | typedef uint8_t Taccess_t; |
---|
| 54 | typedef Tptr_t Tlsq_ptr_t; |
---|
| 55 | typedef Tgeneral_address_t Tdcache_address_t; |
---|
| 56 | typedef Tgeneral_data_t Tdcache_data_t; |
---|
| 57 | typedef bool Tdcache_error_t; |
---|
| 58 | typedef uint8_t Tdcache_type_t; |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | // ~~~~~ ifetch |
---|
| 62 | typedef Tptr_t Tinst_ifetch_ptr_t; |
---|
| 63 | typedef Tptr_t Tifetch_queue_ptr_t; |
---|
| 64 | typedef Tgeneral_address_t Ticache_address_t; |
---|
| 65 | typedef Tgeneral_data_t Ticache_instruction_t; |
---|
| 66 | typedef bool Ticache_error_t; |
---|
| 67 | typedef uint8_t Ticache_type_t; |
---|
[57] | 68 | |
---|
[78] | 69 | typedef enum |
---|
| 70 | { |
---|
| 71 | PRIORITY_STATIC, |
---|
| 72 | PRIORITY_ROUND_ROBIN |
---|
| 73 | } Tpriority_t; |
---|
| 74 | |
---|
| 75 | typedef enum |
---|
| 76 | { |
---|
| 77 | LOAD_BALANCING_BALANCE, |
---|
| 78 | LOAD_BALANCING_MAXIMUM_FOR_PRIORITY |
---|
| 79 | } Tload_balancing_t; |
---|
| 80 | |
---|
| 81 | typedef enum |
---|
| 82 | { |
---|
| 83 | VICTIM_RANDOM , // Random |
---|
| 84 | VICTIM_ROUND_ROBIN, // Round Robin |
---|
| 85 | VICTIM_NLU , // Not Last Used |
---|
| 86 | VICTIM_PSEUDO_LRU , // Pseudo Least Recently Used |
---|
| 87 | VICTIM_LRU , // Least Recently Used |
---|
| 88 | VICTIM_FIFO // First IN First OUT |
---|
| 89 | } Tvictim_t; |
---|
| 90 | |
---|
| 91 | typedef enum |
---|
| 92 | { |
---|
| 93 | PREDICTOR_NEVER_TAKE , // Branch is never Take |
---|
| 94 | PREDICTOR_ALWAYS_TAKE , // Branch is always Take |
---|
| 95 | PREDICTOR_STATIC , // If the adress of destination is previous, then the branch is take |
---|
| 96 | PREDICTOR_LAST_TAKE , // The direction is as the last time (if is the first time : static) |
---|
| 97 | PREDICTOR_COUNTER , // Counter table |
---|
| 98 | PREDICTOR_LOCAL , // Counter bank indexed with history bank |
---|
| 99 | PREDICTOR_GLOBAL , // Counter bank indexed with history table |
---|
| 100 | PREDICTOR_META , // A meta_predictor choose between 2 predictor : the local or the global |
---|
| 101 | PREDICTOR_CUSTOM // Note predefined scheme |
---|
| 102 | } Tpredictor_t; |
---|
| 103 | |
---|
[72] | 104 | //----------------------------------------------[ spr_mode_access ]----- |
---|
| 105 | class spr_access_mode_t |
---|
| 106 | { |
---|
| 107 | public : uint8_t _user_access_mode ; |
---|
| 108 | public : uint8_t _supervisor_access_mode; |
---|
| 109 | |
---|
| 110 | public : spr_access_mode_t (uint32_t user_access_mode = SPR_ACCESS_MODE_NONE, |
---|
| 111 | uint32_t supervisor_access_mode = SPR_ACCESS_MODE_NONE) |
---|
| 112 | { |
---|
| 113 | _user_access_mode = user_access_mode ; |
---|
| 114 | _supervisor_access_mode = supervisor_access_mode; |
---|
| 115 | } |
---|
| 116 | }; |
---|
| 117 | |
---|
[57] | 118 | }; // end namespace behavioural |
---|
[77] | 119 | |
---|
| 120 | inline std::string toString_type(const morpheo::behavioural::Ttype_t& x) |
---|
| 121 | { |
---|
| 122 | switch (x) |
---|
| 123 | { |
---|
| 124 | case TYPE_ALU : return "ALU" ; break; |
---|
| 125 | case TYPE_SHIFT : return "SHIFT" ; break; |
---|
| 126 | case TYPE_MOVE : return "MOVE" ; break; |
---|
| 127 | case TYPE_TEST : return "TEST" ; break; |
---|
| 128 | case TYPE_MUL_DIV : return "MUL_DIV"; break; |
---|
| 129 | case TYPE_EXTEND : return "EXTEND" ; break; |
---|
| 130 | case TYPE_FIND : return "FIND" ; break; |
---|
| 131 | case TYPE_SPECIAL : return "SPECIAL"; break; |
---|
| 132 | case TYPE_CUSTOM : return "CUSTOM" ; break; |
---|
| 133 | case TYPE_BRANCH : return "BRANCH" ; break; |
---|
| 134 | case TYPE_MEMORY : return "MEMORY" ; break; |
---|
| 135 | default : return "" ; break; |
---|
| 136 | } |
---|
| 137 | }; |
---|
| 138 | |
---|
[78] | 139 | template<> inline std::string toString<morpheo::behavioural::Tpriority_t>(const morpheo::behavioural::Tpriority_t& x) |
---|
| 140 | { |
---|
| 141 | switch (x) |
---|
| 142 | { |
---|
| 143 | case morpheo::behavioural::PRIORITY_STATIC : return "priority_static"; break; |
---|
| 144 | case morpheo::behavioural::PRIORITY_ROUND_ROBIN : return "priority_round_robin"; break; |
---|
| 145 | default : return "" ; break; |
---|
| 146 | } |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | template<> inline morpheo::behavioural::Tpriority_t fromString<morpheo::behavioural::Tpriority_t>(const std::string& x) |
---|
| 150 | { |
---|
| 151 | if ( (x.compare("0") == 0) or |
---|
| 152 | (x.compare("priority_static") == 0)) |
---|
| 153 | return morpheo::behavioural::PRIORITY_STATIC; |
---|
| 154 | if ( (x.compare("1") == 0) or |
---|
| 155 | (x.compare("priority_round_robin") == 0)) |
---|
| 156 | return morpheo::behavioural::PRIORITY_ROUND_ROBIN; |
---|
| 157 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
| 158 | }; |
---|
| 159 | |
---|
| 160 | template<> inline std::string toString<morpheo::behavioural::Tload_balancing_t>(const morpheo::behavioural::Tload_balancing_t& x) |
---|
| 161 | { |
---|
| 162 | switch (x) |
---|
| 163 | { |
---|
| 164 | case morpheo::behavioural::LOAD_BALANCING_BALANCE : return "load_balancing_balance"; break; |
---|
| 165 | case morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY : return "load_balancing_maximum_for_priority"; break; |
---|
| 166 | default : return "" ; break; |
---|
| 167 | } |
---|
| 168 | }; |
---|
| 169 | |
---|
| 170 | template<> inline morpheo::behavioural::Tload_balancing_t fromString<morpheo::behavioural::Tload_balancing_t>(const std::string& x) |
---|
| 171 | { |
---|
| 172 | if ( (x.compare("0") == 0) or |
---|
| 173 | (x.compare("load_balancing_balance") == 0)) |
---|
| 174 | return morpheo::behavioural::LOAD_BALANCING_BALANCE; |
---|
| 175 | if ( (x.compare("1") == 0) or |
---|
| 176 | (x.compare("load_balancing_maximum_for_priority") == 0)) |
---|
| 177 | return morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY; |
---|
| 178 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
| 179 | }; |
---|
| 180 | |
---|
| 181 | template<> inline std::string toString<morpheo::behavioural::Tvictim_t>(const morpheo::behavioural::Tvictim_t& x) |
---|
| 182 | { |
---|
| 183 | switch (x) |
---|
| 184 | { |
---|
| 185 | case morpheo::behavioural::VICTIM_RANDOM : return "victim_random" ; break; |
---|
| 186 | case morpheo::behavioural::VICTIM_ROUND_ROBIN : return "victim_round_robin"; break; |
---|
| 187 | case morpheo::behavioural::VICTIM_NLU : return "victim_nlu" ; break; |
---|
| 188 | case morpheo::behavioural::VICTIM_PSEUDO_LRU : return "victim_pseudo_lru" ; break; |
---|
| 189 | case morpheo::behavioural::VICTIM_LRU : return "victim_lru" ; break; |
---|
| 190 | case morpheo::behavioural::VICTIM_FIFO : return "victim_fifo" ; break; |
---|
| 191 | default : return "" ; break; |
---|
| 192 | } |
---|
| 193 | }; |
---|
| 194 | |
---|
| 195 | template<> inline morpheo::behavioural::Tvictim_t fromString<morpheo::behavioural::Tvictim_t>(const std::string& x) |
---|
| 196 | { |
---|
| 197 | if ( (x.compare("0") == 0) or |
---|
| 198 | (x.compare("victim_random") == 0)) |
---|
| 199 | return morpheo::behavioural::VICTIM_RANDOM; |
---|
| 200 | if ( (x.compare("1") == 0) or |
---|
| 201 | (x.compare("victim_round_robin") == 0)) |
---|
| 202 | return morpheo::behavioural::VICTIM_ROUND_ROBIN; |
---|
| 203 | if ( (x.compare("2") == 0) or |
---|
| 204 | (x.compare("victim_nlu") == 0)) |
---|
| 205 | return morpheo::behavioural::VICTIM_NLU; |
---|
| 206 | if ( (x.compare("3") == 0) or |
---|
| 207 | (x.compare("victim_pseudo_lru") == 0)) |
---|
| 208 | return morpheo::behavioural::VICTIM_PSEUDO_LRU; |
---|
| 209 | if ( (x.compare("4") == 0) or |
---|
| 210 | (x.compare("victim_lru") == 0)) |
---|
| 211 | return morpheo::behavioural::VICTIM_LRU; |
---|
| 212 | if ( (x.compare("5") == 0) or |
---|
| 213 | (x.compare("victim_fifo") == 0)) |
---|
| 214 | return morpheo::behavioural::VICTIM_FIFO; |
---|
| 215 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
| 216 | }; |
---|
| 217 | |
---|
| 218 | template<> inline std::string toString<morpheo::behavioural::Tpredictor_t>(const morpheo::behavioural::Tpredictor_t& x) |
---|
| 219 | { |
---|
| 220 | switch (x) |
---|
| 221 | { |
---|
| 222 | case morpheo::behavioural::PREDICTOR_NEVER_TAKE : return "predictor_never_take" ; break; |
---|
| 223 | case morpheo::behavioural::PREDICTOR_ALWAYS_TAKE : return "predictor_always_take"; break; |
---|
| 224 | case morpheo::behavioural::PREDICTOR_STATIC : return "predictor_static" ; break; |
---|
| 225 | case morpheo::behavioural::PREDICTOR_LAST_TAKE : return "predictor_last_take" ; break; |
---|
| 226 | case morpheo::behavioural::PREDICTOR_COUNTER : return "predictor_counter" ; break; |
---|
| 227 | case morpheo::behavioural::PREDICTOR_LOCAL : return "predictor_local" ; break; |
---|
| 228 | case morpheo::behavioural::PREDICTOR_GLOBAL : return "predictor_global" ; break; |
---|
| 229 | case morpheo::behavioural::PREDICTOR_META : return "predictor_meta" ; break; |
---|
| 230 | case morpheo::behavioural::PREDICTOR_CUSTOM : return "predictor_custom" ; break; |
---|
| 231 | default : return "" ; break; |
---|
| 232 | } |
---|
| 233 | }; |
---|
| 234 | |
---|
| 235 | template<> inline morpheo::behavioural::Tpredictor_t fromString<morpheo::behavioural::Tpredictor_t>(const std::string& x) |
---|
| 236 | { |
---|
| 237 | if ( (x.compare("0") == 0) or |
---|
| 238 | (x.compare("predictor_never_take") == 0)) |
---|
| 239 | return morpheo::behavioural::PREDICTOR_NEVER_TAKE; |
---|
| 240 | if ( (x.compare("1") == 0) or |
---|
| 241 | (x.compare("predictor_always_take") == 0)) |
---|
| 242 | return morpheo::behavioural::PREDICTOR_ALWAYS_TAKE; |
---|
| 243 | if ( (x.compare("2") == 0) or |
---|
| 244 | (x.compare("predictor_static") == 0)) |
---|
| 245 | return morpheo::behavioural::PREDICTOR_STATIC; |
---|
| 246 | if ( (x.compare("3") == 0) or |
---|
| 247 | (x.compare("predictor_last_take") == 0)) |
---|
| 248 | return morpheo::behavioural::PREDICTOR_LAST_TAKE; |
---|
| 249 | if ( (x.compare("4") == 0) or |
---|
| 250 | (x.compare("predictor_counter") == 0)) |
---|
| 251 | return morpheo::behavioural::PREDICTOR_COUNTER; |
---|
| 252 | if ( (x.compare("5") == 0) or |
---|
| 253 | (x.compare("predictor_local") == 0)) |
---|
| 254 | return morpheo::behavioural::PREDICTOR_LOCAL; |
---|
| 255 | if ( (x.compare("6") == 0) or |
---|
| 256 | (x.compare("predictor_global") == 0)) |
---|
| 257 | return morpheo::behavioural::PREDICTOR_GLOBAL; |
---|
| 258 | if ( (x.compare("7") == 0) or |
---|
| 259 | (x.compare("predictor_meta") == 0)) |
---|
| 260 | return morpheo::behavioural::PREDICTOR_META; |
---|
| 261 | if ( (x.compare("8") == 0) or |
---|
| 262 | (x.compare("predictor_custom") == 0)) |
---|
| 263 | return morpheo::behavioural::PREDICTOR_CUSTOM; |
---|
| 264 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
| 265 | }; |
---|
| 266 | |
---|
[57] | 267 | }; // end namespace morpheo |
---|
| 268 | #endif |
---|