[88] | 1 | /* |
---|
| 2 | * $Id: Parameters.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/include/Parameters.h" |
---|
| 9 | #include "Common/include/Max.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #undef FUNCTION |
---|
| 19 | #define FUNCTION "Front_end::Parameters" |
---|
| 20 | Parameters::Parameters (uint32_t nb_context , |
---|
| 21 | uint32_t nb_decod_unit , |
---|
| 22 | uint32_t size_general_data , |
---|
| 23 | morpheo::behavioural::custom::custom_information_t (*get_custom_information) (void), |
---|
| 24 | // ifetch_unit |
---|
| 25 | uint32_t * size_ifetch_queue , |
---|
| 26 | uint32_t * nb_inst_fetch , |
---|
| 27 | bool ** instruction_implemeted , |
---|
| 28 | uint32_t * link_context_to_decod_unit , |
---|
| 29 | // decod_unit |
---|
| 30 | uint32_t * size_decod_queue , |
---|
| 31 | uint32_t * nb_inst_decod , |
---|
| 32 | uint32_t * nb_context_select , |
---|
| 33 | Tpriority_t * context_select_priority , |
---|
| 34 | Tload_balancing_t * context_select_load_balancing , |
---|
| 35 | // prediction_unit |
---|
| 36 | uint32_t nb_inst_branch_predict , |
---|
| 37 | uint32_t nb_inst_branch_decod , |
---|
| 38 | uint32_t nb_inst_branch_update , |
---|
| 39 | uint32_t nb_inst_branch_complete , |
---|
| 40 | uint32_t btb_size_queue , |
---|
| 41 | uint32_t btb_associativity , |
---|
| 42 | uint32_t btb_size_counter , |
---|
| 43 | Tvictim_t btb_victim_scheme , |
---|
| 44 | Tpredictor_t dir_predictor_scheme , |
---|
| 45 | bool * dir_have_bht ,//[3] |
---|
| 46 | uint32_t * dir_bht_size_shifter ,//[3] |
---|
| 47 | uint32_t * dir_bht_nb_shifter ,//[3] |
---|
| 48 | bool * dir_have_pht ,//[3] |
---|
| 49 | uint32_t * dir_pht_size_counter ,//[3] |
---|
| 50 | uint32_t * dir_pht_nb_counter ,//[3] |
---|
| 51 | uint32_t * dir_pht_size_address_share ,//[3] |
---|
| 52 | uint32_t * ras_size_queue , |
---|
| 53 | uint32_t * upt_size_queue , |
---|
| 54 | // context_state |
---|
| 55 | uint32_t size_nb_inst_commit , |
---|
| 56 | bool is_toplevel): |
---|
| 57 | morpheo::behavioural::Parameters() |
---|
| 58 | { |
---|
| 59 | log_begin(Front_end,FUNCTION); |
---|
| 60 | |
---|
| 61 | _nb_context = nb_context ; |
---|
| 62 | _nb_decod_unit = nb_decod_unit ; |
---|
| 63 | // _size_general_data = size_general_data ; |
---|
| 64 | _get_custom_information = get_custom_information ; |
---|
| 65 | _size_ifetch_queue = size_ifetch_queue ; |
---|
| 66 | _nb_inst_fetch = nb_inst_fetch ; |
---|
| 67 | _instruction_implemeted = instruction_implemeted ; |
---|
| 68 | _link_context_to_decod_unit = link_context_to_decod_unit ; |
---|
| 69 | _size_decod_queue = size_decod_queue ; |
---|
| 70 | _nb_inst_decod = nb_inst_decod ; |
---|
| 71 | _nb_context_select = nb_context_select ; |
---|
| 72 | _context_select_priority = context_select_priority ; |
---|
| 73 | _context_select_load_balancing = context_select_load_balancing ; |
---|
| 74 | _nb_inst_branch_predict = nb_inst_branch_predict ; |
---|
| 75 | _nb_inst_branch_decod = nb_inst_branch_decod ; |
---|
| 76 | _nb_inst_branch_update = nb_inst_branch_update ; |
---|
| 77 | _nb_inst_branch_complete = nb_inst_branch_complete ; |
---|
| 78 | _btb_size_queue = btb_size_queue ; |
---|
| 79 | _btb_associativity = btb_associativity ; |
---|
| 80 | _btb_size_counter = btb_size_counter ; |
---|
| 81 | _btb_victim_scheme = btb_victim_scheme ; |
---|
| 82 | _dir_predictor_scheme = dir_predictor_scheme ; |
---|
| 83 | for (uint32_t i=0; i<3; i++) |
---|
| 84 | { |
---|
| 85 | _dir_have_bht [i] = dir_have_bht [i]; |
---|
| 86 | _dir_bht_size_shifter [i] = dir_bht_size_shifter [i]; |
---|
| 87 | _dir_bht_nb_shifter [i] = dir_bht_nb_shifter [i]; |
---|
| 88 | _dir_have_pht [i] = dir_have_pht [i]; |
---|
| 89 | _dir_pht_size_counter [i] = dir_pht_size_counter [i]; |
---|
| 90 | _dir_pht_nb_counter [i] = dir_pht_nb_counter [i]; |
---|
| 91 | _dir_pht_size_address_share [i] = dir_pht_size_address_share [i]; |
---|
| 92 | } |
---|
| 93 | _ras_size_queue = ras_size_queue ; |
---|
| 94 | _upt_size_queue = upt_size_queue ; |
---|
| 95 | |
---|
| 96 | test(); |
---|
| 97 | |
---|
| 98 | // _size_context_id = log2(_nb_context); |
---|
| 99 | uint32_t size_instruction_address = size_general_data - 2; |
---|
| 100 | |
---|
| 101 | _array_size_depth = new uint32_t [_nb_context]; |
---|
| 102 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 103 | _array_size_depth [i] = log2(_upt_size_queue[i]); |
---|
| 104 | |
---|
| 105 | _array_size_nb_inst_decod = new uint32_t [_nb_decod_unit]; |
---|
| 106 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 107 | _array_size_nb_inst_decod [i] = log2(_size_decod_queue[i]+1); |
---|
| 108 | |
---|
| 109 | _param_ifetch_unit = new behavioural::core::multi_front_end::front_end::ifetch_unit::Parameters * [_nb_context]; |
---|
| 110 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 111 | { |
---|
| 112 | _param_ifetch_unit [i] = new behavioural::core::multi_front_end::front_end::ifetch_unit::Parameters |
---|
| 113 | (_size_ifetch_queue [i] , |
---|
| 114 | _nb_inst_fetch [i] , |
---|
| 115 | log2(_upt_size_queue[i]) , |
---|
| 116 | size_instruction_address ); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | _param_prediction_unit = new behavioural::core::multi_front_end::front_end::prediction_unit::Parameters |
---|
| 120 | (_nb_context , |
---|
| 121 | _nb_decod_unit , |
---|
| 122 | size_instruction_address , |
---|
| 123 | _nb_inst_fetch , |
---|
| 124 | _nb_inst_decod , |
---|
| 125 | _nb_inst_branch_predict , |
---|
| 126 | _nb_inst_branch_decod , |
---|
| 127 | _nb_inst_branch_update , |
---|
| 128 | _nb_inst_branch_complete , |
---|
| 129 | _btb_size_queue , |
---|
| 130 | _btb_associativity , |
---|
| 131 | _btb_size_counter , |
---|
| 132 | _btb_victim_scheme , |
---|
| 133 | _dir_predictor_scheme , |
---|
| 134 | _dir_have_bht , |
---|
| 135 | _dir_bht_size_shifter , |
---|
| 136 | _dir_bht_nb_shifter , |
---|
| 137 | _dir_have_pht , |
---|
| 138 | _dir_pht_size_counter , |
---|
| 139 | _dir_pht_nb_counter , |
---|
| 140 | _dir_pht_size_address_share , |
---|
| 141 | _ras_size_queue , |
---|
| 142 | _upt_size_queue ); |
---|
| 143 | |
---|
| 144 | _translate_context_id_from_decod_unit= new std::vector<uint32_t> [_nb_decod_unit]; |
---|
| 145 | |
---|
| 146 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 147 | _translate_context_id_from_decod_unit [_link_context_to_decod_unit[i]].push_back(i); |
---|
| 148 | |
---|
| 149 | _decod_unit_nb_context = new uint32_t [_nb_decod_unit]; |
---|
| 150 | _decod_unit_nb_inst_fetch = new uint32_t * [_nb_decod_unit]; |
---|
| 151 | _decod_unit_nb_branch_speculated = new uint32_t * [_nb_decod_unit]; |
---|
| 152 | // _decod_unit_depth = new uint32_t * [_nb_decod_unit]; |
---|
| 153 | _decod_unit_instruction_implemeted = new bool ** [_nb_decod_unit]; |
---|
| 154 | // _have_port_decod_unit_context_id = new bool [_nb_decod_unit]; |
---|
| 155 | _sum_inst_decod = 0; |
---|
| 156 | |
---|
| 157 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 158 | { |
---|
| 159 | _sum_inst_decod += _nb_inst_decod [i]; |
---|
| 160 | |
---|
| 161 | uint32_t size = _translate_context_id_from_decod_unit [i].size(); |
---|
| 162 | |
---|
| 163 | _decod_unit_nb_context [i] = size; |
---|
| 164 | _decod_unit_nb_inst_fetch [i] = new uint32_t [size]; |
---|
| 165 | // _decod_unit_depth [i] = new uint32_t [size]; |
---|
| 166 | _decod_unit_nb_branch_speculated [i] = new uint32_t [size]; |
---|
| 167 | _decod_unit_instruction_implemeted [i] = new bool * [size]; |
---|
| 168 | // _have_port_decod_unit_context_id [i] = size > 0; |
---|
| 169 | |
---|
| 170 | for (uint32_t j=0; j<size; ++j) |
---|
| 171 | { |
---|
| 172 | uint32_t x = _translate_context_id_from_decod_unit[i][j]; |
---|
| 173 | |
---|
| 174 | _decod_unit_nb_inst_fetch [i][j] = _nb_inst_fetch [x]; |
---|
| 175 | _decod_unit_nb_branch_speculated [i][j] = _upt_size_queue [x]; |
---|
| 176 | // _decod_unit_depth [i][j] = log2(_upt_size_queue[x]); |
---|
| 177 | _decod_unit_instruction_implemeted [i][j] = new bool [NB_INSTRUCTION]; |
---|
| 178 | |
---|
| 179 | for (uint32_t k=0; k<NB_INSTRUCTION; ++k) |
---|
| 180 | _decod_unit_instruction_implemeted [i][j][k] = _instruction_implemeted [x][k]; |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | log_printf(TRACE,Front_end,FUNCTION,_("Translate")); |
---|
| 185 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 186 | { |
---|
| 187 | uint32_t size = _decod_unit_nb_context [i]; |
---|
| 188 | log_printf(TRACE,Front_end,FUNCTION,_("Decod_unit [%d], nb_decod_unit_context : %d"),i,size); |
---|
| 189 | |
---|
| 190 | for (uint32_t j=0; j<size; ++j) |
---|
| 191 | { |
---|
| 192 | log_printf(TRACE,Front_end,FUNCTION,_(" Context [%d] -> Decod_unit_Context [%d]"),j,(_translate_context_id_from_decod_unit [i])[j]); |
---|
| 193 | log_printf(TRACE,Front_end,FUNCTION,_(" * decod_unit_nb_inst_fetch : %d"),_decod_unit_nb_inst_fetch [i][j]); |
---|
| 194 | log_printf(TRACE,Front_end,FUNCTION,_(" * decod_unit_nb_branch_speculated : %d"),_decod_unit_nb_branch_speculated[i][j]); |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | _param_decod_unit = new behavioural::core::multi_front_end::front_end::decod_unit::Parameters * [_nb_decod_unit]; |
---|
| 199 | for (uint32_t i=0; i<_nb_decod_unit; ++i) |
---|
| 200 | { |
---|
| 201 | _param_decod_unit [i] = new behavioural::core::multi_front_end::front_end::decod_unit::Parameters |
---|
| 202 | (_decod_unit_nb_context [i], |
---|
| 203 | _decod_unit_nb_inst_fetch [i], |
---|
| 204 | _nb_inst_decod [i], |
---|
| 205 | _size_decod_queue [i], |
---|
| 206 | size_general_data , |
---|
| 207 | _decod_unit_nb_branch_speculated [i], |
---|
| 208 | // _decod_unit_depth [i], |
---|
| 209 | _nb_context_select [i], |
---|
| 210 | _context_select_priority [i], |
---|
| 211 | _context_select_load_balancing [i], |
---|
| 212 | _decod_unit_instruction_implemeted [i], |
---|
| 213 | _get_custom_information ); |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | _param_context_state = new behavioural::core::multi_front_end::front_end::context_state::Parameters |
---|
| 217 | (_nb_context, |
---|
| 218 | _nb_decod_unit, |
---|
| 219 | _nb_inst_branch_complete, |
---|
| 220 | _array_size_depth, |
---|
| 221 | size_instruction_address, |
---|
| 222 | _array_size_nb_inst_decod, |
---|
| 223 | size_nb_inst_commit, |
---|
| 224 | _link_context_to_decod_unit); |
---|
| 225 | |
---|
| 226 | _param_glue = new behavioural::core::multi_front_end::front_end::front_end_glue::Parameters |
---|
| 227 | (_nb_context , |
---|
| 228 | _nb_decod_unit , |
---|
| 229 | _nb_inst_decod , |
---|
| 230 | _nb_inst_branch_complete , |
---|
| 231 | _link_context_to_decod_unit , |
---|
| 232 | _translate_context_id_from_decod_unit , |
---|
| 233 | size_instruction_address , |
---|
| 234 | _array_size_depth , |
---|
| 235 | _upt_size_queue //_nb_branch_speculated |
---|
| 236 | ); |
---|
| 237 | |
---|
| 238 | if (is_toplevel) |
---|
| 239 | { |
---|
| 240 | _size_context_id = log2(_nb_context); |
---|
| 241 | _size_instruction_address = size_instruction_address; |
---|
| 242 | _size_general_data = size_general_data; |
---|
| 243 | _size_nb_inst_decod = max<uint32_t>(_array_size_nb_inst_decod,_nb_decod_unit); |
---|
| 244 | _size_nb_inst_commit = size_nb_inst_commit; |
---|
| 245 | _size_depth = max<uint32_t>(_array_size_depth,_nb_context); |
---|
| 246 | _size_ifetch_queue_ptr = log2(max<uint32_t>(_size_ifetch_queue,_nb_context)); |
---|
| 247 | _size_inst_ifetch_ptr = log2(max<uint32_t>(_nb_inst_fetch ,_nb_context)); |
---|
| 248 | |
---|
| 249 | _have_port_context_id = _size_context_id > 0; |
---|
| 250 | _have_port_depth = _size_depth > 0; |
---|
| 251 | _have_port_ifetch_queue_ptr = _size_ifetch_queue_ptr> 0; |
---|
| 252 | _have_port_inst_ifetch_ptr = _size_inst_ifetch_ptr > 0; |
---|
| 253 | |
---|
| 254 | copy (); |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | log_end(Front_end,FUNCTION); |
---|
| 258 | }; |
---|
| 259 | |
---|
| 260 | // #undef FUNCTION |
---|
| 261 | // #define FUNCTION "Front_end::Parameters (copy)" |
---|
| 262 | // Parameters::Parameters (Parameters & param) |
---|
| 263 | // { |
---|
| 264 | // log_begin(Front_end,FUNCTION); |
---|
| 265 | // test(); |
---|
| 266 | // log_end(Front_end,FUNCTION); |
---|
| 267 | // }; |
---|
| 268 | |
---|
| 269 | #undef FUNCTION |
---|
| 270 | #define FUNCTION "Front_end::~Parameters" |
---|
| 271 | Parameters::~Parameters () |
---|
| 272 | { |
---|
| 273 | log_begin(Front_end,FUNCTION); |
---|
| 274 | |
---|
| 275 | delete [] _param_glue ; |
---|
| 276 | delete [] _param_context_state ; |
---|
| 277 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 278 | delete [] _param_decod_unit [i]; |
---|
| 279 | delete [] _param_decod_unit ; |
---|
| 280 | delete [] _param_prediction_unit; |
---|
| 281 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 282 | delete [] _param_ifetch_unit [i]; |
---|
| 283 | delete [] _param_ifetch_unit ; |
---|
| 284 | |
---|
| 285 | // delete [] _size_ifetch_queue_ptr; |
---|
| 286 | // delete [] _size_nb_inst_decod; |
---|
| 287 | delete [] _array_size_depth; |
---|
| 288 | for (uint32_t i=0; i<_nb_context; ++i) |
---|
| 289 | { |
---|
| 290 | for (uint32_t j=0; j<_translate_context_id_from_decod_unit [i].size(); ++j) |
---|
| 291 | delete [] _decod_unit_instruction_implemeted [i][j]; |
---|
| 292 | |
---|
| 293 | delete [] _decod_unit_nb_inst_fetch [i]; |
---|
| 294 | // delete [] _decod_unit_depth [i]; |
---|
| 295 | delete [] _decod_unit_nb_branch_speculated [i]; |
---|
| 296 | delete [] _decod_unit_instruction_implemeted [i]; |
---|
| 297 | } |
---|
| 298 | delete [] _decod_unit_nb_inst_fetch ; |
---|
| 299 | // delete [] _decod_unit_depth ; |
---|
| 300 | delete [] _decod_unit_nb_branch_speculated ; |
---|
| 301 | delete [] _decod_unit_instruction_implemeted; |
---|
| 302 | |
---|
| 303 | // delete [] _have_port_decod_unit_context_id; |
---|
| 304 | delete [] _decod_unit_nb_context ; |
---|
| 305 | delete [] _translate_context_id_from_decod_unit; |
---|
| 306 | |
---|
| 307 | log_end(Front_end,FUNCTION); |
---|
| 308 | }; |
---|
| 309 | |
---|
| 310 | |
---|
| 311 | #undef FUNCTION |
---|
| 312 | #define FUNCTION "Front_end::copy" |
---|
| 313 | void Parameters::copy (void) |
---|
| 314 | { |
---|
| 315 | log_begin(Front_end,FUNCTION); |
---|
| 316 | |
---|
| 317 | COPY(_param_glue ); |
---|
| 318 | COPY(_param_context_state ); |
---|
| 319 | for (uint32_t i=0; i<_nb_decod_unit; i++) |
---|
| 320 | { |
---|
| 321 | COPY(_param_decod_unit [i]); |
---|
| 322 | } |
---|
| 323 | COPY(_param_prediction_unit); |
---|
| 324 | for (uint32_t i=0; i<_nb_context; i++) |
---|
| 325 | COPY(_param_ifetch_unit [i]); |
---|
| 326 | |
---|
| 327 | log_end(Front_end,FUNCTION); |
---|
| 328 | }; |
---|
| 329 | |
---|
| 330 | }; // end namespace front_end |
---|
| 331 | }; // end namespace multi_front_end |
---|
| 332 | }; // end namespace core |
---|
| 333 | |
---|
| 334 | }; // end namespace behavioural |
---|
| 335 | }; // end namespace morpheo |
---|