1 | /* |
---|
2 | * $Id: Meta_Predictor_allocation.cpp 112 2009-03-18 22:36:26Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/include/Meta_Predictor.h" |
---|
9 | #include "Behavioural/include/Allocation.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 | |
---|
20 | #undef FUNCTION |
---|
21 | #define FUNCTION "Meta_Predictor::allocation" |
---|
22 | void Meta_Predictor::allocation |
---|
23 | ( |
---|
24 | #ifdef STATISTICS |
---|
25 | morpheo::behavioural::Parameters_Statistics * param_statistics |
---|
26 | #else |
---|
27 | void |
---|
28 | #endif |
---|
29 | ) |
---|
30 | { |
---|
31 | log_begin(Meta_Predictor,FUNCTION); |
---|
32 | |
---|
33 | _component = new Component (_usage); |
---|
34 | |
---|
35 | Entity * entity = _component->set_entity (_name |
---|
36 | ,"Meta_Predictor" |
---|
37 | #ifdef POSITION |
---|
38 | ,COMBINATORY |
---|
39 | #endif |
---|
40 | ); |
---|
41 | |
---|
42 | _interfaces = entity->set_interfaces(); |
---|
43 | |
---|
44 | // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
45 | { |
---|
46 | Interface * interface = _interfaces->set_interface("" |
---|
47 | #ifdef POSITION |
---|
48 | ,IN |
---|
49 | ,SOUTH, |
---|
50 | "Generalist interface" |
---|
51 | #endif |
---|
52 | ); |
---|
53 | |
---|
54 | in_CLOCK = interface->set_signal_clk ("clock" ,1, CLOCK_VHDL_YES); |
---|
55 | in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1, RESET_VHDL_YES); |
---|
56 | } |
---|
57 | |
---|
58 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
59 | { |
---|
60 | ALLOC1_INTERFACE_BEGIN("predict",IN,WEST,_("Predict direction interface"),_param->_nb_inst_predict); |
---|
61 | |
---|
62 | ALLOC1_VALACK_IN ( in_PREDICT_VAL ,VAL); |
---|
63 | ALLOC1_VALACK_OUT(out_PREDICT_ACK ,ACK); |
---|
64 | ALLOC1_SIGNAL_IN ( in_PREDICT_ADDRESS ,"ADDRESS" ,Taddress_t,_param->_size_address); |
---|
65 | ALLOC1_SIGNAL_OUT(out_PREDICT_DIRECTION ,"DIRECTION" ,Tcontrol_t,1 ); |
---|
66 | ALLOC1_SIGNAL_OUT(out_PREDICT_HISTORY ,"HISTORY" ,Thistory_t,_param->_size_history); |
---|
67 | |
---|
68 | ALLOC1_INTERFACE_END(_param->_nb_inst_predict); |
---|
69 | } |
---|
70 | |
---|
71 | // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
72 | { |
---|
73 | ALLOC1_INTERFACE_BEGIN("update",IN,WEST,_("Update direction interface"),_param->_nb_inst_update); |
---|
74 | |
---|
75 | ALLOC1_VALACK_IN ( in_UPDATE_VAL ,VAL); |
---|
76 | ALLOC1_VALACK_OUT(out_UPDATE_ACK ,ACK); |
---|
77 | ALLOC1_SIGNAL_IN ( in_UPDATE_ADDRESS ,"ADDRESS" ,Taddress_t,_param->_size_address); |
---|
78 | ALLOC1_SIGNAL_IN ( in_UPDATE_HISTORY ,"HISTORY" ,Thistory_t,_param->_size_history); |
---|
79 | ALLOC1_SIGNAL_IN ( in_UPDATE_HISTORY_VAL ,"HISTORY_VAL" ,Tcontrol_t,1 ); |
---|
80 | ALLOC1_SIGNAL_IN ( in_UPDATE_DIRECTION ,"DIRECTION" ,Tcontrol_t,1 ); |
---|
81 | |
---|
82 | ALLOC1_INTERFACE_END(_param->_nb_inst_update); |
---|
83 | } |
---|
84 | |
---|
85 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
86 | |
---|
87 | std::string name; |
---|
88 | |
---|
89 | |
---|
90 | { |
---|
91 | _component_two_level_branch_predictor = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Two_Level_Branch_Predictor * [_param->_nb_predictor]; |
---|
92 | |
---|
93 | for (uint32_t i=0; i<_param->_nb_predictor; ++i) |
---|
94 | { |
---|
95 | name = _name+"_two_level_branch_predictor_"+toString(i); |
---|
96 | log_printf(INFO,Meta_Predictor,FUNCTION,_("Create : %s"),name.c_str()); |
---|
97 | |
---|
98 | _component_two_level_branch_predictor [i] = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Two_Level_Branch_Predictor |
---|
99 | (name.c_str() |
---|
100 | #ifdef STATISTICS |
---|
101 | ,param_statistics |
---|
102 | #endif |
---|
103 | ,_param->_param_two_level_branch_predictor[i] |
---|
104 | ,_usage); |
---|
105 | |
---|
106 | _component->set_component (_component_two_level_branch_predictor[i]->_component |
---|
107 | #ifdef POSITION |
---|
108 | , 50, 50, 10, 10 |
---|
109 | #endif |
---|
110 | ); |
---|
111 | } |
---|
112 | } |
---|
113 | |
---|
114 | { |
---|
115 | name = _name+"_glue"; |
---|
116 | log_printf(INFO,Meta_Predictor,FUNCTION,_("Create : %s"),name.c_str()); |
---|
117 | |
---|
118 | _component_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::meta_predictor_glue::Meta_Predictor_Glue |
---|
119 | (name.c_str() |
---|
120 | #ifdef STATISTICS |
---|
121 | ,param_statistics |
---|
122 | #endif |
---|
123 | ,_param->_param_glue |
---|
124 | ,_usage); |
---|
125 | |
---|
126 | _component->set_component (_component_glue->_component |
---|
127 | #ifdef POSITION |
---|
128 | , 50, 50, 10, 10 |
---|
129 | #endif |
---|
130 | ); |
---|
131 | } |
---|
132 | |
---|
133 | // ~~~~~[ Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
134 | std::string src,dest; |
---|
135 | |
---|
136 | // =================================================================== |
---|
137 | // =====[ Two_Level_Branch_Predictor ]================================ |
---|
138 | // =================================================================== |
---|
139 | |
---|
140 | for (uint32_t i=0; i<_param->_nb_predictor; ++i) |
---|
141 | { |
---|
142 | src = _name+"_two_level_branch_predictor_"+toString(i); |
---|
143 | log_printf(INFO,Prediction_unit,FUNCTION,_("Instance : %s"),src.c_str()); |
---|
144 | |
---|
145 | { |
---|
146 | dest = _name; |
---|
147 | #ifdef POSITION |
---|
148 | _component->interface_map (src ,"", |
---|
149 | dest,""); |
---|
150 | #endif |
---|
151 | |
---|
152 | PORT_MAP(_component,src , "in_CLOCK" ,dest, "in_CLOCK"); |
---|
153 | PORT_MAP(_component,src , "in_NRESET",dest, "in_NRESET"); |
---|
154 | } |
---|
155 | |
---|
156 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
157 | for (uint32_t j=0; j<_param->_nb_inst_predict; ++j) |
---|
158 | { |
---|
159 | dest = _name; |
---|
160 | |
---|
161 | #ifdef POSITION |
---|
162 | _component->interface_map (src ,"predict_"+toString(j), |
---|
163 | dest,"predict_"+toString(j)); |
---|
164 | #endif |
---|
165 | |
---|
166 | PORT_MAP(_component,src , "in_PREDICT_"+toString(j)+"_ADDRESS" , |
---|
167 | dest, "in_PREDICT_"+toString(j)+"_ADDRESS" ); |
---|
168 | |
---|
169 | dest = _name+"_glue"; |
---|
170 | |
---|
171 | #ifdef POSITION |
---|
172 | _component->interface_map (src ,"predict_"+toString(j), |
---|
173 | dest,"predict_predictor_"+toString(i)+"_"+toString(j)); |
---|
174 | #endif |
---|
175 | |
---|
176 | COMPONENT_MAP(_component,src , "in_PREDICT_" +toString(j)+"_VAL" , |
---|
177 | dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_VAL" ); |
---|
178 | COMPONENT_MAP(_component,src ,"out_PREDICT_" +toString(j)+"_ACK" , |
---|
179 | dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ACK" ); |
---|
180 | // COMPONENT_MAP(_component,src , "in_PREDICT_" +toString(j)+"_ADDRESS" , |
---|
181 | // dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ADDRESS" ); |
---|
182 | COMPONENT_MAP(_component,src ,"out_PREDICT_" +toString(j)+"_DIRECTION" , |
---|
183 | dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION" ); |
---|
184 | COMPONENT_MAP(_component,src ,"out_PREDICT_" +toString(j)+"_HISTORY" , |
---|
185 | dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_HISTORY" ); |
---|
186 | if (_param->_predictor_update_on_prediction [i]) |
---|
187 | { |
---|
188 | COMPONENT_MAP(_component,src , "in_PREDICT_" +toString(j)+"_DIRECTION_VAL", |
---|
189 | dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION_VAL"); |
---|
190 | COMPONENT_MAP(_component,src , "in_PREDICT_" +toString(j)+"_DIRECTION" , |
---|
191 | dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION" ); |
---|
192 | } |
---|
193 | } |
---|
194 | |
---|
195 | // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
196 | for (uint32_t j=0; j<_param->_nb_inst_update; ++j) |
---|
197 | { |
---|
198 | dest = _name; |
---|
199 | |
---|
200 | #ifdef POSITION |
---|
201 | _component->interface_map (src ,"update_"+toString(j), |
---|
202 | dest,"update_"+toString(j)); |
---|
203 | #endif |
---|
204 | |
---|
205 | PORT_MAP(_component,src , "in_UPDATE_"+toString(j)+"_ADDRESS" , |
---|
206 | dest, "in_UPDATE_"+toString(j)+"_ADDRESS" ); |
---|
207 | |
---|
208 | dest = _name+"_glue"; |
---|
209 | |
---|
210 | #ifdef POSITION |
---|
211 | _component->interface_map (src ,"update_"+toString(j), |
---|
212 | dest,"update_predictor_"+toString(i)+"_"+toString(j)); |
---|
213 | #endif |
---|
214 | |
---|
215 | COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_VAL" , |
---|
216 | dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_VAL" ); |
---|
217 | COMPONENT_MAP(_component,src ,"out_UPDATE_" +toString(j)+"_ACK" , |
---|
218 | dest, "in_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ACK" ); |
---|
219 | // COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_ADDRESS" , |
---|
220 | // dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ADDRESS" ); |
---|
221 | COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_DIRECTION" , |
---|
222 | dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION" ); |
---|
223 | COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_HISTORY" , |
---|
224 | dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_HISTORY" ); |
---|
225 | COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_HISTORY_VAL" , |
---|
226 | dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_HISTORY_VAL" ); |
---|
227 | if (_param->_predictor_update_on_prediction [i]) |
---|
228 | COMPONENT_MAP(_component,src , "in_UPDATE_" +toString(j)+"_MISS" , |
---|
229 | dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_MISS" ); |
---|
230 | } |
---|
231 | // // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
232 | // public : SC_IN (Tcontrol_t) ** in_UPDATE_VAL ;//[nb_inst_update] |
---|
233 | // public : SC_OUT(Tcontrol_t) ** out_UPDATE_ACK ;//[nb_inst_update] |
---|
234 | // public : SC_IN (Taddress_t) ** in_UPDATE_ADDRESS ;//[nb_inst_update] |
---|
235 | // public : SC_IN (Thistory_t) ** in_UPDATE_HISTORY ;//[nb_inst_update] |
---|
236 | // public : SC_IN (Tcontrol_t) ** in_UPDATE_DIRECTION ;//[nb_inst_update] |
---|
237 | // public : SC_IN (Tcontrol_t) ** in_UPDATE_MISS ;//[nb_inst_update] // if update_on_prediction |
---|
238 | |
---|
239 | } |
---|
240 | |
---|
241 | // =================================================================== |
---|
242 | // =====[ Glue ]====================================================== |
---|
243 | // =================================================================== |
---|
244 | |
---|
245 | { |
---|
246 | src = _name+"_glue"; |
---|
247 | log_printf(INFO,Prediction_unit,FUNCTION,_("Instance : %s"),src.c_str()); |
---|
248 | |
---|
249 | { |
---|
250 | dest = _name; |
---|
251 | #ifdef POSITION |
---|
252 | _component->interface_map (src ,"", |
---|
253 | dest,""); |
---|
254 | #endif |
---|
255 | |
---|
256 | PORT_MAP(_component,src , "in_CLOCK" ,dest, "in_CLOCK"); |
---|
257 | PORT_MAP(_component,src , "in_NRESET",dest, "in_NRESET"); |
---|
258 | } |
---|
259 | |
---|
260 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
261 | for (uint32_t i=0; i<_param->_nb_inst_predict; ++i) |
---|
262 | { |
---|
263 | dest = _name; |
---|
264 | #ifdef POSITION |
---|
265 | _component->interface_map (src ,"predict_"+toString(i), |
---|
266 | dest,"predict_"+toString(i)); |
---|
267 | #endif |
---|
268 | |
---|
269 | PORT_MAP(_component,src , "in_PREDICT_"+toString(i)+"_VAL" , |
---|
270 | dest, "in_PREDICT_"+toString(i)+"_VAL" ); |
---|
271 | PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_ACK" , |
---|
272 | dest,"out_PREDICT_"+toString(i)+"_ACK" ); |
---|
273 | PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_HISTORY" , |
---|
274 | dest,"out_PREDICT_"+toString(i)+"_HISTORY" ); |
---|
275 | PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_DIRECTION", |
---|
276 | dest,"out_PREDICT_"+toString(i)+"_DIRECTION"); |
---|
277 | } |
---|
278 | |
---|
279 | // out_PREDICT_PREDICTOR_VAL -> two_level_branch_predictor. in_PREDICT_PREDICTOR_VAL |
---|
280 | // in_PREDICT_PREDICTOR_ACK -> two_level_branch_predictor.out_PREDICT_PREDICTOR_ACK |
---|
281 | // in_PREDICT_PREDICTOR_HISTORY -> two_level_branch_predictor.out_PREDICT_PREDICTOR_HISTORY |
---|
282 | // in_PREDICT_PREDICTOR_DIRECTION -> two_level_branch_predictor.out_PREDICT_PREDICTOR_DIRECTION |
---|
283 | // out_PREDICT_PREDICTOR_DIRECTION_VAL -> two_level_branch_predictor. in_PREDICT_PREDICTOR_DIRECTION_VAL |
---|
284 | // out_PREDICT_PREDICTOR_DIRECTION -> two_level_branch_predictor. in_PREDICT_PREDICTOR_DIRECTION |
---|
285 | |
---|
286 | // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
287 | for (uint32_t i=0; i<_param->_nb_inst_update; ++i) |
---|
288 | { |
---|
289 | dest = _name; |
---|
290 | #ifdef POSITION |
---|
291 | _component->interface_map (src ,"update_"+toString(i), |
---|
292 | dest,"update_"+toString(i)); |
---|
293 | #endif |
---|
294 | |
---|
295 | PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_VAL" , |
---|
296 | dest, "in_UPDATE_"+toString(i)+"_VAL" ); |
---|
297 | PORT_MAP(_component,src ,"out_UPDATE_"+toString(i)+"_ACK" , |
---|
298 | dest,"out_UPDATE_"+toString(i)+"_ACK" ); |
---|
299 | PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_HISTORY" , |
---|
300 | dest, "in_UPDATE_"+toString(i)+"_HISTORY" ); |
---|
301 | PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_HISTORY_VAL", |
---|
302 | dest, "in_UPDATE_"+toString(i)+"_HISTORY_VAL"); |
---|
303 | PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_DIRECTION" , |
---|
304 | dest, "in_UPDATE_"+toString(i)+"_DIRECTION" ); |
---|
305 | } |
---|
306 | |
---|
307 | // out_UPDATE_PREDICTOR_VAL -> two_level_branch_predictor. in_UPDATE_PREDICTOR_VAL |
---|
308 | // in_UPDATE_PREDICTOR_ACK -> two_level_branch_predictor.out_UPDATE_PREDICTOR_ACK |
---|
309 | // out_UPDATE_PREDICTOR_HISTORY -> two_level_branch_predictor. in_UPDATE_PREDICTOR_HISTORY |
---|
310 | // out_UPDATE_PREDICTOR_HISTORY_VAL-> two_level_branch_predictor. in_UPDATE_PREDICTOR_HISTORY |
---|
311 | // out_UPDATE_PREDICTOR_DIRECTION -> two_level_branch_predictor. in_UPDATE_PREDICTOR_DIRECTION |
---|
312 | // out_UPDATE_PREDICTOR_MISS -> two_level_branch_predictor. in_UPDATE_PREDICTOR_MISS |
---|
313 | |
---|
314 | } |
---|
315 | |
---|
316 | // ~~~~~[ Others ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
317 | if (DEBUG_Meta_Predictor == true) |
---|
318 | _component->test_map(); |
---|
319 | |
---|
320 | #ifdef POSITION |
---|
321 | if (usage_is_set(_usage,USE_POSITION)) |
---|
322 | _component->generate_file(); |
---|
323 | #endif |
---|
324 | |
---|
325 | log_end(Meta_Predictor,FUNCTION); |
---|
326 | }; |
---|
327 | |
---|
328 | }; // end namespace meta_predictor |
---|
329 | }; // end namespace direction |
---|
330 | }; // end namespace prediction_unit |
---|
331 | }; // end namespace front_end |
---|
332 | }; // end namespace multi_front_end |
---|
333 | }; // end namespace core |
---|
334 | |
---|
335 | }; // end namespace behavioural |
---|
336 | }; // end namespace morpheo |
---|