[111] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Meta_Predictor_Glue_genMealy_update.cpp 123 2009-06-08 20:43:30Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | namespace prediction_unit { |
---|
| 17 | namespace direction { |
---|
| 18 | namespace meta_predictor { |
---|
| 19 | namespace meta_predictor_glue { |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #undef FUNCTION |
---|
| 23 | #define FUNCTION "Meta_Predictor_Glue::genMealy_update" |
---|
| 24 | void Meta_Predictor_Glue::genMealy_update (void) |
---|
| 25 | { |
---|
| 26 | log_begin(Meta_Predictor_Glue,FUNCTION); |
---|
| 27 | log_function(Meta_Predictor_Glue,FUNCTION,_name.c_str()); |
---|
| 28 | |
---|
[123] | 29 | if (PORT_READ(in_NRESET)) |
---|
| 30 | { |
---|
[111] | 31 | for (uint32_t i=0; i<_param->_nb_inst_update; ++i) |
---|
| 32 | { |
---|
[112] | 33 | Thistory_t history = PORT_READ(in_UPDATE_HISTORY [i]); |
---|
| 34 | Tcontrol_t history_val = PORT_READ(in_UPDATE_HISTORY_VAL [i]); |
---|
| 35 | Tcontrol_t direction = PORT_READ(in_UPDATE_DIRECTION [i]); |
---|
[111] | 36 | |
---|
| 37 | switch (_param->_nb_predictor) |
---|
| 38 | { |
---|
| 39 | case 1 : |
---|
| 40 | { |
---|
| 41 | Thistory_t history_0 = history; |
---|
| 42 | Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1; |
---|
[112] | 43 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY [0][i],history_0); |
---|
| 44 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [0][i],history_val); |
---|
| 45 | PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [0][i],direction); |
---|
[111] | 46 | if (_param->_predictor_update_on_prediction [0]) |
---|
[112] | 47 | PORT_WRITE(out_UPDATE_PREDICTOR_MISS [0][i],direction xor direction_old_0); |
---|
[111] | 48 | |
---|
| 49 | break; |
---|
| 50 | } |
---|
| 51 | case 3 : |
---|
| 52 | { |
---|
| 53 | /* |
---|
| 54 | dir_0 dir_1 dir_2 | good_dir || next_dir_2 |
---|
| 55 | ------------------+-----------++----------- |
---|
| 56 | 0 0 0 | 0 || no change |
---|
| 57 | 1 0 0 | 0 || 1 select pred_0 but miss |
---|
| 58 | 0 1 0 | 0 || 0 select pred_0 and hit |
---|
| 59 | 1 1 0 | 0 || no change |
---|
| 60 | 0 0 1 | 0 || no change |
---|
| 61 | 1 0 1 | 0 || 1 select pred_1 and hit |
---|
| 62 | 0 1 1 | 0 || 0 select pred_1 but miss |
---|
| 63 | 1 1 1 | 0 || no change |
---|
| 64 | 0 0 0 | 1 || no change |
---|
| 65 | 1 0 0 | 1 || 0 select pred_0 and hit |
---|
| 66 | 0 1 0 | 1 || 1 select pred_0 but miss |
---|
| 67 | 1 1 0 | 1 || no change |
---|
| 68 | 0 0 1 | 1 || no change |
---|
| 69 | 1 0 1 | 1 || 0 select pred_1 but miss |
---|
| 70 | 0 1 1 | 1 || 1 select pred_1 and hit |
---|
| 71 | 1 1 1 | 1 || no change |
---|
| 72 | |
---|
| 73 | next_dir_2 = (good_dir and dir_1) or (not good_dir and dir_0) |
---|
| 74 | */ |
---|
| 75 | |
---|
| 76 | Thistory_t history_0 = (history >>_param->_predictor_history_shift [0])&_param->_predictor_history_mask [0]; |
---|
| 77 | Thistory_t history_1 = (history >>_param->_predictor_history_shift [1])&_param->_predictor_history_mask [1]; |
---|
| 78 | Thistory_t history_2 = (history >>_param->_predictor_history_shift [2])&_param->_predictor_history_mask [2]; |
---|
| 79 | Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1; |
---|
| 80 | Tcontrol_t direction_old_1 = (history_1>>_param->_predictor_history_shift_msb[1])&1; |
---|
| 81 | Tcontrol_t direction_old_2 = (history_2>>_param->_predictor_history_shift_msb[2])&1; |
---|
| 82 | Tcontrol_t direction_new_2 = direction_old_2; |
---|
| 83 | |
---|
| 84 | // Test if two predictor is different |
---|
| 85 | if (direction_old_0 xor direction_old_1) |
---|
| 86 | direction_new_2 = (( direction and direction_old_1) or |
---|
| 87 | (not direction and direction_old_0)); |
---|
| 88 | |
---|
[112] | 89 | PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [0][i],direction); |
---|
| 90 | PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [1][i],direction); |
---|
| 91 | PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [2][i],direction_new_2); |
---|
[111] | 92 | |
---|
| 93 | if (_param->_predictor_update_on_prediction [0]) |
---|
[112] | 94 | PORT_WRITE(out_UPDATE_PREDICTOR_MISS [0][i],direction xor direction_old_0); |
---|
[111] | 95 | if (_param->_predictor_update_on_prediction [1]) |
---|
[112] | 96 | PORT_WRITE(out_UPDATE_PREDICTOR_MISS [1][i],direction xor direction_old_1); |
---|
[111] | 97 | if (_param->_predictor_update_on_prediction [2]) |
---|
[112] | 98 | PORT_WRITE(out_UPDATE_PREDICTOR_MISS [2][i],direction_new_2 xor direction_old_2); |
---|
[111] | 99 | |
---|
[112] | 100 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY [0][i],history_0); |
---|
| 101 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY [1][i],history_1); |
---|
| 102 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY [2][i],history_2); |
---|
[111] | 103 | |
---|
[112] | 104 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [0][i],history_val); |
---|
| 105 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [1][i],history_val); |
---|
| 106 | PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [2][i],history_val); |
---|
| 107 | |
---|
[111] | 108 | break; |
---|
| 109 | } |
---|
| 110 | default : |
---|
| 111 | { |
---|
| 112 | break; |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | } |
---|
[123] | 116 | } |
---|
| 117 | // else |
---|
| 118 | // { |
---|
| 119 | // // RESET |
---|
| 120 | // } |
---|
[111] | 121 | |
---|
| 122 | log_end(Meta_Predictor_Glue,FUNCTION); |
---|
| 123 | }; |
---|
| 124 | |
---|
| 125 | }; // end namespace meta_predictor_glue |
---|
| 126 | }; // end namespace meta_predictor |
---|
| 127 | }; // end namespace direction |
---|
| 128 | }; // end namespace prediction_unit |
---|
| 129 | }; // end namespace front_end |
---|
| 130 | }; // end namespace multi_front_end |
---|
| 131 | }; // end namespace core |
---|
| 132 | |
---|
| 133 | }; // end namespace behavioural |
---|
| 134 | }; // end namespace morpheo |
---|
| 135 | #endif |
---|