source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/src/Meta_Predictor_allocation.cpp @ 111

Last change on this file since 111 was 111, checked in by rosiere, 15 years ago

1) Decod_queue : multi implementation (one_fifo, multi_fifo)
2) Issue_queue : multi implementation (in_order, out_of_order)
3) Direction : Add Meta predictor
4) Context_State : re add Branch_complete, More priority to Load miss (is not speculative)
5) Return_Address_Stack : update reg_PREDICT pointer on decod miss prediction
6) UPT : Fix bug in multi event
7) Prediction_glue : in read_stack case, insert in UPT pc_next
8) Rename select : when rob have an event (need flush), read_r{a,b,c} and write_r{d,e} is set at 0

  • Property svn:keywords set to Id
File size: 14.3 KB
Line 
1/*
2 * $Id: Meta_Predictor_allocation.cpp 111 2009-02-27 18:37:40Z 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
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18namespace 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("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
69    // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70    {
71      ALLOC1_INTERFACE("update",IN,WEST,_("Update direction interface"),_param->_nb_inst_update);
72
73      ALLOC1_VALACK_IN ( in_UPDATE_VAL           ,VAL);
74      ALLOC1_VALACK_OUT(out_UPDATE_ACK           ,ACK);
75      ALLOC1_SIGNAL_IN ( in_UPDATE_ADDRESS       ,"ADDRESS"      ,Taddress_t,_param->_size_address);
76      ALLOC1_SIGNAL_IN ( in_UPDATE_HISTORY       ,"HISTORY"      ,Thistory_t,_param->_size_history);
77      ALLOC1_SIGNAL_IN ( in_UPDATE_DIRECTION     ,"DIRECTION"    ,Tcontrol_t,1                    );
78    }
79   
80    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
82    std::string name;
83
84   
85    {
86      _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];
87
88      for (uint32_t i=0; i<_param->_nb_predictor; ++i)
89        {
90          name = _name+"_two_level_branch_predictor_"+toString(i);
91          log_printf(INFO,Meta_Predictor,FUNCTION,_("Create   : %s"),name.c_str());
92         
93          _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
94            (name.c_str()
95#ifdef STATISTICS
96             ,param_statistics
97#endif
98             ,_param->_param_two_level_branch_predictor[i]
99             ,_usage);
100         
101          _component->set_component (_component_two_level_branch_predictor[i]->_component
102#ifdef POSITION
103                                     , 50, 50, 10, 10
104#endif
105                                     );
106        }
107    }
108   
109    {
110      name = _name+"_glue";
111      log_printf(INFO,Meta_Predictor,FUNCTION,_("Create   : %s"),name.c_str());
112     
113      _component_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::meta_predictor_glue::Meta_Predictor_Glue
114        (name.c_str()
115#ifdef STATISTICS
116         ,param_statistics
117#endif
118         ,_param->_param_glue
119         ,_usage);
120     
121      _component->set_component (_component_glue->_component
122#ifdef POSITION
123                                 , 50, 50, 10, 10
124#endif
125                                 );
126    }
127   
128    // ~~~~~[ Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
129    std::string src,dest;
130
131    // ===================================================================
132    // =====[ Two_Level_Branch_Predictor ]================================
133    // ===================================================================
134   
135    for (uint32_t i=0; i<_param->_nb_predictor; ++i)
136    {
137      src = _name+"_two_level_branch_predictor_"+toString(i);
138      log_printf(INFO,Prediction_unit,FUNCTION,_("Instance : %s"),src.c_str());
139     
140      {
141        dest = _name;
142#ifdef POSITION
143        _component->interface_map (src ,"",
144                                   dest,"");
145#endif
146
147        PORT_MAP(_component,src , "in_CLOCK" ,dest, "in_CLOCK");
148        PORT_MAP(_component,src , "in_NRESET",dest, "in_NRESET");
149      }
150
151      // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152      for (uint32_t j=0; j<_param->_nb_inst_predict; ++j)
153        {
154          dest = _name;
155
156#ifdef POSITION
157          _component->interface_map (src ,"predict_"+toString(j),
158                                     dest,"predict_"+toString(j));
159#endif
160
161          PORT_MAP(_component,src , "in_PREDICT_"+toString(j)+"_ADDRESS"      ,
162                              dest, "in_PREDICT_"+toString(j)+"_ADDRESS"      );
163
164          dest = _name+"_glue";
165
166#ifdef POSITION
167          _component->interface_map (src ,"predict_"+toString(j),
168                                     dest,"predict_predictor_"+toString(i)+"_"+toString(j));
169#endif
170
171          COMPONENT_MAP(_component,src , "in_PREDICT_"                          +toString(j)+"_VAL"          ,
172                                   dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_VAL"          );
173          COMPONENT_MAP(_component,src ,"out_PREDICT_"                          +toString(j)+"_ACK"          ,
174                                   dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ACK"          );
175//        COMPONENT_MAP(_component,src , "in_PREDICT_"                          +toString(j)+"_ADDRESS"      ,
176//                                 dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ADDRESS"      );
177          COMPONENT_MAP(_component,src ,"out_PREDICT_"                          +toString(j)+"_DIRECTION"    ,
178                                   dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION"    );
179          COMPONENT_MAP(_component,src ,"out_PREDICT_"                          +toString(j)+"_HISTORY"      ,
180                                   dest, "in_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_HISTORY"      );
181          if (_param->_predictor_update_on_prediction [i])
182            {
183          COMPONENT_MAP(_component,src , "in_PREDICT_"                          +toString(j)+"_DIRECTION_VAL",
184                                   dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION_VAL");
185          COMPONENT_MAP(_component,src , "in_PREDICT_"                          +toString(j)+"_DIRECTION"    ,
186                                   dest,"out_PREDICT_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION"    );
187            }
188        }
189
190      // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191      for (uint32_t j=0; j<_param->_nb_inst_update; ++j)
192        {
193          dest = _name;
194
195#ifdef POSITION
196          _component->interface_map (src ,"update_"+toString(j),
197                                     dest,"update_"+toString(j));
198#endif
199
200          PORT_MAP(_component,src , "in_UPDATE_"+toString(j)+"_ADDRESS"      ,
201                              dest, "in_UPDATE_"+toString(j)+"_ADDRESS"      );
202
203          dest = _name+"_glue";
204
205#ifdef POSITION
206          _component->interface_map (src ,"update_"+toString(j),
207                                     dest,"update_predictor_"+toString(i)+"_"+toString(j));
208#endif
209
210          COMPONENT_MAP(_component,src , "in_UPDATE_"                          +toString(j)+"_VAL"          ,
211                                   dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_VAL"          );
212          COMPONENT_MAP(_component,src ,"out_UPDATE_"                          +toString(j)+"_ACK"          ,
213                                   dest, "in_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ACK"          );
214//        COMPONENT_MAP(_component,src , "in_UPDATE_"                          +toString(j)+"_ADDRESS"      ,
215//                                 dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_ADDRESS"      );
216          COMPONENT_MAP(_component,src , "in_UPDATE_"                          +toString(j)+"_DIRECTION"    ,
217                                   dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_DIRECTION"    );
218          COMPONENT_MAP(_component,src , "in_UPDATE_"                          +toString(j)+"_HISTORY"      ,
219                                   dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_HISTORY"      );
220          if (_param->_predictor_update_on_prediction [i])
221          COMPONENT_MAP(_component,src , "in_UPDATE_"                          +toString(j)+"_MISS"         ,
222                                   dest,"out_UPDATE_PREDICTOR_"+toString(i)+"_"+toString(j)+"_MISS"         );
223        }
224//     // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225//   public    : SC_IN (Tcontrol_t)           **  in_UPDATE_VAL           ;//[nb_inst_update]
226//   public    : SC_OUT(Tcontrol_t)           ** out_UPDATE_ACK           ;//[nb_inst_update]
227//   public    : SC_IN (Taddress_t)           **  in_UPDATE_ADDRESS       ;//[nb_inst_update]
228//   public    : SC_IN (Thistory_t)           **  in_UPDATE_HISTORY       ;//[nb_inst_update]
229//   public    : SC_IN (Tcontrol_t)           **  in_UPDATE_DIRECTION     ;//[nb_inst_update]
230//   public    : SC_IN (Tcontrol_t)           **  in_UPDATE_MISS          ;//[nb_inst_update] // if update_on_prediction
231
232    }
233     
234    // ===================================================================   
235    // =====[ Glue ]======================================================   
236    // ===================================================================   
237
238    {
239      src = _name+"_glue";
240      log_printf(INFO,Prediction_unit,FUNCTION,_("Instance : %s"),src.c_str());
241     
242      {
243        dest = _name;
244#ifdef POSITION
245        _component->interface_map (src ,"",
246                                   dest,"");
247#endif
248
249        PORT_MAP(_component,src , "in_CLOCK" ,dest, "in_CLOCK");
250        PORT_MAP(_component,src , "in_NRESET",dest, "in_NRESET");
251      }
252
253      // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254      for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
255        {
256          dest = _name;
257#ifdef POSITION
258          _component->interface_map (src ,"predict_"+toString(i),
259                                     dest,"predict_"+toString(i));
260#endif
261           
262          PORT_MAP(_component,src , "in_PREDICT_"+toString(i)+"_VAL"      ,
263                              dest, "in_PREDICT_"+toString(i)+"_VAL"      );
264          PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_ACK"      ,
265                              dest,"out_PREDICT_"+toString(i)+"_ACK"      );
266          PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_HISTORY"  ,
267                              dest,"out_PREDICT_"+toString(i)+"_HISTORY"  );
268          PORT_MAP(_component,src ,"out_PREDICT_"+toString(i)+"_DIRECTION",
269                              dest,"out_PREDICT_"+toString(i)+"_DIRECTION");
270        }
271
272      //  out_PREDICT_PREDICTOR_VAL           -> two_level_branch_predictor. in_PREDICT_PREDICTOR_VAL         
273      //   in_PREDICT_PREDICTOR_ACK           -> two_level_branch_predictor.out_PREDICT_PREDICTOR_ACK         
274      //   in_PREDICT_PREDICTOR_HISTORY       -> two_level_branch_predictor.out_PREDICT_PREDICTOR_HISTORY     
275      //   in_PREDICT_PREDICTOR_DIRECTION     -> two_level_branch_predictor.out_PREDICT_PREDICTOR_DIRECTION   
276      //  out_PREDICT_PREDICTOR_DIRECTION_VAL -> two_level_branch_predictor. in_PREDICT_PREDICTOR_DIRECTION_VAL
277      //  out_PREDICT_PREDICTOR_DIRECTION     -> two_level_branch_predictor. in_PREDICT_PREDICTOR_DIRECTION   
278
279      // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280      for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
281        {
282          dest = _name;
283#ifdef POSITION
284          _component->interface_map (src ,"update_"+toString(i),
285                                     dest,"update_"+toString(i));
286#endif
287
288          PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_VAL"      ,
289                              dest, "in_UPDATE_"+toString(i)+"_VAL"      );
290          PORT_MAP(_component,src ,"out_UPDATE_"+toString(i)+"_ACK"      ,
291                              dest,"out_UPDATE_"+toString(i)+"_ACK"      );
292          PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_HISTORY"  ,
293                              dest, "in_UPDATE_"+toString(i)+"_HISTORY"  );
294          PORT_MAP(_component,src , "in_UPDATE_"+toString(i)+"_DIRECTION",
295                              dest, "in_UPDATE_"+toString(i)+"_DIRECTION");
296        }
297     
298      //  out_UPDATE_PREDICTOR_VAL       -> two_level_branch_predictor. in_UPDATE_PREDICTOR_VAL     
299      //   in_UPDATE_PREDICTOR_ACK       -> two_level_branch_predictor.out_UPDATE_PREDICTOR_ACK     
300      //  out_UPDATE_PREDICTOR_HISTORY   -> two_level_branch_predictor. in_UPDATE_PREDICTOR_HISTORY 
301      //  out_UPDATE_PREDICTOR_DIRECTION -> two_level_branch_predictor. in_UPDATE_PREDICTOR_DIRECTION
302      //  out_UPDATE_PREDICTOR_MISS      -> two_level_branch_predictor. in_UPDATE_PREDICTOR_MISS     
303
304    }
305
306    // ~~~~~[ Others ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
307     if (DEBUG_Meta_Predictor == true)
308       _component->test_map();
309
310#ifdef POSITION
311     if (usage_is_set(_usage,USE_POSITION))
312       _component->generate_file();
313#endif
314
315     log_end(Meta_Predictor,FUNCTION);
316  };
317
318}; // end namespace meta_predictor
319}; // end namespace direction
320}; // end namespace prediction_unit
321}; // end namespace front_end
322}; // end namespace multi_front_end
323}; // end namespace core
324
325}; // end namespace behavioural
326}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.