[2] | 1 | #ifdef VHDL |
---|
| 2 | /* |
---|
| 3 | * $Id$ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
[48] | 9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Two_Level_Branch_Predictor_Glue/include/Two_Level_Branch_Predictor_Glue.h" |
---|
[2] | 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
[48] | 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | namespace prediction_unit { |
---|
| 17 | namespace direction { |
---|
| 18 | |
---|
[2] | 19 | namespace meta_predictor { |
---|
| 20 | namespace two_level_branch_predictor { |
---|
| 21 | namespace two_level_branch_predictor_glue { |
---|
| 22 | |
---|
| 23 | |
---|
[42] | 24 | void Two_Level_Branch_Predictor_Glue::vhdl_body (Vhdl * & vhdl) |
---|
[2] | 25 | { |
---|
| 26 | log_printf(FUNC,Two_Level_Branch_Predictor_Glue,"vhdl_body","Begin"); |
---|
| 27 | |
---|
[42] | 28 | vhdl->set_body ("-- ack output"); |
---|
[2] | 29 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 30 | { |
---|
| 31 | string bht_ack, pht_ack; |
---|
| 32 | |
---|
| 33 | if (_param._have_bht) |
---|
[42] | 34 | bht_ack = "in_PREDICT_"+toString(i)+"_BHT_ACK"; |
---|
[2] | 35 | else |
---|
| 36 | bht_ack = "'1'"; |
---|
| 37 | |
---|
| 38 | if (_param._have_pht) |
---|
[42] | 39 | pht_ack = "in_PREDICT_"+toString(i)+"_PHT_ACK"; |
---|
[2] | 40 | else |
---|
| 41 | pht_ack = "'1'"; |
---|
| 42 | |
---|
[42] | 43 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_ACK <= "+bht_ack+" and "+pht_ack+";"); |
---|
[2] | 44 | } |
---|
| 45 | |
---|
| 46 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 47 | { |
---|
| 48 | string bht_ack, pht_ack; |
---|
| 49 | |
---|
| 50 | if (_param._have_bht) |
---|
[42] | 51 | bht_ack = "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK"; |
---|
[2] | 52 | else |
---|
| 53 | bht_ack = "'1'"; |
---|
| 54 | |
---|
| 55 | if (_param._have_pht) |
---|
[42] | 56 | pht_ack = "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK"; |
---|
[2] | 57 | else |
---|
| 58 | pht_ack = "'1'"; |
---|
| 59 | |
---|
[42] | 60 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_ACK <= "+bht_ack+" and "+pht_ack+";"); |
---|
[2] | 61 | } |
---|
| 62 | |
---|
[42] | 63 | vhdl->set_body (""); |
---|
| 64 | vhdl->set_body ("-- address output"); |
---|
[2] | 65 | |
---|
| 66 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
| 67 | { |
---|
| 68 | // The address is higher than the address size of bht |
---|
| 69 | if (_param._have_bht) |
---|
[42] | 70 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_BHT_ADDRESS <= in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._bht_size_address)+";"); |
---|
[2] | 71 | |
---|
| 72 | if (_param._have_pht) |
---|
| 73 | { |
---|
| 74 | // For pht : 2 cases |
---|
| 75 | if (_param._have_bht) |
---|
| 76 | { |
---|
| 77 | uint32_t min = 0; |
---|
| 78 | uint32_t max = _param._pht_size_address; |
---|
| 79 | |
---|
| 80 | // A lot of case : |
---|
| 81 | // |
---|
| 82 | // pht_size_addr |
---|
| 83 | // addr bht_history |
---|
| 84 | // |
---|
| 85 | // ---------] | |
---|
| 86 | // |[--------- |
---|
| 87 | // |
---|
| 88 | // -----------|----] share |
---|
| 89 | // | [------- |
---|
| 90 | // |
---|
| 91 | // -----------|----] no share |
---|
| 92 | // | [----- |
---|
| 93 | // |
---|
| 94 | |
---|
| 95 | // Test if address is share |
---|
| 96 | if (_param._pht_size_address_shift > 0) |
---|
| 97 | { |
---|
| 98 | min = _param._pht_size_address_shift; |
---|
[42] | 99 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(min) + " <= in_PREDICT_"+toString(i)+"_BHT_HISTORY"+std_logic_range(min)+";"); |
---|
[2] | 100 | } |
---|
| 101 | |
---|
| 102 | if (_param._bht_size_history < _param._pht_size_address) |
---|
| 103 | { |
---|
| 104 | max = _param._bht_size_history; |
---|
[42] | 105 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(_param._pht_size_address-1,max) + " <= in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address-1-_param._pht_size_address_shift, _param._pht_size_address_share)+";"); |
---|
[2] | 106 | } |
---|
| 107 | |
---|
| 108 | // intersection |
---|
| 109 | if (_param._pht_size_address_share > 0) |
---|
[42] | 110 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(max-1,min) + " <= in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address_share-1,0)+" xor in_PREDICT_"+toString(i)+"_BHT_HISTORY"+std_logic_range(max-1,min)+";"); |
---|
[2] | 111 | } |
---|
| 112 | else |
---|
[42] | 113 | vhdl->set_body ("out_PREDICT_"+toString(i)+"_PHT_ADDRESS <= in_PREDICT_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address)+";"); |
---|
[2] | 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
| 118 | { |
---|
| 119 | // The address is higher than the address size of bht |
---|
| 120 | if (_param._have_bht) |
---|
[42] | 121 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS <= in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._bht_size_address)+";"); |
---|
[2] | 122 | |
---|
| 123 | if (_param._have_pht) |
---|
| 124 | { |
---|
| 125 | // For pht : 2 cases |
---|
| 126 | if (_param._have_bht) |
---|
| 127 | { |
---|
| 128 | uint32_t min = 0; |
---|
| 129 | uint32_t max = _param._pht_size_address; |
---|
| 130 | |
---|
| 131 | // Test if address is share |
---|
| 132 | if (_param._pht_size_address_shift > 0) |
---|
| 133 | { |
---|
| 134 | min = _param._pht_size_address_shift; |
---|
[42] | 135 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(min) + " <= in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"+std_logic_range(min)+";"); |
---|
[2] | 136 | } |
---|
| 137 | |
---|
| 138 | if (_param._bht_size_history < _param._pht_size_address) |
---|
| 139 | { |
---|
| 140 | max = _param._bht_size_history; |
---|
[42] | 141 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(_param._pht_size_address-1,max) + " <= in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address-1-_param._pht_size_address_shift, _param._pht_size_address_share)+";"); |
---|
[2] | 142 | } |
---|
| 143 | |
---|
| 144 | // intersection |
---|
| 145 | if (_param._pht_size_address_share > 0) |
---|
[42] | 146 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"+std_logic_range(max-1,min) + " <= in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address_share-1,0)+" xor in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"+std_logic_range(max-1,min)+";"); |
---|
[2] | 147 | } |
---|
| 148 | else |
---|
[42] | 149 | vhdl->set_body ("out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS <= in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"+std_logic_range(_param._pht_size_address)+";"); |
---|
[2] | 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | log_printf(FUNC,Two_Level_Branch_Predictor_Glue,"vhdl_body","End"); |
---|
| 154 | }; |
---|
| 155 | |
---|
| 156 | }; // end namespace two_level_branch_predictor_glue |
---|
| 157 | }; // end namespace two_level_branch_predictor |
---|
| 158 | }; // end namespace meta_predictor |
---|
| 159 | |
---|
[48] | 160 | }; // end namespace core |
---|
| 161 | }; // end namespace multi_front_end |
---|
| 162 | }; // end namespace front_end |
---|
| 163 | }; // end namespace prediction_unit |
---|
| 164 | }; // end namespace direction |
---|
| 165 | |
---|
| 166 | |
---|
[2] | 167 | }; // end namespace behavioural |
---|
| 168 | }; // end namespace morpheo |
---|
| 169 | #endif |
---|