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