[78] | 1 | /* |
---|
| 2 | * $Id: Branch_Target_Buffer_Register.cpp 113 2009-04-14 18:39:12Z 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 | |
---|
[88] | 40 | #if DEBUG_Branch_Target_Buffer_Register == true |
---|
| 41 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,_("<%s> Parameters"),_name.c_str()); |
---|
| 42 | |
---|
| 43 | std::cout << *param << std::endl; |
---|
| 44 | #endif |
---|
| 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 | { |
---|
| 76 | // Constant |
---|
| 77 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 78 | { |
---|
| 79 | PORT_WRITE(out_PREDICT_ACK [i],1); |
---|
| 80 | } |
---|
| 81 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 82 | { |
---|
| 83 | internal_DECOD_ACK [i] = 1; |
---|
| 84 | PORT_WRITE(out_DECOD_ACK [i], internal_DECOD_ACK [i]); |
---|
| 85 | } |
---|
| 86 | for (uint32_t i=0; i<_param->_nb_inst_update; i++) |
---|
| 87 | { |
---|
| 88 | internal_UPDATE_ACK [i] = 1; |
---|
| 89 | PORT_WRITE(out_UPDATE_ACK [i], internal_UPDATE_ACK [i]); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - transition"); |
---|
| 93 | |
---|
| 94 | SC_METHOD (transition); |
---|
| 95 | dont_initialize (); |
---|
| 96 | sensitive << (*(in_CLOCK)).pos(); |
---|
| 97 | |
---|
| 98 | # ifdef SYSTEMCASS_SPECIFIC |
---|
| 99 | // List dependency information |
---|
| 100 | # endif |
---|
| 101 | |
---|
| 102 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_predict"); |
---|
| 103 | |
---|
| 104 | SC_METHOD (genMealy_predict); |
---|
| 105 | dont_initialize (); |
---|
| 106 | sensitive << (*(in_CLOCK)).neg(); // use internal register |
---|
| 107 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 108 | { |
---|
| 109 | // sensitive << (*(in_PREDICT_VAL [i])) |
---|
| 110 | sensitive << (*(in_PREDICT_ADDRESS [i])); |
---|
| 111 | if (_param->_have_port_context_id) |
---|
| 112 | sensitive << (*(in_PREDICT_CONTEXT_ID [i])); |
---|
| 113 | } |
---|
| 114 | |
---|
[88] | 115 | // # ifdef SYSTEMCASS_SPECIFIC |
---|
| 116 | // // List dependency information |
---|
| 117 | // for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 118 | // for (uint32_t j=0; j<_param->_associativity; j++) |
---|
| 119 | // { |
---|
| 120 | // (*(out_PREDICT_HIT [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 121 | // if (_param->_have_port_context_id) |
---|
| 122 | // (*(out_PREDICT_HIT [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 123 | |
---|
[88] | 124 | // (*(out_PREDICT_ADDRESS_SRC [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 125 | // if (_param->_have_port_context_id) |
---|
| 126 | // (*(out_PREDICT_ADDRESS_SRC [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 127 | |
---|
[88] | 128 | // (*(out_PREDICT_ADDRESS_DEST [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 129 | // if (_param->_have_port_context_id) |
---|
| 130 | // (*(out_PREDICT_ADDRESS_DEST [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 131 | |
---|
[88] | 132 | // (*(out_PREDICT_CONDITION [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 133 | // if (_param->_have_port_context_id) |
---|
| 134 | // (*(out_PREDICT_CONDITION [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 135 | |
---|
[88] | 136 | // (*(out_PREDICT_LAST_TAKE [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 137 | // if (_param->_have_port_context_id) |
---|
| 138 | // (*(out_PREDICT_LAST_TAKE [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
[78] | 139 | |
---|
[88] | 140 | // (*(out_PREDICT_IS_ACCURATE [i][j])) (*(in_PREDICT_ADDRESS [i])); |
---|
| 141 | // if (_param->_have_port_context_id) |
---|
| 142 | // (*(out_PREDICT_IS_ACCURATE [i][j])) (*(in_PREDICT_CONTEXT_ID [i])); |
---|
| 143 | // } |
---|
| 144 | // # endif |
---|
[78] | 145 | |
---|
[82] | 146 | if (_param->_have_port_victim) |
---|
| 147 | { |
---|
[78] | 148 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_decod"); |
---|
| 149 | |
---|
| 150 | SC_METHOD (genMealy_decod); |
---|
| 151 | dont_initialize (); |
---|
| 152 | sensitive << (*(in_CLOCK)).neg(); // use internal register |
---|
| 153 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 154 | { |
---|
| 155 | sensitive << (*(in_DECOD_VAL [i])) |
---|
| 156 | << (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 157 | if (_param->_have_port_context_id) |
---|
| 158 | sensitive << (*(in_DECOD_CONTEXT_ID [i])); |
---|
| 159 | } |
---|
| 160 | |
---|
[113] | 161 | // # ifdef SYSTEMCASS_SPECIFIC |
---|
| 162 | // // List dependency information |
---|
| 163 | // for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 164 | // { |
---|
| 165 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_VAL [i])); |
---|
| 166 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 167 | // if (_param->_have_port_context_id) |
---|
| 168 | // (*(out_DECOD_HIT [i])) (*(in_DECOD_CONTEXT_ID [i])); |
---|
[78] | 169 | |
---|
[113] | 170 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_VAL [i])); |
---|
| 171 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_ADDRESS_SRC [i])); |
---|
| 172 | // if (_param->_have_port_context_id) |
---|
| 173 | // (*(out_DECOD_HIT_INDEX [i])) (*(in_DECOD_CONTEXT_ID [i])); |
---|
| 174 | // } |
---|
| 175 | // #endif |
---|
| 176 | } |
---|
[78] | 177 | |
---|
[82] | 178 | if (_param->_have_port_victim) |
---|
| 179 | { |
---|
[78] | 180 | log_printf(INFO,Branch_Target_Buffer_Register,FUNCTION,"Method - genMealy_update"); |
---|
| 181 | |
---|
| 182 | SC_METHOD (genMealy_update); |
---|
| 183 | dont_initialize (); |
---|
| 184 | sensitive << (*(in_CLOCK)).neg(); // use internal register |
---|
| 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 |
---|