[2] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id$ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace stage_1_ifetch { |
---|
| 14 | namespace predictor { |
---|
| 15 | namespace meta_predictor { |
---|
| 16 | namespace two_level_branch_predictor { |
---|
| 17 | |
---|
| 18 | void Two_Level_Branch_Predictor::allocation (void) |
---|
| 19 | { |
---|
| 20 | string rename; |
---|
| 21 | |
---|
| 22 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","Begin"); |
---|
| 23 | |
---|
| 24 | in_CLOCK = new SC_CLOCK ("in_CLOCK"); |
---|
| 25 | |
---|
| 26 | in_PREDICT_VAL = new SC_IN (Tcontrol_t) * [_param._nb_prediction ]; |
---|
| 27 | out_PREDICT_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_prediction ]; |
---|
| 28 | in_PREDICT_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_prediction ]; |
---|
| 29 | if (_param._have_bht) |
---|
| 30 | out_PREDICT_BHT_HISTORY = new SC_OUT(Tbht_history_t) * [_param._nb_prediction ]; |
---|
| 31 | if (_param._have_pht) |
---|
| 32 | out_PREDICT_PHT_HISTORY = new SC_OUT(Tpht_history_t) * [_param._nb_prediction ]; |
---|
| 33 | if (_param._have_bht) |
---|
| 34 | { |
---|
| 35 | signal_PREDICT_BHT_ACK = new SC_SIGNAL(Tcontrol_t) * [_param._nb_prediction]; |
---|
| 36 | signal_PREDICT_BHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_prediction]; |
---|
| 37 | } |
---|
| 38 | if (_param._have_pht) |
---|
| 39 | { |
---|
| 40 | signal_PREDICT_PHT_ACK = new SC_SIGNAL(Tcontrol_t) * [_param._nb_prediction]; |
---|
| 41 | signal_PREDICT_PHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_prediction]; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 45 | { |
---|
[3] | 46 | rename = "in_PREDICT_VAL_" +toString(i); |
---|
[2] | 47 | in_PREDICT_VAL [i] = new SC_IN (Tcontrol_t) (rename.c_str()); |
---|
| 48 | |
---|
| 49 | rename = "out_PREDICT_ACK_" +toString(i); |
---|
| 50 | out_PREDICT_ACK [i] = new SC_OUT(Tcontrol_t) (rename.c_str()); |
---|
| 51 | |
---|
[3] | 52 | rename = "in_PREDICT_ADDRESS_" +toString(i); |
---|
[2] | 53 | in_PREDICT_ADDRESS [i] = new SC_IN (Taddress_t) (rename.c_str()); |
---|
| 54 | |
---|
| 55 | if (_param._have_bht) |
---|
| 56 | { |
---|
| 57 | rename = "out_PREDICT_BHT_HISTORY_"+toString(i); |
---|
| 58 | out_PREDICT_BHT_HISTORY [i] = new SC_OUT(Tbht_history_t) (rename.c_str()); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | if (_param._have_pht) |
---|
| 62 | { |
---|
| 63 | rename = "out_PREDICT_PHT_HISTORY_"+toString(i); |
---|
| 64 | out_PREDICT_PHT_HISTORY [i] = new SC_OUT(Tpht_history_t) (rename.c_str()); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | if (_param._have_bht) |
---|
| 68 | { |
---|
| 69 | rename = "signal_PREDICT_BHT_ACK_" +toString(i); |
---|
| 70 | signal_PREDICT_BHT_ACK [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str()); |
---|
| 71 | |
---|
| 72 | rename = "signal_PREDICT_BHT_ADDRESS_"+toString(i); |
---|
| 73 | signal_PREDICT_BHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if (_param._have_pht) |
---|
| 77 | { |
---|
| 78 | rename = "signal_PREDICT_PHT_ACK_" +toString(i); |
---|
| 79 | signal_PREDICT_PHT_ACK [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str()); |
---|
| 80 | |
---|
| 81 | rename = "signal_PREDICT_PHT_ADDRESS_"+toString(i); |
---|
| 82 | signal_PREDICT_PHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); |
---|
| 83 | } |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | in_BRANCH_COMPLETE_VAL = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 87 | out_BRANCH_COMPLETE_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 88 | in_BRANCH_COMPLETE_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_branch_complete]; |
---|
| 89 | if (_param._have_bht) |
---|
| 90 | in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete]; |
---|
| 91 | if (_param._have_pht) |
---|
| 92 | in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete]; |
---|
[3] | 93 | in_BRANCH_COMPLETE_DIRECTION = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
[2] | 94 | if (_param._have_bht) |
---|
| 95 | { |
---|
| 96 | signal_BRANCH_COMPLETE_BHT_ACK = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 97 | signal_BRANCH_COMPLETE_BHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; |
---|
| 98 | } |
---|
| 99 | if (_param._have_pht) |
---|
| 100 | { |
---|
| 101 | signal_BRANCH_COMPLETE_PHT_ACK = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete]; |
---|
| 102 | signal_BRANCH_COMPLETE_PHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 106 | { |
---|
[3] | 107 | rename = "in_BRANCH_COMPLETE_VAL_" +toString(i); |
---|
[2] | 108 | in_BRANCH_COMPLETE_VAL [i] = new SC_IN (Tcontrol_t) (rename.c_str()); |
---|
| 109 | |
---|
| 110 | rename = "out_BRANCH_COMPLETE_ACK_" +toString(i); |
---|
| 111 | out_BRANCH_COMPLETE_ACK [i] = new SC_OUT(Tcontrol_t) (rename.c_str()); |
---|
| 112 | |
---|
[3] | 113 | rename = "in_BRANCH_COMPLETE_ADDRESS_" +toString(i); |
---|
[2] | 114 | in_BRANCH_COMPLETE_ADDRESS [i] = new SC_IN (Taddress_t) (rename.c_str()); |
---|
| 115 | |
---|
| 116 | if (_param._have_bht) |
---|
| 117 | { |
---|
[3] | 118 | rename = "in_BRANCH_COMPLETE_BHT_HISTORY_"+toString(i); |
---|
[2] | 119 | in_BRANCH_COMPLETE_BHT_HISTORY [i] = new SC_IN (Tbht_history_t) (rename.c_str()); |
---|
| 120 | } |
---|
[3] | 121 | if (_param._have_pht) |
---|
[2] | 122 | { |
---|
[3] | 123 | rename = "in_BRANCH_COMPLETE_PHT_HISTORY_"+toString(i); |
---|
[2] | 124 | in_BRANCH_COMPLETE_PHT_HISTORY [i] = new SC_IN (Tpht_history_t) (rename.c_str()); |
---|
| 125 | } |
---|
[3] | 126 | rename = "in_BRANCH_COMPLETE_DIRECTION_" +toString(i); |
---|
| 127 | in_BRANCH_COMPLETE_DIRECTION [i] = new SC_IN (Tcontrol_t) (rename.c_str()); |
---|
[2] | 128 | if (_param._have_bht) |
---|
| 129 | { |
---|
| 130 | rename = "signal_BRANCH_COMPLETE_BHT_ACK_" +toString(i); |
---|
| 131 | signal_BRANCH_COMPLETE_BHT_ACK [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str()); |
---|
| 132 | |
---|
| 133 | rename = "signal_BRANCH_COMPLETE_BHT_ADDRESS_"+toString(i); |
---|
| 134 | signal_BRANCH_COMPLETE_BHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); |
---|
| 135 | } |
---|
| 136 | if (_param._have_pht) |
---|
| 137 | { |
---|
| 138 | rename = "signal_BRANCH_COMPLETE_PHT_ACK_" +toString(i); |
---|
| 139 | signal_BRANCH_COMPLETE_PHT_ACK [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str()); |
---|
| 140 | |
---|
| 141 | rename = "signal_BRANCH_COMPLETE_PHT_ADDRESS_"+toString(i); |
---|
| 142 | signal_BRANCH_COMPLETE_PHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 147 | string name_component; |
---|
| 148 | |
---|
| 149 | // =====[ component_Branch_History_Table ]============================ |
---|
| 150 | if (_param._have_bht) |
---|
| 151 | { |
---|
| 152 | name_component = _name+"_Branch_History_Table"; |
---|
[3] | 153 | |
---|
| 154 | log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str()); |
---|
[2] | 155 | |
---|
| 156 | component_Branch_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::branch_history_table ::Branch_History_Table (name_component.c_str() , |
---|
| 157 | #ifdef STATISTICS |
---|
| 158 | _param_statistics , |
---|
| 159 | #endif |
---|
| 160 | *(_param._param_branch_history_table)); |
---|
| 161 | |
---|
| 162 | // Instantiation |
---|
| 163 | (*(component_Branch_History_Table->in_CLOCK)) (*(in_CLOCK)); |
---|
| 164 | |
---|
| 165 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 166 | { |
---|
| 167 | (*(component_Branch_History_Table-> in_PREDICT_VAL [i])) (*( in_PREDICT_VAL [i])); |
---|
| 168 | (*(component_Branch_History_Table->out_PREDICT_ACK [i])) (*(signal_PREDICT_BHT_ACK [i])); |
---|
| 169 | (*(component_Branch_History_Table-> in_PREDICT_ADDRESS [i])) (*(signal_PREDICT_BHT_ADDRESS [i])); |
---|
[3] | 170 | (*(component_Branch_History_Table->out_PREDICT_HISTORY [i])) (*( out_PREDICT_BHT_HISTORY [i])); |
---|
[2] | 171 | } |
---|
| 172 | |
---|
| 173 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 174 | { |
---|
[3] | 175 | (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_VAL [i])) (*( in_BRANCH_COMPLETE_VAL [i])); |
---|
| 176 | (*(component_Branch_History_Table->out_BRANCH_COMPLETE_ACK [i])) (*(signal_BRANCH_COMPLETE_BHT_ACK [i])); |
---|
| 177 | (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_BHT_ADDRESS [i])); |
---|
| 178 | (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_HISTORY [i])) (*( in_BRANCH_COMPLETE_BHT_HISTORY [i])); |
---|
| 179 | (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_DIRECTION [i])) (*( in_BRANCH_COMPLETE_DIRECTION [i])); |
---|
[2] | 180 | } |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | // =====[ component_Pattern_History_Table ]=========================== |
---|
| 184 | if (_param._have_pht) |
---|
| 185 | { |
---|
| 186 | name_component = _name+"_Pattern_History_Table"; |
---|
| 187 | |
---|
[3] | 188 | log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str()); |
---|
| 189 | |
---|
[2] | 190 | component_Pattern_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::pattern_history_table::Pattern_History_Table (name_component.c_str() , |
---|
| 191 | #ifdef STATISTICS |
---|
| 192 | _param_statistics , |
---|
| 193 | #endif |
---|
| 194 | *(_param._param_pattern_history_table)); |
---|
| 195 | |
---|
| 196 | // Instantiation |
---|
| 197 | (*(component_Pattern_History_Table->in_CLOCK)) (*(in_CLOCK)); |
---|
| 198 | |
---|
| 199 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 200 | { |
---|
| 201 | (*(component_Pattern_History_Table-> in_PREDICT_VAL [i])) (*( in_PREDICT_VAL [i])); |
---|
| 202 | (*(component_Pattern_History_Table->out_PREDICT_ACK [i])) (*(signal_PREDICT_PHT_ACK [i])); |
---|
| 203 | (*(component_Pattern_History_Table-> in_PREDICT_ADDRESS [i])) (*(signal_PREDICT_PHT_ADDRESS [i])); |
---|
| 204 | (*(component_Pattern_History_Table->out_PREDICT_HISTORY [i])) (*( out_PREDICT_PHT_HISTORY [i])); |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 208 | { |
---|
[3] | 209 | (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_VAL [i])) (*( in_BRANCH_COMPLETE_VAL [i])); |
---|
| 210 | (*(component_Pattern_History_Table->out_BRANCH_COMPLETE_ACK [i])) (*(signal_BRANCH_COMPLETE_PHT_ACK [i])); |
---|
| 211 | (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_PHT_ADDRESS [i])); |
---|
| 212 | (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_HISTORY [i])) (*( in_BRANCH_COMPLETE_PHT_HISTORY [i])); |
---|
| 213 | (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_DIRECTION [i])) (*( in_BRANCH_COMPLETE_DIRECTION [i])); |
---|
[2] | 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | // =====[ component_Two_Level_Branch_Predictor_Glue ]=========================== |
---|
[3] | 218 | name_component = _name+"_Two_Level_Branch_Predictor_Glue"; |
---|
| 219 | |
---|
| 220 | log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str()); |
---|
| 221 | |
---|
| 222 | component_Two_Level_Branch_Predictor_Glue = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::two_level_branch_predictor_glue::Two_Level_Branch_Predictor_Glue (name_component.c_str() , |
---|
[2] | 223 | #ifdef STATISTICS |
---|
[3] | 224 | _param_statistics , |
---|
[2] | 225 | #endif |
---|
[3] | 226 | *(_param._param_two_level_branch_predictor_glue)); |
---|
| 227 | |
---|
| 228 | // Instantiation |
---|
[2] | 229 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
[3] | 230 | (*(component_Two_Level_Branch_Predictor_Glue->in_CLOCK)) (*(in_CLOCK)); |
---|
[2] | 231 | #endif |
---|
[3] | 232 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 233 | { |
---|
| 234 | if (_param._have_bht) |
---|
[2] | 235 | { |
---|
| 236 | (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_ACK [i])) (*(signal_PREDICT_BHT_ACK [i])); |
---|
| 237 | (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_BHT_ADDRESS [i])) (*(signal_PREDICT_BHT_ADDRESS [i])); |
---|
[3] | 238 | } |
---|
| 239 | if (_param._have_pht) |
---|
| 240 | { |
---|
[2] | 241 | (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_PHT_ACK [i])) (*(signal_PREDICT_PHT_ACK [i])); |
---|
| 242 | (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_PHT_ADDRESS [i])) (*(signal_PREDICT_PHT_ADDRESS [i])); |
---|
[3] | 243 | } |
---|
| 244 | if (_param._have_bht and _param._have_pht) |
---|
| 245 | { |
---|
| 246 | (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_HISTORY [i])) (*( out_PREDICT_BHT_HISTORY [i])); |
---|
| 247 | } |
---|
| 248 | (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_ACK [i])) (*( out_PREDICT_ACK [i])); |
---|
| 249 | (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_ADDRESS [i])) (*( in_PREDICT_ADDRESS [i])); |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 253 | { |
---|
| 254 | if (_param._have_bht) |
---|
[2] | 255 | { |
---|
| 256 | (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_ACK [i])) (*(signal_BRANCH_COMPLETE_BHT_ACK [i])); |
---|
| 257 | (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_BHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_BHT_ADDRESS [i])); |
---|
[3] | 258 | } |
---|
| 259 | if (_param._have_pht) |
---|
| 260 | { |
---|
[2] | 261 | (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_PHT_ACK [i])) (*(signal_BRANCH_COMPLETE_PHT_ACK [i])); |
---|
| 262 | (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_PHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_PHT_ADDRESS [i])); |
---|
[3] | 263 | } |
---|
| 264 | if (_param._have_bht and _param._have_pht) |
---|
| 265 | { |
---|
[2] | 266 | (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_BHT_HISTORY [i])); |
---|
[3] | 267 | } |
---|
| 268 | (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_ACK [i])) (*( out_BRANCH_COMPLETE_ACK [i])); |
---|
| 269 | (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_ADDRESS [i])) (*( in_BRANCH_COMPLETE_ADDRESS [i])); |
---|
[2] | 270 | } |
---|
[3] | 271 | |
---|
[2] | 272 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End"); |
---|
| 273 | }; |
---|
[3] | 274 | |
---|
[2] | 275 | }; // end namespace two_level_branch_predictor |
---|
| 276 | }; // end namespace meta_predictor |
---|
| 277 | }; // end namespace predictor |
---|
| 278 | }; // end namespace stage_1_ifetch |
---|
| 279 | }; // end namespace behavioural |
---|
| 280 | }; // end namespace morpheo |
---|
| 281 | #endif |
---|