[5] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id$ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace stage_1_ifetch { |
---|
| 14 | namespace predictor { |
---|
| 15 | namespace meta_predictor { |
---|
| 16 | namespace meta_predictor_glue { |
---|
| 17 | |
---|
| 18 | void Meta_Predictor_Glue::genMealy_branch_complete_val (void) |
---|
| 19 | { |
---|
| 20 | log_printf(FUNC,Meta_Predictor_Glue,"genMealy_branch_complete_val","Begin"); |
---|
| 21 | |
---|
| 22 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 23 | { |
---|
| 24 | Tcontrol_t val = PORT_READ(in_BRANCH_COMPLETE_VAL [i]); |
---|
| 25 | Thistory_t history = PORT_READ(in_BRANCH_COMPLETE_HISTORY [i]); |
---|
| 26 | Tcontrol_t direction = PORT_READ(in_BRANCH_COMPLETE_DIRECTION [i]); |
---|
| 27 | |
---|
| 28 | Tcontrol_t predictor_0_direction = (history>>(_param._shift_2-1))&1; |
---|
| 29 | Tcontrol_t predictor_1_direction = (history>>(_param._shift_4-1))&1; |
---|
| 30 | // Tcontrol_t predictor_2_direction = (history>>(_param._shift_6-1))&1; |
---|
| 31 | |
---|
| 32 | // log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","direction_(predictor_0 %d, predictor_1 %d, predictor_2 %d, good %d)", predictor_0_direction, predictor_1_direction, predictor_2_direction, direction); |
---|
| 33 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","direction_(predictor_0 %d, predictor_1 %d, good %d)", predictor_0_direction, predictor_1_direction, direction); |
---|
| 34 | |
---|
| 35 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_0 : %d >>(%d-1)",history,_param._shift_2); |
---|
| 36 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_1 : %d >>(%d-1)",history,_param._shift_4); |
---|
| 37 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_2 : %d >>(%d-1)",history,_param._shift_6); |
---|
| 38 | |
---|
| 39 | /* |
---|
| 40 | dir_0 dir_1 dir_2 | good_dir || next_dir_2 |
---|
| 41 | ------------------+-----------++----------- |
---|
| 42 | 0 0 0 | 0 || no change |
---|
| 43 | 1 0 0 | 0 || 1 select pred_0 but miss |
---|
| 44 | 0 1 0 | 0 || 0 select pred_0 and hit |
---|
| 45 | 1 1 0 | 0 || no change |
---|
| 46 | 0 0 1 | 0 || no change |
---|
| 47 | 1 0 1 | 0 || 1 select pred_1 and hit |
---|
| 48 | 0 1 1 | 0 || 0 select pred_1 but miss |
---|
| 49 | 1 1 1 | 0 || no change |
---|
| 50 | 0 0 0 | 1 || no change |
---|
| 51 | 1 0 0 | 1 || 0 select pred_0 and hit |
---|
| 52 | 0 1 0 | 1 || 1 select pred_0 but miss |
---|
| 53 | 1 1 0 | 1 || no change |
---|
| 54 | 0 0 1 | 1 || no change |
---|
| 55 | 1 0 1 | 1 || 0 select pred_1 but miss |
---|
| 56 | 0 1 1 | 1 || 1 select pred_1 and hit |
---|
| 57 | 1 1 1 | 1 || no change |
---|
| 58 | |
---|
| 59 | next_dir_2 = (good_dir and dir_1) or (not good_dir and dir_0) |
---|
| 60 | */ |
---|
| 61 | |
---|
| 62 | Tcontrol_t branch_complete_predictor_2_val = val and (predictor_0_direction xor predictor_1_direction); |
---|
| 63 | Tcontrol_t branch_complete_predictor_2_direction = ( (not direction and predictor_0_direction) or |
---|
| 64 | ( direction and predictor_1_direction) ); |
---|
| 65 | |
---|
| 66 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","branch_complete_predictor_2_( val %d, direction %d)",branch_complete_predictor_2_val, branch_complete_predictor_2_direction); |
---|
| 67 | |
---|
| 68 | // Modify meta_predictor if have a branch_complete and twice prediction have not predict the same way |
---|
| 69 | PORT_WRITE(out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION [i], branch_complete_predictor_2_direction); |
---|
| 70 | PORT_WRITE(out_BRANCH_COMPLETE_PREDICTOR_2_VAL [i], branch_complete_predictor_2_val ); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | log_printf(FUNC,Meta_Predictor_Glue,"genMealy_branch_complete_val","End"); |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | }; // end namespace meta_predictor_glue |
---|
| 77 | }; // end namespace meta_predictor |
---|
| 78 | }; // end namespace predictor |
---|
| 79 | }; // end namespace stage_1_ifetch |
---|
| 80 | }; // end namespace behavioural |
---|
| 81 | }; // end namespace morpheo |
---|
| 82 | #endif |
---|