[78] | 1 | /* |
---|
| 2 | * $Id: Branch_Target_Buffer_Glue.cpp 81 2008-04-15 18:40:01Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/Branch_Target_Buffer_Glue/include/Branch_Target_Buffer_Glue.h" |
---|
| 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | namespace core { |
---|
| 13 | namespace multi_front_end { |
---|
| 14 | namespace front_end { |
---|
| 15 | namespace prediction_unit { |
---|
| 16 | namespace branch_target_buffer { |
---|
| 17 | namespace branch_target_buffer_glue { |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #undef FUNCTION |
---|
| 21 | #define FUNCTION "Branch_Target_Buffer_Glue::Branch_Target_Buffer_Glue" |
---|
| 22 | Branch_Target_Buffer_Glue::Branch_Target_Buffer_Glue |
---|
| 23 | ( |
---|
| 24 | #ifdef SYSTEMC |
---|
| 25 | sc_module_name name, |
---|
| 26 | #else |
---|
| 27 | string name, |
---|
| 28 | #endif |
---|
| 29 | #ifdef STATISTICS |
---|
| 30 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
| 31 | #endif |
---|
| 32 | morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer::branch_target_buffer_glue::Parameters * param, |
---|
| 33 | morpheo::behavioural::Tusage_t usage |
---|
| 34 | ): |
---|
| 35 | _name (name) |
---|
| 36 | ,_param (param) |
---|
| 37 | ,_usage (usage) |
---|
| 38 | { |
---|
| 39 | log_printf(FUNC,Branch_Target_Buffer_Glue,FUNCTION,"Begin"); |
---|
| 40 | |
---|
| 41 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Allocation"); |
---|
| 42 | |
---|
| 43 | allocation ( |
---|
| 44 | #ifdef STATISTICS |
---|
| 45 | param_statistics |
---|
| 46 | #endif |
---|
| 47 | ); |
---|
| 48 | |
---|
| 49 | #ifdef STATISTICS |
---|
| 50 | if (_usage & USE_STATISTICS) |
---|
| 51 | { |
---|
| 52 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Allocation of statistics"); |
---|
| 53 | |
---|
| 54 | statistics_allocation(param_statistics); |
---|
| 55 | } |
---|
| 56 | #endif |
---|
| 57 | |
---|
| 58 | #ifdef VHDL |
---|
| 59 | if (_usage & USE_VHDL) |
---|
| 60 | { |
---|
| 61 | // generate the vhdl |
---|
| 62 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Generate the vhdl"); |
---|
| 63 | |
---|
| 64 | vhdl(); |
---|
| 65 | } |
---|
| 66 | #endif |
---|
| 67 | |
---|
| 68 | #ifdef SYSTEMC |
---|
| 69 | if (_usage & USE_SYSTEMC) |
---|
| 70 | { |
---|
| 71 | # if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 72 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Method - transition"); |
---|
| 73 | |
---|
| 74 | SC_METHOD (transition); |
---|
| 75 | dont_initialize (); |
---|
| 76 | sensitive << (*(in_CLOCK)).pos(); |
---|
| 77 | |
---|
| 78 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 79 | // List dependency information |
---|
| 80 | # endif |
---|
| 81 | # endif |
---|
| 82 | |
---|
| 83 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Method - genMealy_predict"); |
---|
| 84 | |
---|
| 85 | SC_METHOD (genMealy_predict); |
---|
| 86 | dont_initialize (); |
---|
| 87 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
| 88 | |
---|
| 89 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 90 | { |
---|
| 91 | sensitive << (*(in_PREDICT_VAL [i])) |
---|
| 92 | << (*(in_PREDICT_REGISTER_ACK [i])); |
---|
| 93 | if (_param->_have_port_victim) |
---|
| 94 | sensitive << (*(in_PREDICT_SORT_VAL [i])) |
---|
| 95 | << (*(in_PREDICT_SORT_INDEX [i])) |
---|
| 96 | << (*(in_PREDICT_VICTIM_ACK [i])); |
---|
| 97 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 98 | sensitive << (*(in_PREDICT_REGISTER_HIT [i][j])) |
---|
| 99 | << (*(in_PREDICT_REGISTER_ADDRESS_SRC [i][j])) |
---|
| 100 | << (*(in_PREDICT_REGISTER_ADDRESS_DEST [i][j])) |
---|
| 101 | << (*(in_PREDICT_REGISTER_CONDITION [i][j])) |
---|
| 102 | << (*(in_PREDICT_REGISTER_LAST_TAKE [i][j])) |
---|
| 103 | << (*(in_PREDICT_REGISTER_IS_ACCURATE [i][j])); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 107 | // List dependency information |
---|
| 108 | |
---|
| 109 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 110 | { |
---|
| 111 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 112 | (*(out_PREDICT_HIT [i])) (*(in_PREDICT_REGISTER_HIT [i][j])); |
---|
| 113 | if (_param->_have_port_victim) |
---|
| 114 | (*(out_PREDICT_HIT [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 115 | |
---|
| 116 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 117 | (*(out_PREDICT_ADDRESS_SRC [i])) (*(in_PREDICT_REGISTER_ADDRESS_SRC [i][j])); |
---|
| 118 | if (_param->_have_port_victim) |
---|
| 119 | (*(out_PREDICT_ADDRESS_SRC [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 120 | |
---|
| 121 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 122 | (*(out_PREDICT_ADDRESS_DEST [i])) (*(in_PREDICT_REGISTER_ADDRESS_DEST [i][j])); |
---|
| 123 | if (_param->_have_port_victim) |
---|
| 124 | (*(out_PREDICT_ADDRESS_DEST [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 125 | |
---|
| 126 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 127 | (*(out_PREDICT_CONDITION [i])) (*(in_PREDICT_REGISTER_CONDITION [i][j])); |
---|
| 128 | if (_param->_have_port_victim) |
---|
| 129 | (*(out_PREDICT_CONDITION [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 130 | |
---|
| 131 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 132 | (*(out_PREDICT_LAST_TAKE [i])) (*(in_PREDICT_REGISTER_LAST_TAKE [i][j])); |
---|
| 133 | if (_param->_have_port_victim) |
---|
| 134 | (*(out_PREDICT_LAST_TAKE [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 135 | |
---|
| 136 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 137 | (*(out_PREDICT_IS_ACCURATE [i])) (*(in_PREDICT_REGISTER_IS_ACCURATE [i][j])); |
---|
| 138 | if (_param->_have_port_victim) |
---|
| 139 | (*(out_PREDICT_IS_ACCURATE [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_REGISTER_ACK [i])); |
---|
| 143 | if (_param->_have_port_victim) |
---|
| 144 | { |
---|
| 145 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_SORT_VAL [i])); |
---|
| 146 | (*(out_PREDICT_ACK [i])) (*(in_PREDICT_VICTIM_ACK [i])); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | (*(out_PREDICT_REGISTER_VAL [i])) (*(in_PREDICT_VAL [i])); |
---|
| 150 | if (_param->_have_port_victim) |
---|
| 151 | { |
---|
| 152 | (*(out_PREDICT_REGISTER_VAL [i])) (*(in_PREDICT_SORT_VAL [i])); |
---|
| 153 | (*(out_PREDICT_REGISTER_VAL [i])) (*(in_PREDICT_VICTIM_ACK [i])); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | if (_param->_have_port_victim) |
---|
| 157 | { |
---|
| 158 | (*(out_PREDICT_VICTIM_VAL [i])) (*(in_PREDICT_VAL [i])); |
---|
| 159 | (*(out_PREDICT_VICTIM_VAL [i])) (*(in_PREDICT_REGISTER_ACK [i])); |
---|
| 160 | (*(out_PREDICT_VICTIM_VAL [i])) (*(in_PREDICT_SORT_VAL [i])); |
---|
| 161 | |
---|
| 162 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 163 | (*(out_PREDICT_VICTIM_HIT [i])) (*(in_PREDICT_REGISTER_HIT [i][j])); |
---|
| 164 | (*(out_PREDICT_VICTIM_HIT [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 165 | |
---|
| 166 | if (not _param->_is_full_associative) |
---|
| 167 | { |
---|
| 168 | for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 169 | (*(out_PREDICT_VICTIM_ADDRESS [i])) (*(in_PREDICT_REGISTER_ADDRESS_SRC [i][j])); |
---|
| 170 | (*(out_PREDICT_VICTIM_ADDRESS [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 171 | } |
---|
| 172 | (*(out_PREDICT_VICTIM_INDEX [i])) (*(in_PREDICT_SORT_INDEX [i])); |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | # endif |
---|
| 176 | |
---|
| 177 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Method - genMealy_decod"); |
---|
| 178 | |
---|
| 179 | SC_METHOD (genMealy_decod); |
---|
| 180 | dont_initialize (); |
---|
| 181 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
| 182 | |
---|
| 183 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 184 | { |
---|
| 185 | sensitive << (*(in_DECOD_VAL [i])) |
---|
| 186 | << (*(in_DECOD_REGISTER_ACK [i])); |
---|
| 187 | if (_param->_have_port_victim) |
---|
| 188 | { |
---|
| 189 | if (not _param->_is_full_associative) |
---|
| 190 | sensitive << (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 191 | sensitive << (*(in_DECOD_VICTIM_ACK [i])); |
---|
| 192 | } |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 196 | // List dependency information |
---|
| 197 | |
---|
| 198 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 199 | { |
---|
| 200 | (*(out_DECOD_ACK [i])) (*(in_DECOD_REGISTER_ACK [i])); |
---|
| 201 | if (_param->_have_port_victim) |
---|
| 202 | (*(out_DECOD_ACK [i])) (*(in_DECOD_VICTIM_ACK [i])); |
---|
| 203 | |
---|
| 204 | (*(out_DECOD_REGISTER_VAL [i])) (*(in_DECOD_VAL [i])); |
---|
| 205 | if (_param->_have_port_victim) |
---|
| 206 | (*(out_DECOD_REGISTER_VAL [i])) (*(in_DECOD_VICTIM_ACK [i])); |
---|
| 207 | |
---|
| 208 | if (_param->_have_port_victim) |
---|
| 209 | { |
---|
| 210 | (*(out_DECOD_VICTIM_VAL [i])) (*(in_DECOD_VAL [i])); |
---|
| 211 | (*(out_DECOD_VICTIM_VAL [i])) (*(in_DECOD_REGISTER_ACK [i])); |
---|
| 212 | |
---|
| 213 | if (not _param->_is_full_associative) |
---|
| 214 | (*(out_DECOD_VICTIM_ADDRESS [i])) (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 215 | } |
---|
| 216 | } |
---|
| 217 | # endif |
---|
| 218 | |
---|
| 219 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Method - genMealy_update"); |
---|
| 220 | |
---|
| 221 | SC_METHOD (genMealy_update); |
---|
| 222 | dont_initialize (); |
---|
| 223 | // sensitive << (*(in_CLOCK)).neg(); // don't use internal register |
---|
| 224 | |
---|
| 225 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
| 226 | { |
---|
| 227 | sensitive << (*(in_UPDATE_VAL [i])) |
---|
| 228 | << (*(in_UPDATE_REGISTER_ACK [i])); |
---|
| 229 | if (_param->_have_port_victim) |
---|
| 230 | { |
---|
| 231 | if (not _param->_is_full_associative) |
---|
| 232 | sensitive << (*(in_UPDATE_ADDRESS_SRC [i])); |
---|
| 233 | sensitive << (*(in_UPDATE_VICTIM_ACK [i])); |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 238 | // List dependency information |
---|
| 239 | |
---|
| 240 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
| 241 | { |
---|
| 242 | (*(out_UPDATE_ACK [i])) (*(in_UPDATE_REGISTER_ACK [i])); |
---|
| 243 | if (_param->_have_port_victim) |
---|
| 244 | (*(out_UPDATE_ACK [i])) (*(in_UPDATE_VICTIM_ACK [i])); |
---|
| 245 | |
---|
| 246 | (*(out_UPDATE_REGISTER_VAL [i])) (*(in_UPDATE_VAL [i])); |
---|
| 247 | if (_param->_have_port_victim) |
---|
| 248 | (*(out_UPDATE_REGISTER_VAL [i])) (*(in_UPDATE_VICTIM_ACK [i])); |
---|
| 249 | |
---|
| 250 | if (_param->_have_port_victim) |
---|
| 251 | { |
---|
| 252 | (*(out_UPDATE_VICTIM_VAL [i])) (*(in_UPDATE_VAL [i])); |
---|
| 253 | (*(out_UPDATE_VICTIM_VAL [i])) (*(in_UPDATE_REGISTER_ACK [i])); |
---|
| 254 | |
---|
| 255 | if (not _param->_is_full_associative) |
---|
| 256 | (*(out_UPDATE_VICTIM_ADDRESS [i])) (*(in_UPDATE_ADDRESS_SRC [i])); |
---|
| 257 | } |
---|
| 258 | } |
---|
| 259 | # endif |
---|
| 260 | |
---|
| 261 | #endif |
---|
| 262 | } |
---|
| 263 | log_printf(FUNC,Branch_Target_Buffer_Glue,FUNCTION,"End"); |
---|
| 264 | }; |
---|
| 265 | |
---|
| 266 | #undef FUNCTION |
---|
| 267 | #define FUNCTION "Branch_Target_Buffer_Glue::~Branch_Target_Buffer_Glue" |
---|
| 268 | Branch_Target_Buffer_Glue::~Branch_Target_Buffer_Glue (void) |
---|
| 269 | { |
---|
| 270 | log_printf(FUNC,Branch_Target_Buffer_Glue,FUNCTION,"Begin"); |
---|
| 271 | |
---|
| 272 | #ifdef STATISTICS |
---|
| 273 | if (_usage & USE_STATISTICS) |
---|
| 274 | { |
---|
| 275 | statistics_deallocation(); |
---|
| 276 | } |
---|
| 277 | #endif |
---|
| 278 | |
---|
| 279 | log_printf(INFO,Branch_Target_Buffer_Glue,FUNCTION,"Deallocation"); |
---|
| 280 | deallocation (); |
---|
| 281 | |
---|
| 282 | log_printf(FUNC,Branch_Target_Buffer_Glue,FUNCTION,"End"); |
---|
| 283 | }; |
---|
| 284 | |
---|
| 285 | }; // end namespace branch_target_buffer_glue |
---|
| 286 | }; // end namespace branch_target_buffer |
---|
| 287 | }; // end namespace prediction_unit |
---|
| 288 | }; // end namespace front_end |
---|
| 289 | }; // end namespace multi_front_end |
---|
| 290 | }; // end namespace core |
---|
| 291 | |
---|
| 292 | }; // end namespace behavioural |
---|
| 293 | }; // end namespace morpheo |
---|