Changeset 98 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/src/Prediction_unit_Glue_genMealy_predict.cpp
- Timestamp:
- Dec 31, 2008, 11:18:08 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Prediction_unit_Glue/src/Prediction_unit_Glue_genMealy_predict.cpp
r88 r98 24 24 log_begin(Prediction_unit_Glue,FUNCTION); 25 25 log_function(Prediction_unit_Glue,FUNCTION,_name.c_str()); 26 26 27 if (PORT_READ(in_NRESET)) 28 { 29 30 // Init 27 31 Tcontrol_t ack [_param->_nb_context]; 28 32 for (uint32_t i=0; i<_param->_nb_context; i++) 29 { 30 ack [i] = 0; 31 32 // if (_param->_have_port_depth) 33 // { 34 // PORT_WRITE(out_DEPTH_TAIL [i],PORT_READ(in_DEPTH_UPT_TAIL [i])); 35 // } 36 // PORT_WRITE(out_DEPTH_NB_BRANCH [i],PORT_READ(in_DEPTH_UPT_NB_BRANCH [i])); 37 } 33 ack [i] = 0; 38 34 39 35 for (uint32_t i=0; i<_param->_nb_inst_branch_predict; i++) … … 41 37 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * PREDICT [%d]",i); 42 38 43 Tcontrol_t btb_val; 44 Tcontrol_t dir_val; 45 Tcontrol_t ras_val; 46 Tcontrol_t upt_val; 47 48 Tcontext_t context = (reg_PREDICT_PRIORITY+i)%_param->_nb_context; 39 Tcontrol_t btb_val = false; 40 Tcontrol_t dir_val = false; 41 Tcontrol_t ras_val = false; 42 Tcontrol_t upt_val = false; 43 44 Tcontrol_t btb_ack = PORT_READ(in_PREDICT_BTB_ACK [i]); 45 Tcontrol_t dir_ack = PORT_READ(in_PREDICT_DIR_ACK [i]); 46 Tcontrol_t ras_ack = PORT_READ(in_PREDICT_RAS_ACK [i]); 47 Tcontrol_t upt_ack = PORT_READ(in_PREDICT_UPT_ACK [i]); 48 49 Tcontext_t context = (reg_PREDICT_PRIORITY+i)%_param->_nb_context; // priority 49 50 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * context : %d",context); 50 51 51 52 ack [context] = 1; 52 53 53 54 if (PORT_READ(in_PREDICT_VAL[context]) == 0) 54 55 { 55 56 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * not valid ..."); 56 57 57 btb_val = false;58 dir_val = false;59 ras_val = false;60 upt_val = false;58 // btb_val = false; 59 // dir_val = false; 60 // ras_val = false; 61 // upt_val = false; 61 62 } 62 63 else … … 67 68 Taddress_t pc_current = PORT_READ(in_PREDICT_PC_CURRENT [context]); 68 69 Tcontrol_t pc_current_is_ds_take = PORT_READ(in_PREDICT_PC_CURRENT_IS_DS_TAKE [context]); 70 71 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * pc_previous : 0x%.8x",pc_previous ); 72 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * pc_current : 0x%.8x",pc_current ); 73 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * pc_current_is_ds_take : %d" ,pc_current_is_ds_take); 69 74 70 75 Taddress_t pc_next ; … … 75 80 76 81 // STEP (1) - Compute the address source 82 // if pc_current is a ds take, then pc_previous is a branchement 77 83 Taddress_t address = (pc_current_is_ds_take)?pc_previous:pc_current; 78 84 Taddress_t address_lsb = pc_current%_param->_nb_instruction [context]; //if pc_current_is_ds_take, then pc_current%_param->_nb_instruction [context] == 0 79 85 Taddress_t address_msb; 80 86 81 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address : 0x%x",address); 87 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address : 0x%.8x",address); 88 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address_lsb : %d" ,address_lsb); 82 89 83 90 // STEP (2) - Test if branch (access at branch_target_buffer) 84 91 btb_val = true; 85 ack [context] &= PORT_READ(in_PREDICT_BTB_ACK [i]);86 92 87 93 if (_param->_have_port_context_id) 88 94 PORT_WRITE(out_PREDICT_BTB_CONTEXT_ID [i],context); 89 95 PORT_WRITE(out_PREDICT_BTB_ADDRESS [i],address); 96 97 ack [context] &= btb_ack; 98 99 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * btb_ack : %d" ,btb_ack); 100 101 // BTB_ack = 0 ? 102 if (not btb_ack) 103 continue; 90 104 91 105 // special case : … … 95 109 Tcontrol_t is_accurate = PORT_READ(in_PREDICT_BTB_IS_ACCURATE [i]) and not (pc_current_is_ds_take and not hit); 96 110 111 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * hit : %d" ,hit); 112 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * is_accurate : %d" ,is_accurate); 113 97 114 // STEP (3) : Test if have branch in the packet 98 115 if (hit == 1) 99 116 { 100 117 // STEP (3a) : branch - test condition 101 102 118 bool use_dir = false; 103 119 bool use_ras = false; 104 120 bool use_upt = false; 105 121 106 Tbranch_condition_t cond 122 Tbranch_condition_t condition = PORT_READ(in_PREDICT_BTB_CONDITION [i]); 107 123 Taddress_t address_src = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC [i]); 108 124 Taddress_t address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]); 109 Tcontrol_t push ;125 Tcontrol_t push ; 110 126 Tcontrol_t direction; 111 127 112 switch (cond) 128 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * condition : %s" ,toString(condition).c_str()); 129 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address_src : 0x%.8x",address_src); 130 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address_dest : 0x%.8x",address_dest); 131 132 switch (condition) 113 133 { 114 134 case BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK : // l.j … … 188 208 if (use_dir) 189 209 { 190 ack[context] &= PORT_READ(in_PREDICT_DIR_ACK [i]);210 ack[context] &= dir_ack; 191 211 PORT_WRITE(out_PREDICT_DIR_ADDRESS_SRC [i], address_src); 192 212 PORT_WRITE(out_PREDICT_DIR_STATIC [i], address_dest<address_src); // if destination is previous : the static direction is take … … 196 216 if (use_ras) 197 217 { 198 ack[context] &= PORT_READ(in_PREDICT_RAS_ACK [i]);218 ack[context] &= ras_ack; 199 219 if (_param->_have_port_context_id) 200 220 PORT_WRITE(out_PREDICT_RAS_CONTEXT_ID [i], context); … … 207 227 if (use_upt) 208 228 { 209 ack[context] &= PORT_READ(in_PREDICT_UPT_ACK [i]);229 ack[context] &= upt_ack; 210 230 231 if (_param->_have_port_context_id) 211 232 PORT_WRITE(out_PREDICT_UPT_CONTEXT_ID [i],context); 212 233 PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_SRC [i],address_src); 213 234 PORT_WRITE(out_PREDICT_UPT_BTB_ADDRESS_DEST [i],address_dest); 214 PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION [i],cond );235 PORT_WRITE(out_PREDICT_UPT_BTB_CONDITION [i],condition); 215 236 PORT_WRITE(out_PREDICT_UPT_BTB_LAST_TAKE [i],direction); 216 237 PORT_WRITE(out_PREDICT_UPT_BTB_IS_ACCURATE [i],is_accurate); … … 225 246 // * use_ras and ras_ack 226 247 // * use_upt and upt_ack 227 // ack [context] = (PORT_READ(in_PREDICT_BTB_ACK [i]) and 228 // (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i])) and 229 // (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i])) and 230 // (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i]))); 231 232 dir_val = (use_dir and 233 PORT_READ(in_PREDICT_BTB_ACK [i]) and 234 (not use_ras or (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i]))) and 235 (not use_upt or (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i])))); 236 237 ras_val = (use_ras and 238 PORT_READ(in_PREDICT_BTB_ACK [i]) and 239 (not use_dir or (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i]))) and 240 (not use_upt or (use_upt and PORT_READ(in_PREDICT_UPT_ACK [i])))); 241 242 upt_val = (use_upt and 243 PORT_READ(in_PREDICT_BTB_ACK [i]) and 244 (not use_dir or (use_dir and PORT_READ(in_PREDICT_DIR_ACK [i]))) and 245 (not use_ras or (use_ras and PORT_READ(in_PREDICT_RAS_ACK [i])))); 248 // ack [context] = (btb_ack and 249 // (use_dir and dir_ack) and 250 // (use_ras and ras_ack) and 251 // (use_upt and upt_ack)); 252 253 dir_val = (btb_ack and 254 use_dir and 255 // use_ras and 256 // use_upt and 257 // (not use_dir or (use_dir and dir_ack)) and 258 (not use_ras or (use_ras and ras_ack)) and 259 (not use_upt or (use_upt and upt_ack))); 260 261 ras_val = (btb_ack and 262 // use_dir and 263 use_ras and 264 // use_upt and 265 (not use_dir or (use_dir and dir_ack)) and 266 // (not use_ras or (use_ras and ras_ack)) and 267 (not use_upt or (use_upt and upt_ack))); 268 269 upt_val = (btb_ack and 270 // use_dir and 271 // use_ras and 272 use_upt and 273 (not use_dir or (use_dir and dir_ack)) and 274 (not use_ras or (use_ras and ras_ack))// and 275 // (not use_upt or (use_upt and upt_ack)) 276 ); 246 277 247 278 // pc_next - is previously computed … … 252 283 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address_src : 0x%x",address_src); 253 284 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * address_src_lsb : %d",address_src_lsb); 285 254 286 if (address_src_lsb == (_param->_nb_instruction [context]-1)) 255 287 { … … 288 320 PORT_WRITE(out_PREDICT_PC_NEXT_IS_DS_TAKE [context] , pc_next_is_ds_take ); 289 321 322 Taddress_t address_limit_min = address_lsb; 323 Taddress_t address_limit_max = ((pc_current_is_ds_take)?(address_lsb+1):address_msb); 324 290 325 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * instruction enable :"); 291 326 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * nb_inst : %d",_param->_nb_instruction [context]); 292 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [0:%d[ = 0" ,address_lsb);293 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [%d:%d[ = 1",address_l sb,((pc_current_is_ds_take)?1:address_msb));294 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [%d:%d[ = 0", ((pc_current_is_ds_take)?1:address_msb),_param->_nb_instruction [context]);295 296 for (uint32_t j=0; j<address_l sb; j++)327 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [0:%d[ = 0" ,address_limit_min); 328 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [%d:%d[ = 1",address_limit_min,address_limit_max); 329 log_printf(TRACE,Prediction_unit_Glue,FUNCTION," * [%d:%d[ = 0",address_limit_max,_param->_nb_instruction [context]); 330 331 for (uint32_t j=0; j<address_limit_min; j++) 297 332 PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE [context][j], 0); // Before the address : not valid 298 for (uint32_t j=address_l sb; j<((pc_current_is_ds_take)?1:address_msb); j++)333 for (uint32_t j=address_limit_min; j<address_limit_max; j++) 299 334 PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE [context][j], 1); // Vald packet 300 for (uint32_t j= ((pc_current_is_ds_take)?1:address_msb); j<_param->_nb_instruction [context]; j++)335 for (uint32_t j=address_limit_max; j<_param->_nb_instruction [context]; j++) 301 336 PORT_WRITE(out_PREDICT_INSTRUCTION_ENABLE [context][j], 0); // After last address (branch) : not valid 302 337 if (_param->_have_port_inst_ifetch_ptr) … … 316 351 for (uint32_t i=0; i<_param->_nb_context; i++) 317 352 PORT_WRITE(out_PREDICT_ACK[i],ack[i]); 353 } 318 354 319 355 log_end(Prediction_unit_Glue,FUNCTION);
Note: See TracChangeset
for help on using the changeset viewer.