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