Changeset 111 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor
- Timestamp:
- Feb 27, 2009, 7:37:40 PM (15 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor
- Files:
-
- 3 added
- 11 edited
- 1 moved
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/SelfTest/config_bht_only.cfg
r110 r111 1 1 Two_Level_Branch_Predictor 2 4 4 *2 # nb_inst_predict 3 4 4 *2 # nb_inst_update 4 30 30 *2 # size_address 5 1 1 +1 # have_bht 6 1 16 *4 # bht_size_shifter 7 1 16 *4 # bht_nb_shifter 8 0 0 +1 # have_pht 9 0 0 +1 # pht_size_counter 10 0 0 *2 # pht_nb_counter 11 0 0 +1 # pht_size_address_share 12 1 1 +1 # update_on_prediction -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h
r110 r111 11 11 #endif 12 12 13 #define NB_ITERATION 1 13 #define NB_ITERATION 16 14 14 #define CYCLE_MAX (1024*NB_ITERATION) 15 15 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/main.cpp
r110 r111 7 7 8 8 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h" 9 #include "Behavioural/include/Selftest.h" 9 10 10 #define NB_PARAMS 011 #define NB_PARAMS 11 11 12 12 13 void usage (int argc, char * argv[]) … … 14 15 err (_("<Usage> %s name_instance list_params.\n"),argv[0]); 15 16 err (_("list_params is :\n")); 16 err (_(" * ()\n")); 17 err (_(" * nb_inst_predict (uint32_t)\n")); 18 err (_(" * nb_inst_update (uint32_t)\n")); 19 err (_(" * size_address (uint32_t)\n")); 20 err (_(" * have_bht (bool )\n")); 21 err (_(" * bht_size_shifter (uint32_t)\n")); 22 err (_(" * bht_nb_shifter (uint32_t)\n")); 23 err (_(" * have_pht (bool )\n")); 24 err (_(" * pht_size_counter (uint32_t)\n")); 25 err (_(" * pht_nb_counter (uint32_t)\n")); 26 err (_(" * pht_size_address_share (uint32_t)\n")); 27 err (_(" * update_on_prediction (bool )\n")); 17 28 18 29 exit (1); … … 32 43 string name = argv[x++]; 33 44 45 uint32_t nb_inst_predict ; 46 uint32_t nb_inst_update ; 47 uint32_t size_address ; 48 bool have_bht ; 49 uint32_t bht_size_shifter ; 50 uint32_t bht_nb_shifter ; 51 bool have_pht ; 52 uint32_t pht_size_counter ; 53 uint32_t pht_nb_counter ; 54 uint32_t pht_size_address_share; 55 bool update_on_prediction ; 56 57 SELFTEST0(nb_inst_predict ,uint32_t,argv,x); 58 SELFTEST0(nb_inst_update ,uint32_t,argv,x); 59 SELFTEST0(size_address ,uint32_t,argv,x); 60 SELFTEST0(have_bht ,bool ,argv,x); 61 SELFTEST0(bht_size_shifter ,uint32_t,argv,x); 62 SELFTEST0(bht_nb_shifter ,uint32_t,argv,x); 63 SELFTEST0(have_pht ,bool ,argv,x); 64 SELFTEST0(pht_size_counter ,uint32_t,argv,x); 65 SELFTEST0(pht_nb_counter ,uint32_t,argv,x); 66 SELFTEST0(pht_size_address_share,uint32_t,argv,x); 67 SELFTEST0(update_on_prediction ,bool ,argv,x); 68 34 69 int _return = EXIT_SUCCESS; 35 70 try … … 37 72 morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters 38 73 ( 74 nb_inst_predict , 75 nb_inst_update , 76 size_address , 77 have_bht , 78 bht_size_shifter , 79 bht_nb_shifter , 80 have_pht , 81 pht_size_counter , 82 pht_nb_counter , 83 pht_size_address_share, 84 update_on_prediction , 39 85 true //is_toplevel 40 86 ); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/test.cpp
r110 r111 50 50 sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); 51 51 sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); 52 53 ALLOC1_SC_SIGNAL( in_PREDICT_VAL ," in_PREDICT_VAL ",Tcontrol_t,_param->_nb_inst_predict); 54 ALLOC1_SC_SIGNAL(out_PREDICT_ACK ,"out_PREDICT_ACK ",Tcontrol_t,_param->_nb_inst_predict); 55 ALLOC1_SC_SIGNAL( in_PREDICT_ADDRESS ," in_PREDICT_ADDRESS ",Taddress_t,_param->_nb_inst_predict); 56 ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION ,"out_PREDICT_DIRECTION ",Tcontrol_t,_param->_nb_inst_predict); 57 ALLOC1_SC_SIGNAL(out_PREDICT_HISTORY ,"out_PREDICT_HISTORY ",Thistory_t,_param->_nb_inst_predict); 58 ALLOC1_SC_SIGNAL( in_PREDICT_DIRECTION_VAL," in_PREDICT_DIRECTION_VAL",Tcontrol_t,_param->_nb_inst_predict); 59 ALLOC1_SC_SIGNAL( in_PREDICT_DIRECTION ," in_PREDICT_DIRECTION ",Tcontrol_t,_param->_nb_inst_predict); 60 61 ALLOC1_SC_SIGNAL( in_UPDATE_VAL ," in_UPDATE_VAL ",Tcontrol_t,_param->_nb_inst_update); 62 ALLOC1_SC_SIGNAL(out_UPDATE_ACK ,"out_UPDATE_ACK ",Tcontrol_t,_param->_nb_inst_update); 63 ALLOC1_SC_SIGNAL( in_UPDATE_ADDRESS ," in_UPDATE_ADDRESS ",Taddress_t,_param->_nb_inst_update); 64 ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY ," in_UPDATE_HISTORY ",Thistory_t,_param->_nb_inst_update); 65 ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION ," in_UPDATE_DIRECTION ",Tcontrol_t,_param->_nb_inst_update); 66 ALLOC1_SC_SIGNAL( in_UPDATE_MISS ," in_UPDATE_MISS ",Tcontrol_t,_param->_nb_inst_update); 52 67 53 68 /******************************************************** … … 60 75 (*(_Two_Level_Branch_Predictor->in_NRESET)) (*(in_NRESET)); 61 76 77 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_VAL ,_param->_nb_inst_predict); 78 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_ACK ,_param->_nb_inst_predict); 79 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_ADDRESS ,_param->_nb_inst_predict); 80 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_DIRECTION ,_param->_nb_inst_predict); 81 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_HISTORY ,_param->_nb_inst_predict); 82 if (_param->_update_on_prediction) 83 { 84 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict); 85 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_DIRECTION ,_param->_nb_inst_predict); 86 } 87 88 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_VAL ,_param->_nb_inst_update); 89 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_UPDATE_ACK ,_param->_nb_inst_update); 90 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_ADDRESS ,_param->_nb_inst_update); 91 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_HISTORY ,_param->_nb_inst_update); 92 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_DIRECTION ,_param->_nb_inst_update); 93 if (_param->_update_on_prediction) 94 INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_MISS ,_param->_nb_inst_update); 62 95 63 96 msg(_("<%s> : Start Simulation ............\n"),name.c_str()); … … 76 109 srand(seed); 77 110 111 const int32_t percent_transaction_predict = 75; 112 const int32_t percent_transaction_update = 75; 113 78 114 SC_START(0); 79 115 LABEL("Initialisation"); 116 117 for (uint32_t i=0; i<_param->_nb_inst_predict; ++i) 118 in_PREDICT_VAL [i]->write(0); 119 for (uint32_t i=0; i<_param->_nb_inst_update; ++i) 120 in_UPDATE_VAL [i]->write(0); 80 121 81 122 LABEL("Reset"); … … 85 126 86 127 LABEL("Loop of Test"); 87 128 129 Thistory_t bht; 130 Thistory_t pht [_param->_pht_size_bank]; 131 88 132 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 89 133 { 90 134 LABEL("Iteration %d",iteration); 91 135 136 uint32_t bht_num_reg = (_param->_have_bht)?(rand()%_param->_bht_nb_shifter):0; 137 uint32_t pht_num_bank = (_param->_have_pht)?(rand()%_param->_pht_nb_bank ):0; 138 139 LABEL(" * bht_num_reg : %d",bht_num_reg ); 140 LABEL(" * pht_num_bank : %d",pht_num_bank); 141 142 { 143 LABEL("Init BHT and PHT"); 144 145 bht = 0; 146 for (uint32_t i=0; i<_param->_pht_size_bank; ++i) 147 pht [i] = 0; 148 149 uint32_t port = rand()%_param->_nb_inst_update; 150 151 if (_param->_have_bht) 152 { 153 bool find = false; 154 while (not find) 155 { 156 bool val = ((rand()%2)<percent_transaction_update); 157 in_UPDATE_VAL [port]->write(val); 158 in_UPDATE_DIRECTION [port]->write(0); 159 160 if (_param->_update_on_prediction) 161 in_UPDATE_MISS [port]->write(1); // miss 162 in_UPDATE_HISTORY [port]->write(0); 163 in_UPDATE_ADDRESS [port]->write(bht_num_reg); 164 165 SC_START(0); 166 167 if (val and out_UPDATE_ACK [port]->read()) 168 { 169 LABEL("UPDATE[%d] - Transaction accepted",port); 170 find = true; 171 } 172 173 SC_START(1); 174 } 175 in_UPDATE_VAL [port]->write(0); 176 } 177 178 if (_param->_have_pht) 179 { 180 for (uint32_t i=0; i<_param->_pht_size_bank; ++i) 181 { 182 bool find = false; 183 184 while (not find) 185 { 186 bool val = ((rand()%2)<percent_transaction_update); 187 in_UPDATE_VAL [port]->write(val); 188 in_UPDATE_DIRECTION [port]->write(0); 189 190 if (_param->_update_on_prediction) 191 in_UPDATE_MISS [port]->write(1); // miss 192 in_UPDATE_HISTORY [port]->write(i<<_param->_bht_history_rshift); 193 in_UPDATE_ADDRESS [port]->write(pht_num_bank<<_param->_pht_address_bank_rshift); 194 195 SC_START(0); 196 197 if (val and out_UPDATE_ACK [port]->read()) 198 { 199 LABEL("UPDATE[%d] - Transaction accepted",port); 200 find = true; 201 } 202 203 SC_START(1); 204 } 205 in_UPDATE_VAL [port]->write(0); 206 } 207 } 208 } 209 210 // if (1) 211 // { 212 // LABEL("Saturation all PHT"); 213 214 // } 215 92 216 SC_START(1); 93 217 } … … 104 228 delete in_CLOCK; 105 229 delete in_NRESET; 230 231 DELETE1_SC_SIGNAL( in_PREDICT_VAL ,_param->_nb_inst_predict); 232 DELETE1_SC_SIGNAL(out_PREDICT_ACK ,_param->_nb_inst_predict); 233 DELETE1_SC_SIGNAL( in_PREDICT_ADDRESS ,_param->_nb_inst_predict); 234 DELETE1_SC_SIGNAL(out_PREDICT_DIRECTION ,_param->_nb_inst_predict); 235 DELETE1_SC_SIGNAL(out_PREDICT_HISTORY ,_param->_nb_inst_predict); 236 DELETE1_SC_SIGNAL( in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict); 237 DELETE1_SC_SIGNAL( in_PREDICT_DIRECTION ,_param->_nb_inst_predict); 238 239 DELETE1_SC_SIGNAL( in_UPDATE_VAL ,_param->_nb_inst_update); 240 DELETE1_SC_SIGNAL(out_UPDATE_ACK ,_param->_nb_inst_update); 241 DELETE1_SC_SIGNAL( in_UPDATE_ADDRESS ,_param->_nb_inst_update); 242 DELETE1_SC_SIGNAL( in_UPDATE_HISTORY ,_param->_nb_inst_update); 243 DELETE1_SC_SIGNAL( in_UPDATE_DIRECTION ,_param->_nb_inst_update); 244 DELETE1_SC_SIGNAL( in_UPDATE_MISS ,_param->_nb_inst_update); 106 245 } 107 246 #endif -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h
r110 r111 9 9 */ 10 10 11 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Types.h" 11 12 #include "Behavioural/include/Parameters.h" 12 13 #include "Common/include/Debug.h" … … 26 27 { 27 28 //-----[ fields ]------------------------------------------------------------ 29 public : uint32_t _nb_inst_predict ; 30 public : uint32_t _nb_inst_update ; 31 public : uint32_t _size_address ; 32 public : bool _have_bht ; 33 public : uint32_t _bht_size_shifter ; 34 public : uint32_t _bht_nb_shifter ; 35 public : bool _have_pht ; 36 public : uint32_t _pht_size_counter ; 37 public : uint32_t _pht_nb_counter ; 38 public : uint32_t _pht_size_address_share ; 39 public : bool _update_on_prediction ; 40 41 public : Thistory_t _pht_counter_max ; 42 43 public : uint32_t _size_history ; 44 45 public : Thistory_t _bht_history_mask ; 46 public : Thistory_t _bht_history_rshift ; 47 public : Thistory_t _pht_history_mask ; 48 public : Thistory_t _pht_history_rshift ; 49 50 public : uint32_t _bht_size_address ; 51 public : uint32_t _pht_size_address ; 52 53 public : Taddress_t _bht_address_mask ; 54 public : uint32_t _pht_nb_bank ; 55 public : uint32_t _pht_size_bank ; 56 public : Taddress_t _pht_address_share_mask ; 57 public : Taddress_t _pht_address_share_lshift; 58 public : Taddress_t _pht_address_bank_mask ; 59 public : Taddress_t _pht_address_bank_rshift ; 28 60 29 61 //-----[ methods ]----------------------------------------------------------- 30 public : Parameters (bool is_toplevel=false); 62 public : Parameters (uint32_t nb_inst_predict , 63 uint32_t nb_inst_update , 64 uint32_t size_address , 65 bool have_bht , 66 uint32_t bht_size_shifter , 67 uint32_t bht_nb_shifter , 68 bool have_pht , 69 uint32_t pht_size_counter , 70 uint32_t pht_nb_counter , 71 uint32_t pht_size_address_share, 72 bool update_on_prediction , 73 bool is_toplevel=false); 31 74 //public : Parameters (Parameters & param) ; 32 75 public : ~Parameters (void); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h
r110 r111 66 66 public : SC_IN (Tcontrol_t) * in_NRESET ; 67 67 68 // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 public : SC_IN (Tcontrol_t) ** in_PREDICT_VAL ;//[nb_inst_predict] 70 public : SC_OUT(Tcontrol_t) ** out_PREDICT_ACK ;//[nb_inst_predict] 71 public : SC_IN (Taddress_t) ** in_PREDICT_ADDRESS ;//[nb_inst_predict] 72 public : SC_OUT(Tcontrol_t) ** out_PREDICT_DIRECTION ;//[nb_inst_predict] // = MSB[history] 73 public : SC_OUT(Thistory_t) ** out_PREDICT_HISTORY ;//[nb_inst_predict] 74 public : SC_IN (Tcontrol_t) ** in_PREDICT_DIRECTION_VAL;//[nb_inst_predict] // if update_on_prediction 75 public : SC_IN (Tcontrol_t) ** in_PREDICT_DIRECTION ;//[nb_inst_predict] // if update_on_prediction 76 77 // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 78 public : SC_IN (Tcontrol_t) ** in_UPDATE_VAL ;//[nb_inst_update] 79 public : SC_OUT(Tcontrol_t) ** out_UPDATE_ACK ;//[nb_inst_update] 80 public : SC_IN (Taddress_t) ** in_UPDATE_ADDRESS ;//[nb_inst_update] 81 public : SC_IN (Thistory_t) ** in_UPDATE_HISTORY ;//[nb_inst_update] 82 public : SC_IN (Tcontrol_t) ** in_UPDATE_DIRECTION ;//[nb_inst_update] 83 public : SC_IN (Tcontrol_t) ** in_UPDATE_MISS ;//[nb_inst_update] // if update_on_prediction 84 68 85 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 69 86 70 87 // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 88 private : Thistory_t * reg_BHT ;//[bht_nb_shifter] 89 private : Thistory_t ** reg_PHT ;//[pht_nb_counter][pht_nb_bank] 71 90 72 91 // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 92 private : Tcontrol_t * internal_PREDICT_ACK ;//[nb_inst_predict] 93 private : Thistory_t * internal_PREDICT_BHT_NUM_REG ;//[nb_inst_predict] // if update_on_prediction 94 private : Thistory_t * internal_PREDICT_PHT_NUM_BANK ;//[nb_inst_predict] // if update_on_prediction 95 private : Thistory_t * internal_PREDICT_PHT_NUM_REG ;//[nb_inst_predict] // if update_on_prediction 96 97 private : Tcontrol_t * internal_UPDATE_ACK ;//[nb_inst_update] 73 98 #endif 74 99 … … 104 129 #ifdef SYSTEMC 105 130 public : void transition (void); 106 //public : void genMoore(void);131 public : void genMealy_predict (void); 107 132 #endif 108 133 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters.cpp
r110 r111 7 7 8 8 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h" 9 #include "Common/include/BitManipulation.h" 9 10 10 11 namespace morpheo { … … 21 22 #undef FUNCTION 22 23 #define FUNCTION "Two_Level_Branch_Predictor::Parameters" 23 Parameters::Parameters (bool is_toplevel) 24 Parameters::Parameters (uint32_t nb_inst_predict , 25 uint32_t nb_inst_update , 26 uint32_t size_address , 27 bool have_bht , 28 uint32_t bht_size_shifter , 29 uint32_t bht_nb_shifter , 30 bool have_pht , 31 uint32_t pht_size_counter , 32 uint32_t pht_nb_counter , 33 uint32_t pht_size_address_share, 34 bool update_on_prediction , 35 bool is_toplevel) 24 36 { 25 37 log_begin(Two_Level_Branch_Predictor,FUNCTION); 26 38 27 test(); 39 _nb_inst_predict = nb_inst_predict ; 40 _nb_inst_update = nb_inst_update ; 41 _size_address = size_address ; 42 _have_bht = have_bht ; 43 _bht_size_shifter = (have_bht)?(bht_size_shifter):0; 44 _bht_nb_shifter = (have_bht)?(bht_nb_shifter ):0; 45 _have_pht = have_pht ; 46 _pht_size_counter = (have_pht)?(pht_size_counter ):0; 47 _pht_nb_counter = (have_pht)?(pht_nb_counter ):0; 48 _pht_size_address_share = (have_bht and have_pht)?(pht_size_address_share):0; 49 _update_on_prediction = update_on_prediction ; 50 51 _bht_size_address = (_have_bht)?log2(_bht_nb_shifter):0; 52 _pht_size_address = (_have_pht)?log2(_pht_nb_counter):0; 53 54 test(); 55 56 _size_history = _bht_size_shifter + _pht_size_counter; 57 58 _bht_history_mask = gen_mask<Thistory_t>(_bht_size_shifter); 59 _bht_history_rshift = 0; 60 _pht_history_mask = gen_mask<Thistory_t>(_pht_size_counter); 61 _pht_history_rshift = _bht_size_shifter; 62 63 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _size_history : %d",_size_history ); 64 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_history_mask : 0x%x",_bht_history_mask ); 65 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_history_rshift : %d",_bht_history_rshift); 66 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_history_mask : 0x%x",_pht_history_mask ); 67 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_history_rshift : %d",_pht_history_rshift); 68 69 if (_have_bht) 70 { 71 _bht_address_mask = gen_mask<Taddress_t>(_bht_size_address); 72 73 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _bht_address_mask : 0x%x",_bht_address_mask ); 74 } 75 76 if (_have_pht) 77 { 78 _pht_counter_max = (1<<_pht_size_counter)-1; 79 80 _pht_nb_bank = (_pht_nb_counter - (1<<_bht_size_shifter))+1; 81 _pht_size_bank = _pht_nb_counter / _pht_nb_bank; 82 83 _pht_address_share_mask = gen_mask<Taddress_t>(_pht_size_address_share); 84 _pht_address_share_lshift= _bht_size_shifter-_pht_size_address_share; 85 _pht_address_bank_mask = gen_mask<Taddress_t>(log2(_pht_nb_bank)); 86 _pht_address_bank_rshift = _pht_size_address_share; 87 88 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_nb_bank : %d" ,_pht_nb_bank ); 89 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_size_bank : %d" ,_pht_size_bank ); 90 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_share_mask : 0x%x",_pht_address_share_mask ); 91 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_share_lshift : %d" ,_pht_address_share_lshift); 92 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_bank_mask : 0x%x",_pht_address_bank_mask ); 93 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * _pht_address_bank_rshift : %d" ,_pht_address_bank_rshift ); 94 } 28 95 29 96 if (is_toplevel) 30 { 31 copy(); 32 } 97 copy(); 33 98 34 99 log_end(Two_Level_Branch_Predictor,FUNCTION); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_msg_error.cpp
r110 r111 29 29 Parameters_test test ("Two_Level_Branch_Predictor"); 30 30 31 if ((_have_bht or _have_pht) == false) 32 test.error(_("They have no Branch History Table and no Pattern History Table. You need a less of a BHT or a PHT\n")); 33 34 if ( _have_bht and (_size_address < _bht_size_address)) 35 test.error(_("The address's size must to large to the number of shifter in the Branch History Table.\n")); 36 37 if (_have_pht and (_size_address < _pht_size_address)) 38 test.error(_("The address's size must to large to the number of counter in the Pattern History Table.\n")); 39 40 if (_have_pht and _have_bht and (_bht_size_address > _pht_nb_counter)) 41 test.error (_("The size of shifter don't must too large that the number of counter in the Pattern History Table.\n")); 42 43 if (_have_pht and _have_bht and (_pht_size_address_share > _bht_size_shifter)) 44 test.error (_("The size of address share don't must too large that the size of shifter in the Branch History Table.\n")); 45 31 46 log_end(Two_Level_Branch_Predictor,FUNCTION); 32 47 -
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.cpp
r110 r111 72 72 if (usage_is_set(_usage,USE_SYSTEMC)) 73 73 { 74 // Constants : 75 for (uint32_t i=0; i<_param->_nb_inst_predict; ++i) 76 { 77 internal_PREDICT_ACK [i] = 1; 78 PORT_WRITE(out_PREDICT_ACK [i], internal_PREDICT_ACK [i]); 79 } 80 for (uint32_t i=0; i<_param->_nb_inst_update; ++i) 81 { 82 internal_UPDATE_ACK [i] = 1; 83 PORT_WRITE(out_UPDATE_ACK [i], internal_UPDATE_ACK [i]); 84 } 85 86 74 87 log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - transition"),_name.c_str()); 75 88 … … 82 95 # endif 83 96 84 // log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - genMoore"),_name.c_str());97 log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - genMealy_predict"),_name.c_str()); 85 98 86 // SC_METHOD (genMoore); 87 // dont_initialize (); 88 // sensitive << (*(in_CLOCK)).neg(); // need internal register 89 90 // # ifdef SYSTEMCASS_SPECIFIC 91 // // List dependency information 92 // # endif 99 SC_METHOD (genMealy_predict); 100 dont_initialize (); 101 sensitive << (*(in_CLOCK)).neg(); // need internal register 102 103 for (uint32_t i=0; i<_param->_nb_inst_predict; ++i) 104 sensitive 105 // << (*(in_PREDICT_VAL [i])) 106 << (*(in_PREDICT_ADDRESS [i])); 107 108 # ifdef SYSTEMCASS_SPECIFIC 109 // List dependency information 110 # endif 93 111 94 112 #endif -
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_allocation.cpp
r110 r111 19 19 namespace meta_predictor { 20 20 namespace two_level_branch_predictor { 21 22 23 21 24 22 #undef FUNCTION … … 58 56 in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1, RESET_VHDL_YES); 59 57 } 58 59 // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 { 61 ALLOC1_INTERFACE("predict",IN,WEST,_("Predict direction interface"),_param->_nb_inst_predict); 62 63 ALLOC1_VALACK_IN ( in_PREDICT_VAL ,VAL); 64 ALLOC1_VALACK_OUT(out_PREDICT_ACK ,ACK); 65 ALLOC1_SIGNAL_IN ( in_PREDICT_ADDRESS ,"ADDRESS" ,Taddress_t,_param->_size_address); 66 ALLOC1_SIGNAL_OUT(out_PREDICT_DIRECTION ,"DIRECTION" ,Tcontrol_t,1 ); 67 ALLOC1_SIGNAL_OUT(out_PREDICT_HISTORY ,"HISTORY" ,Thistory_t,_param->_size_history); 68 if (_param->_update_on_prediction) 69 { 70 ALLOC1_SIGNAL_IN ( in_PREDICT_DIRECTION_VAL,"DIRECTION_VAL",Tcontrol_t,1 ); 71 ALLOC1_SIGNAL_IN ( in_PREDICT_DIRECTION ,"DIRECTION" ,Tcontrol_t,1 ); 72 } 73 } 74 75 // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 76 { 77 ALLOC1_INTERFACE("update",IN,WEST,_("Update direction interface"),_param->_nb_inst_update); 78 79 ALLOC1_VALACK_IN ( in_UPDATE_VAL ,VAL); 80 ALLOC1_VALACK_OUT(out_UPDATE_ACK ,ACK); 81 ALLOC1_SIGNAL_IN ( in_UPDATE_ADDRESS ,"ADDRESS" ,Taddress_t,_param->_size_address); 82 ALLOC1_SIGNAL_IN ( in_UPDATE_HISTORY ,"HISTORY" ,Thistory_t,_param->_size_history); 83 ALLOC1_SIGNAL_IN ( in_UPDATE_DIRECTION ,"DIRECTION" ,Tcontrol_t,1 ); 84 if (_param->_update_on_prediction) 85 ALLOC1_SIGNAL_IN ( in_UPDATE_MISS ,"MISS" ,Tcontrol_t,1 ); 86 } 87 88 if (usage_is_set(_usage,USE_SYSTEMC)) 89 { 90 if (_param->_have_bht) 91 { 92 ALLOC1(reg_BHT ,Thistory_t,_param->_bht_nb_shifter); 93 94 for (uint32_t i=0; i<_param->_bht_nb_shifter; ++i) 95 reg_BHT [i] = 0; 96 } 97 98 if (_param->_have_pht) 99 { 100 ALLOC2(reg_PHT ,Thistory_t,_param->_pht_nb_bank,_param->_pht_size_bank); 101 102 for (uint32_t i=0; i<_param->_pht_nb_bank; ++i) 103 for (uint32_t j=0; j<_param->_pht_size_bank; ++j) 104 reg_PHT [i][j] = 0; 105 } 106 107 108 ALLOC1(internal_PREDICT_ACK ,Tcontrol_t,_param->_nb_inst_predict); 109 if (_param->_update_on_prediction) 110 { 111 if (_param->_have_bht) 112 ALLOC1(internal_PREDICT_BHT_NUM_REG ,Thistory_t,_param->_nb_inst_predict); 113 if (_param->_have_pht) 114 { 115 ALLOC1(internal_PREDICT_PHT_NUM_BANK ,Thistory_t,_param->_nb_inst_predict); 116 ALLOC1(internal_PREDICT_PHT_NUM_REG ,Thistory_t,_param->_nb_inst_predict); 117 } 118 } 119 ALLOC1(internal_UPDATE_ACK ,Tcontrol_t,_param->_nb_inst_update ); 120 } 121 60 122 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 61 62 123 #ifdef POSITION 63 124 if (usage_is_set(_usage,USE_POSITION)) -
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_deallocation.cpp
r110 r111 30 30 delete in_CLOCK ; 31 31 delete in_NRESET; 32 33 DELETE1_SIGNAL( in_PREDICT_VAL ,_param->_nb_inst_predict,1 ); 34 DELETE1_SIGNAL(out_PREDICT_ACK ,_param->_nb_inst_predict,1 ); 35 DELETE1_SIGNAL( in_PREDICT_ADDRESS ,_param->_nb_inst_predict,_param->_size_address); 36 DELETE1_SIGNAL(out_PREDICT_DIRECTION ,_param->_nb_inst_predict,1 ); 37 DELETE1_SIGNAL(out_PREDICT_HISTORY ,_param->_nb_inst_predict,_param->_size_history); 38 if (_param->_update_on_prediction) 39 { 40 DELETE1_SIGNAL( in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict,1 ); 41 DELETE1_SIGNAL( in_PREDICT_DIRECTION ,_param->_nb_inst_predict,1 ); 42 } 43 44 DELETE1_SIGNAL( in_UPDATE_VAL ,_param->_nb_inst_update,1 ); 45 DELETE1_SIGNAL(out_UPDATE_ACK ,_param->_nb_inst_update,1 ); 46 DELETE1_SIGNAL( in_UPDATE_ADDRESS ,_param->_nb_inst_update,_param->_size_address); 47 DELETE1_SIGNAL( in_UPDATE_HISTORY ,_param->_nb_inst_update,_param->_size_history); 48 DELETE1_SIGNAL( in_UPDATE_DIRECTION ,_param->_nb_inst_update,1 ); 49 if (_param->_update_on_prediction) 50 DELETE1_SIGNAL( in_UPDATE_MISS ,_param->_nb_inst_update,1 ); 51 52 if (_param->_have_bht) 53 DELETE1(reg_BHT ,_param->_bht_nb_shifter); 54 if (_param->_have_pht) 55 DELETE2(reg_PHT ,_param->_pht_nb_bank,_param->_pht_size_bank); 56 57 DELETE1(internal_PREDICT_ACK ,_param->_nb_inst_predict); 58 if (_param->_update_on_prediction) 59 { 60 if (_param->_have_bht) 61 DELETE1(internal_PREDICT_BHT_NUM_REG ,_param->_nb_inst_predict); 62 if (_param->_have_pht) 63 { 64 DELETE1(internal_PREDICT_PHT_NUM_BANK ,_param->_nb_inst_predict); 65 DELETE1(internal_PREDICT_PHT_NUM_REG ,_param->_nb_inst_predict); 66 } 67 } 68 DELETE1(internal_UPDATE_ACK ,_param->_nb_inst_update ); 32 69 } 33 70 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
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
r110 r111 25 25 { 26 26 log_begin(Two_Level_Branch_Predictor,FUNCTION); 27 log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str()); 28 29 if (PORT_READ(in_NRESET) == 0) 30 { 31 } 32 else 33 { 34 // =================================================================== 35 // =====[ PREDICT ]=================================================== 36 // =================================================================== 37 38 for (uint32_t i=0; i<_param->_nb_inst_predict; ++i) 39 if (PORT_READ(in_PREDICT_VAL[i]) and internal_PREDICT_ACK[i]) 40 { 41 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * PREDICT [%d]",i); 42 43 // Predict if 44 // * update_on_prediction and direction is valid 45 if (_param->_update_on_prediction) 46 if (PORT_READ(in_PREDICT_DIRECTION_VAL [i])) 47 { 48 Tcontrol_t direction = PORT_READ(in_PREDICT_DIRECTION [i]); 49 50 if (_param->_have_bht) 51 { 52 Thistory_t bht_num_reg = internal_PREDICT_BHT_NUM_REG [i]; 53 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_num_reg : %d",bht_num_reg); 54 55 Thistory_t bht_history = reg_BHT[bht_num_reg]; 56 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (old): %x",bht_history); 57 58 59 bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ; 60 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * bht_history (new): %x",bht_history); 61 reg_BHT [bht_num_reg] = bht_history; 62 } 63 64 if (_param->_have_pht) 65 { 66 Thistory_t pht_num_reg = internal_PREDICT_PHT_NUM_REG [i]; 67 Thistory_t pht_num_bank= internal_PREDICT_PHT_NUM_BANK [i]; 68 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_reg : %d",pht_num_reg); 69 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_num_bank : %d",pht_num_bank); 70 71 Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg]; 72 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (old): %x",pht_history); 73 74 // PHT : saturation counter 75 pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history)); 76 77 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * pht_history (new): %x",pht_history); 78 79 reg_PHT [pht_num_bank][pht_num_reg] = pht_history; 80 } 81 } 82 } 83 84 // =================================================================== 85 // =====[ UPDATE ]==================================================== 86 // =================================================================== 87 88 for (uint32_t i=0; i<_param->_nb_inst_update; ++i) 89 if (PORT_READ(in_UPDATE_VAL[i]) and internal_UPDATE_ACK[i]) 90 { 91 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * UPDATE [%d]",i); 92 93 // Update if 94 // * update_on_prediction and miss 95 // * 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; 101 102 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * address : %.8x",address); 103 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * direction : %d",direction); 104 105 Thistory_t pht_bht_history = 0; 106 107 if (_param->_have_bht) 108 { 109 Thistory_t bht_history = (history>>_param->_bht_history_rshift)&_param->_bht_history_mask; 110 Thistory_t bht_num_reg = address & _param->_bht_address_mask; 111 112 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); 121 reg_BHT [bht_num_reg] = bht_history; 122 } 123 124 if (_param->_have_pht) 125 { 126 Thistory_t pht_history = (history>>_param->_pht_history_rshift)&_param->_pht_history_mask; 127 Thistory_t pht_num_reg = pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift); 128 Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask; 129 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); 134 135 // 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); 139 140 reg_PHT [pht_num_bank][pht_num_reg] = pht_history; 141 } 142 } 143 } 144 } 145 146 #if defined(DEBUG) and DEBUG_Two_Level_Branch_Predictor and (DEBUG >= DEBUG_TRACE) 147 if (0) 148 { 149 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * Dump Two_Level_Branch_Predictor"); 150 151 if (_param->_have_bht) 152 { 153 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * Dump BHT"); 154 155 uint32_t limit = 4; 156 157 for (uint32_t i=0; i<_param->_bht_nb_shifter; i+=limit) 158 { 159 std::string str = ""; 160 161 for (uint32_t j=0; j<limit; j++) 162 { 163 uint32_t index = i+j; 164 if (index >= _param->_bht_nb_shifter) 165 break; 166 else 167 str+=toString("[%.4d] %.4x ",index,reg_BHT[index]); 168 } 169 170 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," %s",str.c_str()); 171 } 172 } 173 174 if (_param->_have_pht) 175 { 176 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," * Dump PHT"); 177 178 uint32_t limit = 4; 179 180 for (uint32_t num_bank=0; num_bank <_param->_pht_nb_bank; ++num_bank) 181 { 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 = ""; 187 188 for (uint32_t j=0; j<limit; j++) 189 { 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]); 195 } 196 197 log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION," %s",str.c_str()); 198 } 199 } 200 } 201 } 202 #endif 27 203 28 204 #if defined(STATISTICS) or defined(VHDL_TESTBENCH)
Note: See TracChangeset
for help on using the changeset viewer.