[4] | 1 | #ifdef VHDL |
---|
| 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 | |
---|
| 19 | void Meta_Predictor_Glue::vhdl_body (Vhdl & vhdl) |
---|
| 20 | { |
---|
| 21 | log_printf(FUNC,Meta_Predictor_Glue,"vhdl_body","Begin"); |
---|
| 22 | vhdl.set_body (""); |
---|
| 23 | vhdl.set_body (" -- predict"); |
---|
| 24 | |
---|
| 25 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 26 | { |
---|
| 27 | string meta_predictor_ack = (_param._have_meta_predictor==true)?("in_PREDICT_PREDICTOR_0_ACK_"+toString(i)+" and in_PREDICT_PREDICTOR_1_ACK_"+toString(i)):"'1'"; |
---|
| 28 | |
---|
| 29 | vhdl.set_body ("out_PREDICT_ACK_"+toString(i)+" <= "+meta_predictor_ack+" and "+"in_PREDICT_PREDICTOR_2_ACK_"+toString(i)+";"); |
---|
| 30 | |
---|
| 31 | uint32_t index=_param._size_history; |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | if (_param._predictor_2_have_pht) |
---|
| 35 | { |
---|
| 36 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_2_pht_size_counter)+" <= in_PREDICT_PREDICTOR_2_PHT_HISTORY_"+toString(i)+";"); |
---|
| 37 | index-= _param._predictor_2_pht_size_counter; |
---|
| 38 | } |
---|
| 39 | if (_param._predictor_2_have_bht) |
---|
| 40 | { |
---|
| 41 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_2_bht_size_shifter)+" <= in_PREDICT_PREDICTOR_2_BHT_HISTORY_"+toString(i)+";"); |
---|
| 42 | index-= _param._predictor_2_bht_size_shifter; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | if (_param._have_meta_predictor) |
---|
| 46 | { |
---|
| 47 | if (_param._predictor_1_have_pht) |
---|
| 48 | { |
---|
| 49 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_1_pht_size_counter)+" <= in_PREDICT_PREDICTOR_1_PHT_HISTORY_"+toString(i)+";"); |
---|
| 50 | index-= _param._predictor_1_pht_size_counter; |
---|
| 51 | } |
---|
| 52 | if (_param._predictor_1_have_bht) |
---|
| 53 | { |
---|
| 54 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_1_bht_size_shifter)+" <= in_PREDICT_PREDICTOR_1_BHT_HISTORY_"+toString(i)+";"); |
---|
| 55 | index-= _param._predictor_1_bht_size_shifter; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | if (_param._predictor_0_have_pht) |
---|
| 59 | { |
---|
| 60 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_0_pht_size_counter)+" <= in_PREDICT_PREDICTOR_0_PHT_HISTORY_"+toString(i)+";"); |
---|
| 61 | index-= _param._predictor_0_pht_size_counter; |
---|
| 62 | } |
---|
| 63 | if (_param._predictor_0_have_bht) |
---|
| 64 | { |
---|
| 65 | vhdl.set_body ("out_PREDICT_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_0_bht_size_shifter)+" <= in_PREDICT_PREDICTOR_0_BHT_HISTORY_"+toString(i)+";"); |
---|
| 66 | index-= _param._predictor_0_bht_size_shifter; |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | // direction of prediction |
---|
| 71 | vhdl.set_body (""); |
---|
| 72 | if (_param._have_meta_predictor) |
---|
| 73 | vhdl.set_body ("out_PREDICT_DIRECTION_"+toString(i)+" <= predictor_0_direction_"+toString(i)+" when predictor_2_direction_"+toString(i)+"='0' else predictor_1_direction_"+toString(i)+";"); |
---|
| 74 | else |
---|
| 75 | vhdl.set_body ("out_PREDICT_DIRECTION_"+toString(i)+" <= predictor_2_direction_"+toString(i)+";"); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | // Interface - branch_complete |
---|
| 79 | |
---|
| 80 | vhdl.set_body (""); |
---|
| 81 | vhdl.set_body (" -- branch_complete"); |
---|
| 82 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 83 | { |
---|
| 84 | string meta_predictor_ack = (_param._have_meta_predictor==true)?("in_BRANCH_COMPLETE_PREDICTOR_0_ACK_"+toString(i)+" and in_BRANCH_COMPLETE_PREDICTOR_1_ACK_"+toString(i)):"'1'"; |
---|
| 85 | |
---|
| 86 | vhdl.set_body ("out_BRANCH_COMPLETE_ACK_"+toString(i)+" <= "+meta_predictor_ack+" and "+"in_BRANCH_COMPLETE_PREDICTOR_2_ACK_"+toString(i)+";"); |
---|
| 87 | |
---|
| 88 | uint32_t index=_param._size_history; |
---|
| 89 | |
---|
| 90 | if (_param._predictor_2_have_pht) |
---|
| 91 | { |
---|
| 92 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_2_pht_size_counter)+";"); |
---|
| 93 | index-= _param._predictor_2_pht_size_counter; |
---|
| 94 | } |
---|
| 95 | if (_param._predictor_2_have_bht) |
---|
| 96 | { |
---|
| 97 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_2_bht_size_shifter)+";"); |
---|
| 98 | index-= _param._predictor_2_bht_size_shifter; |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | if (_param._have_meta_predictor) |
---|
| 102 | { |
---|
| 103 | if (_param._predictor_1_have_pht) |
---|
| 104 | { |
---|
| 105 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_1_pht_size_counter)+";"); |
---|
| 106 | index-= _param._predictor_1_pht_size_counter; |
---|
| 107 | } |
---|
| 108 | if (_param._predictor_1_have_bht) |
---|
| 109 | { |
---|
| 110 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_1_bht_size_shifter)+";"); |
---|
| 111 | index-= _param._predictor_1_bht_size_shifter; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | if (_param._predictor_0_have_pht) |
---|
| 115 | { |
---|
| 116 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_0_pht_size_counter)+";"); |
---|
| 117 | index-= _param._predictor_0_pht_size_counter; |
---|
| 118 | } |
---|
| 119 | if (_param._predictor_0_have_bht) |
---|
| 120 | { |
---|
| 121 | vhdl.set_body ("out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY_"+toString(i)+" <= in_BRANCH_COMPLETE_HISTORY_"+toString(i)+std_logic_range(index-1,index-_param._predictor_0_bht_size_shifter)+";"); |
---|
| 122 | index-= _param._predictor_0_bht_size_shifter; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | } |
---|
| 126 | |
---|
| 127 | log_printf(FUNC,Meta_Predictor_Glue,"vhdl_body","End"); |
---|
| 128 | }; |
---|
| 129 | |
---|
| 130 | }; // end namespace meta_predictor_glue |
---|
| 131 | }; // end namespace meta_predictor |
---|
| 132 | }; // end namespace predictor |
---|
| 133 | }; // end namespace stage_1_ifetch |
---|
| 134 | |
---|
| 135 | }; // end namespace behavioural |
---|
| 136 | }; // end namespace morpheo |
---|
| 137 | #endif |
---|