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