Changeset 112 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp
- Timestamp:
- Mar 18, 2009, 11:36:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp
r111 r112 90 90 { 91 91 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * UPDATE [%d]",i); 92 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * miss : %d",PORT_READ(in_UPDATE_MISS [i])); 93 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * update_on_predict: %d",_param->_update_on_prediction); 92 94 93 95 // Update if 94 96 // * update_on_prediction and miss 95 97 // * not update_on_prediction 96 if (not _param->_update_on_prediction or (_param->_update_on_prediction and PORT_READ(in_UPDATE_MISS [i]))) 97 { 98 Taddress_t address = PORT_READ(in_UPDATE_ADDRESS [i]); 99 Thistory_t history = PORT_READ(in_UPDATE_HISTORY [i]); 100 Tcontrol_t direction = PORT_READ(in_UPDATE_DIRECTION [i])&1; 98 Tcontrol_t history_val = PORT_READ(in_UPDATE_HISTORY_VAL [i]); 99 100 if (not _param->_update_on_prediction or 101 (_param->_update_on_prediction and PORT_READ(in_UPDATE_MISS [i])) or 102 not history_val // static_prediction 103 ) 104 { 105 Taddress_t address = PORT_READ(in_UPDATE_ADDRESS [i]); 106 Thistory_t history = PORT_READ(in_UPDATE_HISTORY [i]); 107 Tcontrol_t direction = PORT_READ(in_UPDATE_DIRECTION [i])&1; 101 108 102 109 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * address : %.8x",address); 103 110 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * direction : %d",direction); 111 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * history_val : %d",direction); 104 112 105 113 Thistory_t pht_bht_history = 0; … … 107 115 if (_param->_have_bht) 108 116 { 117 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht"); 118 109 119 Thistory_t bht_history = (history>>_param->_bht_history_rshift)&_param->_bht_history_mask; 110 120 Thistory_t bht_num_reg = address & _param->_bht_address_mask; 111 121 122 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (old): %x",bht_history); 123 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_num_reg : %x",bht_num_reg); 124 125 // BHT : shift register 126 if (not history_val) 127 bht_history = (direction)?_param->_bht_init_take:_param->_bht_init_ntake; 128 else 129 bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ; 130 112 131 pht_bht_history = bht_history; 113 114 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (old): %x",bht_history); 115 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_num_reg : %x",bht_num_reg); 116 117 // BHT : shift register 118 119 bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ; 120 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (new): %x",bht_history); 132 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (new): %x",bht_history); 121 133 reg_BHT [bht_num_reg] = bht_history; 122 134 } … … 124 136 if (_param->_have_pht) 125 137 { 138 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht"); 139 126 140 Thistory_t pht_history = (history>>_param->_pht_history_rshift)&_param->_pht_history_mask; 127 141 Thistory_t pht_num_reg = pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift); 128 142 Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask; 129 143 130 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (old): %x",pht_bht_history);131 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (old): %x",pht_history);132 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_reg : %x",pht_num_reg);133 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_bank : %x",pht_num_bank);144 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (old): %x",pht_bht_history); 145 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (old): %x",pht_history); 146 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_reg : %x",pht_num_reg); 147 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_bank : %x",pht_num_bank); 134 148 135 149 // PHT : saturation counter 136 pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history)); 137 138 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (new): %x",pht_history); 150 if (not history_val) 151 pht_history = (direction)?_param->_pht_init_take:_param->_pht_init_ntake; 152 else 153 pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history)); 154 155 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (new): %x",pht_history); 139 156 140 157 reg_PHT [pht_num_bank][pht_num_reg] = pht_history; … … 145 162 146 163 #if defined(DEBUG) and DEBUG_Two_Level_Branch_Predictor and (DEBUG >= DEBUG_TRACE) 147 if ( 0)164 if (1) 148 165 { 149 166 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * Dump Two_Level_Branch_Predictor"); … … 180 197 for (uint32_t num_bank=0; num_bank <_param->_pht_nb_bank; ++num_bank) 181 198 { 182 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," [%.4d]",num_bank); 183 184 for (uint32_t i=0; i<_param->_pht_size_bank; i+=limit) 185 { 186 std::string str = ""; 199 if (_param->_pht_size_bank == 1) 200 { 201 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," [%.4d][0000] %4x",num_bank,reg_PHT[num_bank][0]); 202 } 203 else 204 { 205 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," [%.4d]",num_bank); 187 206 188 for (uint32_t j=0; j<limit; j++)207 for (uint32_t i=0; i<_param->_pht_size_bank; i+=limit) 189 208 { 190 uint32_t index = i+j; 191 if (index >= _param->_pht_nb_counter) 192 break; 193 else 194 str+=toString("[%.4d] %.4x ",index,reg_PHT[num_bank][index]); 209 std::string str = ""; 210 211 for (uint32_t j=0; j<limit; j++) 212 { 213 uint32_t index = i+j; 214 if (index >= _param->_pht_size_bank) 215 break; 216 else 217 str+=toString("[%.4d] %.4x ",index,reg_PHT[num_bank][index]); 218 } 219 220 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," %s",str.c_str()); 195 221 } 196 197 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," %s",str.c_str());198 222 } 199 223 }
Note: See TracChangeset
for help on using the changeset viewer.