1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Two_Level_Branch_Predictor_allocation.cpp 81 2008-04-15 18:40:01Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.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 | |
---|
19 | namespace meta_predictor { |
---|
20 | namespace two_level_branch_predictor { |
---|
21 | |
---|
22 | void Two_Level_Branch_Predictor::allocation (void) |
---|
23 | { |
---|
24 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","Begin"); |
---|
25 | |
---|
26 | _component = new Component (); |
---|
27 | |
---|
28 | Entity * entity = _component->set_entity (_name |
---|
29 | ,"Two_Level_Branch_Predictor" |
---|
30 | #ifdef POSITION |
---|
31 | ,MIXTE |
---|
32 | #endif |
---|
33 | ); |
---|
34 | |
---|
35 | _interfaces = entity->set_interfaces(); |
---|
36 | |
---|
37 | // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
38 | { |
---|
39 | Interface * interface = _interfaces->set_interface("" |
---|
40 | #ifdef POSITION |
---|
41 | , IN |
---|
42 | , SOUTH |
---|
43 | , "Generalist interface" |
---|
44 | #endif |
---|
45 | ); |
---|
46 | |
---|
47 | in_CLOCK = interface->set_signal_clk ("clock" ,1); |
---|
48 | in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1,RESET_VHDL_YES); |
---|
49 | } |
---|
50 | |
---|
51 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
52 | |
---|
53 | in_PREDICT_VAL = new SC_IN (Tcontrol_t) * [_param._nb_prediction ]; |
---|
54 | out_PREDICT_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_prediction ]; |
---|
55 | in_PREDICT_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_prediction ]; |
---|
56 | if (_param._have_bht) |
---|
57 | out_PREDICT_BHT_HISTORY = new SC_OUT(Tbht_history_t) * [_param._nb_prediction ]; |
---|
58 | if (_param._have_pht) |
---|
59 | out_PREDICT_PHT_HISTORY = new SC_OUT(Tpht_history_t) * [_param._nb_prediction ]; |
---|
60 | |
---|
61 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
62 | { |
---|
63 | Interface_fifo * interface = _interfaces->set_interface("predict_"+toString(i) |
---|
64 | #ifdef POSITION |
---|
65 | , IN |
---|
66 | , WEST |
---|
67 | , "Interface Predict" |
---|
68 | #endif |
---|
69 | ); |
---|
70 | |
---|
71 | in_PREDICT_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
72 | out_PREDICT_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
73 | in_PREDICT_ADDRESS [i] = interface->set_signal_in <Taddress_t> ("address", _param._size_address); |
---|
74 | if (_param._have_bht) |
---|
75 | out_PREDICT_BHT_HISTORY [i] = interface->set_signal_out <Tbht_history_t> ("bht_history", _param._bht_size_shifter); |
---|
76 | if (_param._have_pht) |
---|
77 | out_PREDICT_PHT_HISTORY [i] = interface->set_signal_out <Tpht_history_t> ("pht_history", _param._pht_size_counter); |
---|
78 | } |
---|
79 | |
---|
80 | // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
81 | |
---|
82 | in_BRANCH_COMPLETE_VAL = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
83 | out_BRANCH_COMPLETE_ACK = new SC_OUT(Tcontrol_t) * [_param._nb_branch_complete]; |
---|
84 | in_BRANCH_COMPLETE_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_branch_complete]; |
---|
85 | if (_param._have_bht) |
---|
86 | in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete]; |
---|
87 | if (_param._have_pht) |
---|
88 | in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete]; |
---|
89 | in_BRANCH_COMPLETE_DIRECTION = new SC_IN (Tcontrol_t) * [_param._nb_branch_complete]; |
---|
90 | |
---|
91 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
92 | { |
---|
93 | Interface_fifo * interface = _interfaces->set_interface("branch_complete_"+toString(i) |
---|
94 | #ifdef POSITION |
---|
95 | , IN |
---|
96 | , EAST |
---|
97 | , "Interface branch complete" |
---|
98 | #endif |
---|
99 | ); |
---|
100 | |
---|
101 | in_BRANCH_COMPLETE_VAL [i] = interface->set_signal_valack_in ("val" , VAL); |
---|
102 | out_BRANCH_COMPLETE_ACK [i] = interface->set_signal_valack_out ("ack" , ACK); |
---|
103 | in_BRANCH_COMPLETE_ADDRESS [i] = interface->set_signal_in <Taddress_t > ("address" , _param._size_address); |
---|
104 | if (_param._have_bht) |
---|
105 | in_BRANCH_COMPLETE_BHT_HISTORY [i] = interface->set_signal_in <Tbht_history_t> ("bht_history", _param._bht_size_shifter); |
---|
106 | if (_param._have_pht) |
---|
107 | in_BRANCH_COMPLETE_PHT_HISTORY [i] = interface->set_signal_in <Tpht_history_t> ("pht_history", _param._pht_size_counter); |
---|
108 | in_BRANCH_COMPLETE_DIRECTION [i] = interface->set_signal_in <Tcontrol_t > ("direction" , 1); |
---|
109 | } |
---|
110 | |
---|
111 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
112 | string name_component; |
---|
113 | |
---|
114 | // =====[ component_Branch_History_Table ]============================ |
---|
115 | if (_param._have_bht) |
---|
116 | { |
---|
117 | name_component = _name+"_Branch_History_Table"; |
---|
118 | |
---|
119 | component_Branch_History_Table = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::branch_history_table ::Branch_History_Table (name_component.c_str() |
---|
120 | #ifdef STATISTICS |
---|
121 | ,_param_statistics |
---|
122 | #endif |
---|
123 | ,*(_param._param_branch_history_table)); |
---|
124 | |
---|
125 | _component->set_component (component_Branch_History_Table->_component |
---|
126 | #ifdef POSITION |
---|
127 | , 75 |
---|
128 | , 25 |
---|
129 | , 10 |
---|
130 | , 10 |
---|
131 | #endif |
---|
132 | ); |
---|
133 | } |
---|
134 | |
---|
135 | // =====[ component_Pattern_History_Table ]=========================== |
---|
136 | if (_param._have_pht) |
---|
137 | { |
---|
138 | name_component = _name+"_Pattern_History_Table"; |
---|
139 | |
---|
140 | component_Pattern_History_Table = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::pattern_history_table ::Pattern_History_Table (name_component.c_str() |
---|
141 | #ifdef STATISTICS |
---|
142 | ,_param_statistics |
---|
143 | #endif |
---|
144 | ,*(_param._param_pattern_history_table)); |
---|
145 | |
---|
146 | _component->set_component (component_Pattern_History_Table->_component |
---|
147 | #ifdef POSITION |
---|
148 | , 75 |
---|
149 | , 75 |
---|
150 | , 10 |
---|
151 | , 10 |
---|
152 | #endif |
---|
153 | ); |
---|
154 | } |
---|
155 | |
---|
156 | // =====[ component_Two_Level_Branch_Predictor_Glue ]================= |
---|
157 | |
---|
158 | name_component = _name+"_Two_Level_Branch_Predictor_Glue"; |
---|
159 | |
---|
160 | component_Two_Level_Branch_Predictor_Glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::two_level_branch_predictor_glue::Two_Level_Branch_Predictor_Glue (name_component.c_str() |
---|
161 | #ifdef STATISTICS |
---|
162 | ,_param_statistics |
---|
163 | #endif |
---|
164 | ,*(_param._param_two_level_branch_predictor_glue)); |
---|
165 | |
---|
166 | _component->set_component (component_Two_Level_Branch_Predictor_Glue->_component |
---|
167 | #ifdef POSITION |
---|
168 | , 50 |
---|
169 | , 75 |
---|
170 | , 10 |
---|
171 | , 10 |
---|
172 | #endif |
---|
173 | ); |
---|
174 | |
---|
175 | // ~~~~~[ Component - Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
176 | |
---|
177 | // =====[ component_Branch_History_Table - Instanciation ]============ |
---|
178 | if (_param._have_bht) |
---|
179 | { |
---|
180 | #ifdef POSITION |
---|
181 | _component->interface_map (_name+"_Branch_History_Table","", |
---|
182 | _name ,""); |
---|
183 | #endif |
---|
184 | |
---|
185 | _component->port_map(_name+"_Branch_History_Table", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
186 | _component->port_map(_name+"_Branch_History_Table", "in_NRESET", _name,"in_NRESET"); |
---|
187 | |
---|
188 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
189 | { |
---|
190 | #ifdef POSITION |
---|
191 | _component->interface_map (_name+"_Branch_History_Table","predict_"+toString(i), |
---|
192 | _name ,"predict_"+toString(i)); |
---|
193 | #endif |
---|
194 | _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_VAL" , _name , "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
195 | _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_ACK" ); |
---|
196 | _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_BHT_ADDRESS"); |
---|
197 | _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name ,"out_PREDICT_"+toString(i)+"_BHT_HISTORY"); |
---|
198 | } |
---|
199 | |
---|
200 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
201 | { |
---|
202 | #ifdef POSITION |
---|
203 | _component->interface_map (_name+"_Branch_History_Table","branch_complete_"+toString(i), |
---|
204 | _name ,"branch_complete_"+toString(i)); |
---|
205 | #endif |
---|
206 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" ); |
---|
207 | _component->port_map(_name+"_Branch_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK" ); |
---|
208 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS" ); |
---|
209 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY" ); |
---|
210 | _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION" ); |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | // =====[ component_Pattern_History_Table - Instanciation ]=========== |
---|
215 | if (_param._have_pht) |
---|
216 | { |
---|
217 | #ifdef POSITION |
---|
218 | _component->interface_map (_name+"_Pattern_History_Table","", |
---|
219 | _name ,""); |
---|
220 | #endif |
---|
221 | |
---|
222 | _component->port_map(_name+"_Pattern_History_Table", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
223 | _component->port_map(_name+"_Pattern_History_Table", "in_NRESET", _name,"in_NRESET"); |
---|
224 | |
---|
225 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
226 | { |
---|
227 | #ifdef POSITION |
---|
228 | _component->interface_map (_name+"_Pattern_History_Table","predict_"+toString(i), |
---|
229 | _name ,"predict_"+toString(i)); |
---|
230 | #endif |
---|
231 | _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_VAL" , _name , "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
232 | _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_PHT_ACK" ); |
---|
233 | _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_PHT_ADDRESS"); |
---|
234 | _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name ,"out_PREDICT_"+toString(i)+"_PHT_HISTORY"); |
---|
235 | } |
---|
236 | |
---|
237 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
238 | { |
---|
239 | #ifdef POSITION |
---|
240 | _component->interface_map (_name+"_Pattern_History_Table","branch_complete_"+toString(i), |
---|
241 | _name ,"branch_complete_"+toString(i)); |
---|
242 | #endif |
---|
243 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL" ); |
---|
244 | _component->port_map(_name+"_Pattern_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK" ); |
---|
245 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS" ); |
---|
246 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_HISTORY" ); |
---|
247 | _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION" ); |
---|
248 | } |
---|
249 | } |
---|
250 | |
---|
251 | // =====[ component_Two_Level_Branch_Predictor_Glue - Instanciation ]= |
---|
252 | #ifdef POSITION |
---|
253 | _component->interface_map (_name+"_Two_Level_Branch_Predictor_Glue","", |
---|
254 | _name ,""); |
---|
255 | #endif |
---|
256 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_CLOCK" , _name,"in_CLOCK" ); |
---|
257 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_NRESET", _name,"in_NRESET"); |
---|
258 | |
---|
259 | for (uint32_t i=0; i<_param._nb_prediction; i++) |
---|
260 | { |
---|
261 | if (_param._have_bht) |
---|
262 | { |
---|
263 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_ACK" , _name+"_Branch_History_Table" , "out_PREDICT_"+toString(i)+"_ACK" ); |
---|
264 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" , "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
265 | } |
---|
266 | if (_param._have_pht) |
---|
267 | { |
---|
268 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_PHT_ACK" , _name+"_Pattern_History_Table", "out_PREDICT_"+toString(i)+"_ACK" ); |
---|
269 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
270 | } |
---|
271 | if (_param._have_bht and _param._have_pht) |
---|
272 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_HISTORY" , _name+"_Branch_History_Table" ,"out_PREDICT_"+toString(i)+"_HISTORY"); |
---|
273 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_ACK" , _name ,"out_PREDICT_"+toString(i)+"_ACK"); |
---|
274 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_ADDRESS" , _name , "in_PREDICT_"+toString(i)+"_ADDRESS"); |
---|
275 | } |
---|
276 | |
---|
277 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
278 | { |
---|
279 | if (_param._have_bht) |
---|
280 | { |
---|
281 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK" , _name+"_Branch_History_Table" , "out_BRANCH_COMPLETE_"+toString(i)+"_ACK" ); |
---|
282 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
283 | } |
---|
284 | if (_param._have_pht) |
---|
285 | { |
---|
286 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK" , _name+"_Pattern_History_Table", "out_BRANCH_COMPLETE_"+toString(i)+"_ACK" ); |
---|
287 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
288 | } |
---|
289 | if (_param._have_bht and _param._have_pht) |
---|
290 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"); |
---|
291 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_ACK" , _name ,"out_BRANCH_COMPLETE_"+toString(i)+"_ACK"); |
---|
292 | _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS" , _name , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"); |
---|
293 | } |
---|
294 | #ifdef POSITION |
---|
295 | _component->generate_file(); |
---|
296 | #endif |
---|
297 | |
---|
298 | log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End"); |
---|
299 | }; |
---|
300 | |
---|
301 | }; // end namespace two_level_branch_predictor |
---|
302 | }; // end namespace meta_predictor |
---|
303 | |
---|
304 | }; // end namespace core |
---|
305 | }; // end namespace multi_front_end |
---|
306 | }; // end namespace front_end |
---|
307 | }; // end namespace prediction_unit |
---|
308 | }; // end namespace direction |
---|
309 | |
---|
310 | }; // end namespace behavioural |
---|
311 | }; // end namespace morpheo |
---|
312 | #endif |
---|