[78] | 1 | /* |
---|
| 2 | * $Id: Branch_Target_Buffer_Register.cpp 132 2009-07-11 16:39:35Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Branch_Target_Buffer/Branch_Target_Buffer_Register/include/Branch_Target_Buffer_Register.h" |
---|
| 9 | |
---|
[113] | 10 | namespace morpheo { |
---|
[78] | 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_register { |
---|
| 18 | |
---|
| 19 | #undef FUNCTION |
---|
| 20 | #define FUNCTION "Branch_Target_Buffer_Register::Branch_Target_Buffer_Register" |
---|
| 21 | Branch_Target_Buffer_Register::Branch_Target_Buffer_Register |
---|
| 22 | ( |
---|
| 23 | #ifdef SYSTEMC |
---|
| 24 | sc_module_name name, |
---|
| 25 | #else |
---|
| 26 | string name, |
---|
| 27 | #endif |
---|
| 28 | #ifdef STATISTICS |
---|
| 29 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
| 30 | #endif |
---|
| 31 | morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer::branch_target_buffer_register::Parameters * param, |
---|
| 32 | morpheo::behavioural::Tusage_t usage |
---|
| 33 | ): |
---|
[113] | 34 | _name (name) |
---|
| 35 | ,_param (param) |
---|
| 36 | ,_usage (usage) |
---|
[78] | 37 | { |
---|
| 38 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
| 39 | |
---|
[123] | 40 | // #if DEBUG_Branch_Target_Buffer_Register == true |
---|
| 41 | // log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,_("<%s> Parameters"),_name.c_str()); |
---|
[88] | 42 | |
---|
[123] | 43 | // std::cout << *param << std::endl; |
---|
| 44 | // #endif |
---|
[88] | 45 | |
---|
[78] | 46 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Allocation"); |
---|
| 47 | |
---|
| 48 | allocation ( |
---|
| 49 | #ifdef STATISTICS |
---|
| 50 | param_statistics |
---|
| 51 | #endif |
---|
| 52 | ); |
---|
| 53 | |
---|
| 54 | #ifdef STATISTICS |
---|
[88] | 55 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
[78] | 56 | { |
---|
| 57 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Allocation of statistics"); |
---|
| 58 | |
---|
| 59 | statistics_allocation(param_statistics); |
---|
| 60 | } |
---|
| 61 | #endif |
---|
| 62 | |
---|
| 63 | #ifdef VHDL |
---|
[88] | 64 | if (usage_is_set(_usage,USE_VHDL)) |
---|
[78] | 65 | { |
---|
| 66 | // generate the vhdl |
---|
| 67 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Generate the vhdl"); |
---|
| 68 | |
---|
| 69 | vhdl(); |
---|
| 70 | } |
---|
| 71 | #endif |
---|
| 72 | |
---|
| 73 | #ifdef SYSTEMC |
---|
[88] | 74 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
[78] | 75 | { |
---|
[131] | 76 | #ifdef SYSTEMCASS_SPECIFIC |
---|
| 77 | constant(); |
---|
| 78 | #else |
---|
| 79 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - constant"); |
---|
[78] | 80 | |
---|
[131] | 81 | SC_METHOD (constant); |
---|
| 82 | // dont_initialize (); |
---|
| 83 | |
---|
| 84 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 85 | // List dependency information |
---|
| 86 | # endif |
---|
| 87 | #endif |
---|
| 88 | |
---|
[78] | 89 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - transition"); |
---|
| 90 | |
---|
| 91 | SC_METHOD (transition); |
---|
| 92 | dont_initialize (); |
---|
| 93 | sensitive << (*(in_CLOCK)).pos(); |
---|
| 94 | |
---|
| 95 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 96 | // List dependency information |
---|
| 97 | # endif |
---|
| 98 | |
---|
| 99 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_predict"); |
---|
| 100 | |
---|
| 101 | SC_METHOD (genMealy_predict); |
---|
| 102 | dont_initialize (); |
---|
[132] | 103 | sensitive << (*(in_CLOCK)).neg() // use internal register |
---|
| 104 | << (*(in_NRESET)); |
---|
[78] | 105 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 106 | { |
---|
| 107 | // sensitive << (*(in_PREDICT_VAL [i])) |
---|
| 108 | sensitive << (*(in_PREDICT_ADDRESS [i])); |
---|
| 109 | if (_param->_have_port_context_id) |
---|
| 110 | sensitive << (*(in_PREDICT_CONTEXT_ID [i])); |
---|
| 111 | } |
---|
| 112 | |
---|
[88] | 113 | // # ifdef SYSTEMCASS_SPECIFIC |
---|
| 114 | // // List dependency information |
---|
| 115 | // for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 116 | // for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 117 | // { |
---|
| 118 | // (*(out_PREDICT_HIT [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 119 | // if (_param->_have_port_context_id) |
---|
| 120 | // (*(out_PREDICT_HIT [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 121 | |
---|
[88] | 122 | // (*(out_PREDICT_ADDRESS_SRC [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 123 | // if (_param->_have_port_context_id) |
---|
| 124 | // (*(out_PREDICT_ADDRESS_SRC [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 125 | |
---|
[88] | 126 | // (*(out_PREDICT_ADDRESS_DEST [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 127 | // if (_param->_have_port_context_id) |
---|
| 128 | // (*(out_PREDICT_ADDRESS_DEST [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 129 | |
---|
[88] | 130 | // (*(out_PREDICT_CONDITION [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 131 | // if (_param->_have_port_context_id) |
---|
| 132 | // (*(out_PREDICT_CONDITION [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 133 | |
---|
[88] | 134 | // (*(out_PREDICT_LAST_TAKE [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 135 | // if (_param->_have_port_context_id) |
---|
| 136 | // (*(out_PREDICT_LAST_TAKE [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 137 | |
---|
[88] | 138 | // (*(out_PREDICT_IS_ACCURATE [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 139 | // if (_param->_have_port_context_id) |
---|
| 140 | // (*(out_PREDICT_IS_ACCURATE [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
| 141 | // } |
---|
| 142 | // # endif |
---|
[78] | 143 | |
---|
[82] | 144 | if (_param->_have_port_victim) |
---|
| 145 | { |
---|
[78] | 146 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_decod"); |
---|
| 147 | |
---|
| 148 | SC_METHOD (genMealy_decod); |
---|
| 149 | dont_initialize (); |
---|
[132] | 150 | sensitive << (*(in_CLOCK)).neg() // use internal register |
---|
| 151 | << (*(in_NRESET)); |
---|
[78] | 152 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 153 | { |
---|
| 154 | sensitive << (*(in_DECOD_VAL [i])) |
---|
| 155 | << (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 156 | if (_param->_have_port_context_id) |
---|
| 157 | sensitive << (*(in_DECOD_CONTEXT_ID [i])); |
---|
| 158 | } |
---|
| 159 | |
---|
[113] | 160 | // # ifdef SYSTEMCASS_SPECIFIC |
---|
| 161 | // // List dependency information |
---|
| 162 | // for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 163 | // { |
---|
| 164 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_VAL [i])); |
---|
| 165 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 166 | // if (_param->_have_port_context_id) |
---|
| 167 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_CONTEXT_ID [i])); |
---|
[78] | 168 | |
---|
[113] | 169 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_VAL [i])); |
---|
| 170 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 171 | // if (_param->_have_port_context_id) |
---|
| 172 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_CONTEXT_ID [i])); |
---|
| 173 | // } |
---|
| 174 | // #endif |
---|
| 175 | } |
---|
[78] | 176 | |
---|
[82] | 177 | if (_param->_have_port_victim) |
---|
| 178 | { |
---|
[78] | 179 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_update"); |
---|
| 180 | |
---|
| 181 | SC_METHOD (genMealy_update); |
---|
| 182 | dont_initialize (); |
---|
[132] | 183 | sensitive << (*(in_CLOCK)).neg() // use internal register |
---|
| 184 | << (*(in_NRESET)); |
---|
[78] | 185 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
| 186 | { |
---|
| 187 | sensitive << (*(in_UPDATE_VAL [i])) |
---|
| 188 | << (*(in_UPDATE_ADDRESS_SRC [i])); |
---|
| 189 | if (_param->_have_port_context_id) |
---|
| 190 | sensitive << (*(in_UPDATE_CONTEXT_ID [i])); |
---|
| 191 | } |
---|
| 192 | |
---|
[113] | 193 | // # ifdef SYSTEMCASS_SPECIFIC |
---|
| 194 | // // List dependency information |
---|
| 195 | // for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
| 196 | // { |
---|
| 197 | // (*(out_UPDATE_HIT [i])) (*(in_UPDATE_VAL [i])); |
---|
| 198 | // (*(out_UPDATE_HIT [i])) (*(in_UPDATE_ADDRESS_SRC [i])); |
---|
| 199 | // if (_param->_have_port_context_id) |
---|
| 200 | // (*(out_UPDATE_HIT [i])) (*(in_UPDATE_CONTEXT_ID [i])); |
---|
[78] | 201 | |
---|
[113] | 202 | // (*(out_UPDATE_HIT_INDEX [i])) (*(in_UPDATE_VAL [i])); |
---|
| 203 | // (*(out_UPDATE_HIT_INDEX [i])) (*(in_UPDATE_ADDRESS_SRC [i])); |
---|
| 204 | // if (_param->_have_port_context_id) |
---|
| 205 | // (*(out_UPDATE_HIT_INDEX [i])) (*(in_UPDATE_CONTEXT_ID [i])); |
---|
| 206 | // } |
---|
| 207 | // # endif |
---|
| 208 | } |
---|
[78] | 209 | #endif |
---|
| 210 | |
---|
| 211 | } |
---|
| 212 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
| 213 | }; |
---|
| 214 | |
---|
| 215 | #undef FUNCTION |
---|
| 216 | #define FUNCTION "Branch_Target_Buffer_Register::~Branch_Target_Buffer_Register" |
---|
| 217 | Branch_Target_Buffer_Register::~Branch_Target_Buffer_Register (void) |
---|
| 218 | { |
---|
| 219 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"Begin"); |
---|
| 220 | |
---|
| 221 | #ifdef STATISTICS |
---|
[88] | 222 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
[78] | 223 | { |
---|
| 224 | statistics_deallocation(); |
---|
| 225 | } |
---|
| 226 | #endif |
---|
| 227 | |
---|
| 228 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Deallocation"); |
---|
| 229 | deallocation (); |
---|
| 230 | log_printf(FUNC,Branch_Target_Buffer_Register,FUNCTION,"End"); |
---|
| 231 | }; |
---|
| 232 | |
---|
| 233 | }; // end namespace branch_target_buffer_register |
---|
| 234 | }; // end namespace branch_target_buffer |
---|
| 235 | }; // end namespace prediction_unit |
---|
| 236 | }; // end namespace front_end |
---|
| 237 | }; // end namespace multi_front_end |
---|
| 238 | }; // end namespace core |
---|
| 239 | }; // end namespace behavioural |
---|
[113] | 240 | }; // end namespace morpheo |
---|