source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp @ 106

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

1) RAT : Fix bug when update and event in same cycle
2) Context State : Compute depth
3) Load Store Unit : In check logic, translate all access in little endian. More easy to check
4) UFPT : End Event

  • Property svn:keywords set to Id
File size: 49.2 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Update_Prediction_Table_transition.cpp 106 2009-02-09 22:55:26Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace update_prediction_table {
18
19#undef  FUNCTION
20#define FUNCTION "Update_Prediction_Table::transition"
21  void Update_Prediction_Table::transition (void)
22  {
23    log_begin(Update_Prediction_Table,FUNCTION);
24    log_function(Update_Prediction_Table,FUNCTION,_name.c_str());
25
26    if (PORT_READ(in_NRESET) == 0)
27      {
28        // Initialisation
29
30        reg_UPDATE_PRIORITY = 0;
31
32        // All pointer is set at 0
33        for (uint32_t i=0; i<_param->_nb_context; i++)
34          {
35            for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
36              reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
37            reg_UFPT_BOTTOM          [i] = 0;
38            reg_UFPT_TOP             [i] = 0;
39            reg_UFPT_UPDATE          [i] = 0;
40            reg_UFPT_NB_NEED_UPDATE  [i] = 0;
41            reg_UFPT_NB_UPDATE       [i] = 0;
42                                                               
43            for (uint32_t j=0; j<_param->_size_upt_queue[i]; ++j)
44              reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EMPTY;
45            reg_UPT_BOTTOM           [i] = 0;
46            reg_UPT_TOP              [i] = 0;
47            reg_UPT_TOP_EVENT        [i] = 0;
48            reg_UPT_UPDATE           [i] = 0;
49            reg_UPT_EMPTY            [i] = true;
50                                                                                   
51            reg_IS_ACCURATE          [i] = true;
52           
53            reg_EVENT_VAL            [i] = false;
54            reg_EVENT_STATE          [i] = EVENT_STATE_OK;
55          }
56      }
57    else
58      {
59        bool flush_UFPT    [_param->_nb_context];
60        for (uint32_t i=0; i<_param->_nb_context; i++)
61          {
62            flush_UFPT    [i] = false;
63          }
64
65        // ===================================================================
66        // =====[ GARBAGE COLLECTOR ]=========================================
67        // ===================================================================
68
69        // Each cycle, if the most lastest branch have update all prediction struction (state = end), free this slot
70        //   * Update state -> new status is "empty"
71        //   * Update pointer (bottom and accurate)
72        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR (BEGIN)");
73        for (uint32_t i=0; i<_param->_nb_context; i++)
74          {
75            // UPDATE_FETCH_PREDICTION_TABLE
76            {
77              uint32_t bottom = reg_UFPT_BOTTOM [i];
78             
79              // Test if state is end
80              if (reg_UPDATE_FETCH_PREDICTION_TABLE [i][bottom]._state == UPDATE_FETCH_PREDICTION_STATE_END)
81                {
82                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d]",i,bottom);
83                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state =  UPDATE_FETCH_PREDICTION_STATE_EMPTY",i,bottom);
84
85                  // Free slot
86                  reg_UPDATE_FETCH_PREDICTION_TABLE [i][bottom]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
87                  // Update pointer
88                  reg_UFPT_BOTTOM [i] = (bottom+1)%_param->_size_ufpt_queue[i];
89                }
90            }
91
92            // UPDATE_PREDICTION_TABLE
93            {
94              uint32_t      bottom      = reg_UPT_BOTTOM [i];
95              bool          end         = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END);
96//               bool          end_ok      = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_OK);
97//               bool          end_ko      = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_KO);
98//               event_state_t event_state = reg_EVENT_STATE [i];
99
100              // Test if state is end
101//               if (end_ok or end_ko)
102              if (end)
103                {
104                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]",i,bottom);
105                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]._state =  UPDATE_PREDICTION_STATE_EMPTY",i,bottom);
106                  // Free slot
107                  reg_UPDATE_PREDICTION_TABLE [i][bottom]._state = UPDATE_PREDICTION_STATE_EMPTY;
108
109                  // Update pointer
110                  reg_UPT_BOTTOM [i] = (bottom+1)%_param->_size_upt_queue[i];
111                 
112                  if (reg_UPT_BOTTOM [i] == reg_UPT_TOP [i])
113                    reg_UPT_EMPTY [i] = true; // free a slot
114
115//                   if (bottom = reg_UPT_UPDATE [i])
116//                     reg_UPT_UPDATE [i] = reg_UPT_BOTTOM [i];
117
118                  if (reg_EVENT_VAL [i] and (reg_EVENT_UPT_PTR [i] == bottom))
119                    {
120                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * END EVENT");
121                     
122                      reg_EVENT_VAL  [i] = false;
123                      reg_UPT_TOP    [i] = reg_UPT_TOP_EVENT [i];
124                      reg_UPT_UPDATE [i] = reg_UPT_TOP_EVENT [i];
125                     
126                      if (reg_UPT_BOTTOM [i] != reg_UPT_TOP [i])
127                        reg_UPT_EMPTY [i] = false;
128                    }
129
130                }
131            }
132          }
133
134        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * GARBAGE COLLECTOR (END)");
135
136        // ===================================================================
137        // =====[ PREDICT ]===================================================
138        // ===================================================================
139       
140        // An ifetch_unit compute next cycle and have an branch : predict_val is set
141        //   * Alloc new entry -> new status is "wait decod"
142        //   * Save input (to restore in miss or error)
143        //   * Update pointer
144
145        for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
146          if (PORT_READ(in_PREDICT_VAL[i]) and internal_PREDICT_ACK [i])
147            {
148              Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0;
149              uint32_t   top     = internal_PREDICT_UPDATE_PREDICTION_ID [i];
150
151              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * PREDICT[%d] - Accepted",i);
152              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
153              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top     : %d",top);
154
155#ifdef DEBUG_TEST
156              if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state != UPDATE_FETCH_PREDICTION_STATE_EMPTY)
157                throw ERRORMORPHEO(FUNCTION,_("Predict : invalid state."));
158#endif
159
160              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD (predict)",context,top);
161              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._state        = UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD;
162
163              Tbranch_condition_t condition = PORT_READ(in_PREDICT_BTB_CONDITION [i]);
164
165              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._condition    = condition;
166              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_src  = PORT_READ(in_PREDICT_BTB_ADDRESS_SRC  [i]);
167              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_dest = PORT_READ(in_PREDICT_BTB_ADDRESS_DEST [i]);
168              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._last_take    = PORT_READ(in_PREDICT_BTB_LAST_TAKE    [i]);
169              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._is_accurate  = PORT_READ(in_PREDICT_BTB_IS_ACCURATE  [i]);
170              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._history      = (_param->_have_port_history)?PORT_READ(in_PREDICT_DIR_HISTORY [i]):0;
171              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._address_ras  = PORT_READ(in_PREDICT_RAS_ADDRESS      [i]);
172              reg_UPDATE_FETCH_PREDICTION_TABLE [context][top]._index_ras    = PORT_READ(in_PREDICT_RAS_INDEX        [i]);
173
174              reg_UFPT_TOP     [context] = (top+1)%_param->_size_ufpt_queue [context];
175//            reg_UFPT_UPDATE  [context] = reg_UFPT_TOP [context];
176              if (need_update(condition))
177                reg_UFPT_NB_NEED_UPDATE [context] ++;
178            }
179
180        // ===================================================================
181        // =====[ DECOD ]=====================================================
182        // ===================================================================
183
184
185        // An decod is detected by decod stage
186        //   1) Hit prediction : The instruction bundle have a branch predicted in ifetch stage and it is this branch
187        //      * Update state, wait_decod -> wait_end
188        //      * Pop ufpt -> push upt
189        //      * Update accurate register : if the predict stage have tagged this branch as not accurate, stop decod
190        //   2) Miss           : The instruction bundle have a branch but it is not predicted
191        //      * Flush ufpt
192        //      * decod information is write in upt
193
194        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
195          if (PORT_READ(in_DECOD_VAL[i]) and internal_DECOD_ACK [i])
196            {
197              Tcontext_t          context       = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
198              Tcontrol_t          miss_ifetch   = PORT_READ(in_DECOD_MISS_IFETCH [i]);
199              Tcontrol_t          miss_decod    = PORT_READ(in_DECOD_MISS_DECOD  [i]);
200              uint32_t            upt_ptr_write = internal_DECOD_UPT_PTR_WRITE [i];
201              Tbranch_condition_t condition  ;
202              Tcontrol_t          is_accurate;
203              Taddress_t          address_src   = PORT_READ(in_DECOD_BTB_ADDRESS_SRC  [i]);
204              Taddress_t          address_dest  = PORT_READ(in_DECOD_BTB_ADDRESS_DEST [i]);
205              Tcontrol_t          last_take     = PORT_READ(in_DECOD_BTB_LAST_TAKE    [i]);
206
207              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD[%d] - Accepted",i);
208              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context       : %d",context);
209              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_ifetch   : %d",miss_ifetch);
210              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_decod    : %d",miss_decod);
211              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * upt_ptr_write : %d",upt_ptr_write);
212             
213              if (miss_ifetch or miss_decod)
214                {
215                  // Have a miss !!!
216#ifdef DEBUG_TEST
217                  if (reg_EVENT_STATE [context] != EVENT_STATE_OK)
218                    throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
219#endif
220                 
221                  if (reg_UFPT_NB_NEED_UPDATE [context] == 0)
222                    {
223                      // Change state
224                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_UPDATE_CONTEXT (decod - miss - no flush ufpt)",context);
225                      reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
226                    }
227                  else
228                    {
229                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT (decod - miss - flush ufpt)",context);
230                      reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT;
231                    }
232
233                  // Flush UPFT
234                  flush_UFPT [context] = true;
235
236                  reg_EVENT_DEPTH           [context] = upt_ptr_write;
237                  reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
238                  reg_EVENT_ADDRESS_DEST_VAL[context] = last_take;
239                  reg_EVENT_ADDRESS_DEST    [context] = address_dest;
240
241                  // Push upt (from decod interface)
242                  condition   = PORT_READ(in_DECOD_BTB_CONDITION [i]);
243                  is_accurate = PORT_READ(in_DECOD_IS_ACCURATE   [i]);
244
245                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._condition         = condition;
246                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = address_src ;
247                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = address_dest;
248                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = last_take   ;
249//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
250                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
251//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._history           = ; // static prediction
252                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras       = PORT_READ(in_DECOD_RAS_ADDRESS [i]);
253                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras         = PORT_READ(in_DECOD_RAS_INDEX   [i]);
254                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = false; // static prediction
255                }
256              else
257                {
258                  // Normal case : branch is previous predicated, change state of branch
259                  uint32_t ufpt_ptr_read = (_param->_have_port_depth)?PORT_READ(in_DECOD_UPDATE_PREDICTION_ID [i]):0;
260
261                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * ufpt_ptr_read : %d",ufpt_ptr_read);
262
263#ifdef DEBUG_TEST
264                  if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._state != UPDATE_FETCH_PREDICTION_STATE_WAIT_DECOD)
265                    throw ERRORMORPHEO(FUNCTION,_("Decod : invalid ufpt state."));
266#endif
267                  // Change state
268                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (decod - hit)",context,ufpt_ptr_read);
269                  reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._state = UPDATE_FETCH_PREDICTION_STATE_END;
270
271                  // Push upt (from Pop ufpt)
272                  condition   = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._condition;
273                  is_accurate = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._is_accurate;
274
275                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._condition         = condition;
276                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_src       = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_src ;
277                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_dest      = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_dest;
278                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._last_take         = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._last_take   ;
279//                reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._good_take;
280                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._is_accurate       = is_accurate;
281                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._history           = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._history     ;
282                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras       = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_ras ;
283                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras         = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._index_ras   ;
284                  reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true ; // prediction from ifetch
285
286                  // Update pointer
287                  if (need_update(condition))
288                    {
289                      reg_UFPT_NB_NEED_UPDATE [context] --;
290                    }
291                }
292
293              // All case !!!
294#ifdef DEBUG_TEST
295              if (reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state != UPDATE_PREDICTION_STATE_EMPTY)
296                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid upt state."));
297#endif
298             
299              // Change state
300              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_WAIT_END (decod - hit)",context,upt_ptr_write);
301              reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state = UPDATE_PREDICTION_STATE_WAIT_END;
302             
303              // Write new accurate
304#ifdef DEBUG_TEST
305              if (not reg_IS_ACCURATE [context]  and not is_accurate)
306                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid accurate flag."));
307#endif
308              reg_IS_ACCURATE [context] = is_accurate;
309             
310              // Update pointer
311              reg_UPT_TOP     [context] = (upt_ptr_write+1)%_param->_size_upt_queue [context];
312              reg_UPT_EMPTY   [context] = false;
313//            reg_UPT_UPDATE  [context] = reg_UPT_TOP [context];
314            }
315
316        // ===================================================================
317        // =====[ BRANCH_COMPLETE ]===========================================
318        // ===================================================================
319       
320        // The branch is complete
321        //   * Hit  prediction :
322        //     * update status
323        //   * Miss prediction :
324        for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
325          if (PORT_READ(in_BRANCH_COMPLETE_VAL[i]) and internal_BRANCH_COMPLETE_ACK [i])
326            {
327              Tcontext_t context   = (_param->_have_port_context_id)?PORT_READ(in_BRANCH_COMPLETE_CONTEXT_ID [i]):0;
328              Tdepth_t   depth     = (_param->_have_port_depth     )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
329              Tcontrol_t miss      = internal_BRANCH_COMPLETE_MISS_PREDICTION [i];
330              Tcontrol_t good_take = internal_BRANCH_COMPLETE_TAKE            [i];
331              Taddress_t good_addr = internal_BRANCH_COMPLETE_ADDRESS_DEST    [i];
332
333              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_COMPLETE[%d] - Accepted",i);
334              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context    : %d",context);
335              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth      : %d",depth);
336              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss       : %d",miss);
337             
338              if (miss)
339                {
340                  // Have a miss !!!
341                  // Flush UPFT
342                  flush_UFPT [context] = true;
343                 
344                  // Flush UPT
345                  uint32_t top        = reg_UPT_TOP [context];
346                  uint32_t new_update = ((top==0)?_param->_size_upt_queue[context]:top)-1; 
347
348                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top        : %d",top);
349                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update : %d",new_update);
350
351                  for (uint32_t j=(depth+1)%_param->_size_upt_queue[context];
352                                j!=top; 
353                                j=(j+1)%_param->_size_upt_queue[context])
354                    reg_UPDATE_PREDICTION_TABLE [context][j]._state = UPDATE_PREDICTION_STATE_EVENT;
355                 
356                 
357//                reg_UPT_BOTTOM    [context];
358                  reg_UPT_TOP       [context] = depth;
359                  reg_UPT_TOP_EVENT [context] = top;
360
361                  if (reg_UPT_BOTTOM [context] == reg_UPT_TOP [context])
362                    reg_UPT_EMPTY [context] = true;
363
364#ifdef DEBUG_TEST
365                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
366                    throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
367#endif
368                 
369                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_KO (branch_complete, ifetch hit)",context,depth);
370                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_KO;
371                 
372                  Taddress_t    address_src         = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
373                  event_state_t event_state         = reg_EVENT_STATE [context];
374                  bool          previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
375                                                       (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
376                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
377                                                       (event_state == EVENT_STATE_EVENT_FLUSH_UPT));
378//                   bool          update_ras          = (new_update != depth);
379
380//                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
381
382                  if (reg_UFPT_NB_NEED_UPDATE [context] > 0)
383                    {
384                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);
385                      reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT;
386                    }
387                  else
388                    {
389//                       if (not previous_update_ras)
390                        {
391                          // have ras prediction ?
392                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UPT (branch_complete - miss)",context);
393
394                          reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT;
395             
396                        }
397                    }
398
399                  if (not previous_update_ras)
400                    {
401                      reg_UPT_UPDATE [context]  = new_update;
402                    }
403                  // else no update
404
405                  reg_EVENT_DEPTH           [context] = depth;
406                  reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
407                  reg_EVENT_ADDRESS_DEST_VAL[context] = good_take;
408                  reg_EVENT_ADDRESS_DEST    [context] = good_addr;
409                }
410              else
411                {
412                  // Hit case
413
414#ifdef DEBUG_TEST
415                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
416                    throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
417#endif
418                   
419                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_OK (branch_complete, ifetch hit)",context,depth);
420                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_OK;
421                }
422
423              // In all case : update good_take
424              reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take = good_take;
425            }
426
427        // ===================================================================
428        // =====[ UPDATE ]====================================================
429        // ===================================================================
430        {
431          bool can_continue [_param->_nb_context];
432          for (uint32_t i=0; i<_param->_nb_context; ++i)
433            can_continue [i] = true;
434
435          for (uint32_t i=0; i<_param->_nb_inst_update; i++)
436            {
437              Tcontext_t context   = internal_UPDATE_CONTEXT_ID [i];
438
439              if ((internal_UPDATE_VAL[i] and PORT_READ(in_UPDATE_ACK [i])) or
440                  (internal_UPDATE_VAL_WITHOUT_ACK [i] and can_continue [context]))
441                {
442                  Tdepth_t   depth     = internal_UPDATE_DEPTH      [i];
443                 
444                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
445                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
446                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
447                 
448                  if (internal_UPDATE_FROM_UFPT [i])
449                    {
450                      // if free a slot, also all queue is updated
451                      // Last slot ?
452//                       if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
453                      if ((--reg_UFPT_NB_UPDATE [context])==0)
454                        switch (reg_EVENT_STATE [context])
455                          {
456                          case EVENT_STATE_MISS_FLUSH_UFPT         : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
457                            // impossible to have an update on ufpt and reg_upt_update>reg_upt_top
458                          case EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT ; break;
459                          case EVENT_STATE_EVENT_FLUSH_UFPT        : reg_EVENT_STATE [context] = EVENT_STATE_OK             ; break;
460                          case EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT: reg_EVENT_STATE [context] = EVENT_STATE_EVENT_FLUSH_UPT; break;
461                          default : break;
462                          }
463                     
464                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
465                     
466                      // Change state
467#ifdef DEBUG_TEST
468                      if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state != UPDATE_FETCH_PREDICTION_STATE_EVENT)
469                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid ufpt state."));
470#endif
471                     
472                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (update)",context,depth);
473                     
474                      reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
475                                           
476                      // Update pointer
477                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (before) : %d",reg_UFPT_UPDATE [context]);
478                      reg_UFPT_UPDATE [context] = ((depth==0)?_param->_size_ufpt_queue[context]:depth)-1;
479                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (after ) : %d",reg_UFPT_UPDATE [context]);
480                      // Free a register that need update ?
481                      if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
482                        reg_UFPT_NB_NEED_UPDATE [context] --;
483                    }
484                  else
485                    {
486                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Prediction Table");
487                     
488                      // Change state
489#ifdef DEBUG_TEST
490                      if (internal_UPDATE_RAS [i])
491                        {
492                          if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT) and
493                              (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ) )
494                            throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
495                        }
496                      else
497                        {
498                          if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_OK   )
499                            throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
500                        }
501#endif
502
503//                    bool have_event = ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO) or
504//                                       (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_EVENT));
505#ifdef STATISTICS
506                      Tbranch_condition_t condition = reg_UPDATE_PREDICTION_TABLE [context][depth]._condition;
507                      bool ok     = (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_OK);
508#endif
509                      bool ko     = (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO);
510
511                      // Have an update, test the state to transiste to the good state
512                      if (ko)
513                        {
514                          // Ko : wait end of all instruction
515//                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO_WAIT_END (update)",context,depth);
516                         
517//                           reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO_WAIT_END;
518
519                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",context,depth);
520                         
521                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
522
523                          reg_EVENT_VAL     [context] = true;
524                          reg_EVENT_UPT_PTR [context] = depth;
525
526#ifdef STATISTICS
527                          if (usage_is_set(_usage,USE_STATISTICS))
528                            (*_stat_nb_branch_miss [context][condition])++;
529#endif
530                        }
531                      else
532                        {
533//                           log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_OK (update)",context,depth);
534//                           reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_OK;
535
536                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (update)",context,depth);
537                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END;
538
539#ifdef STATISTICS
540                          if (usage_is_set(_usage,USE_STATISTICS))
541                            {
542                              if (ok)
543                                (*_stat_nb_branch_hit    [context][condition]) ++;
544                              else
545                                (*_stat_nb_branch_unused [context]) ++;
546                            }
547#endif
548                        }
549                     
550                      // Update pointer
551                      //  * if update RAS : update pointer is decreaste until it equal at top pointer
552                      if (internal_UPDATE_RAS [i])
553                        {
554                          // if end_event, restart too bottom, else decrease pointer
555                          bool end_event  = (reg_UPT_UPDATE [context] == reg_UPT_TOP [context]);
556                         
557                          reg_UPT_UPDATE [context] = (end_event)?reg_UPT_BOTTOM[context]:(((depth==0)?_param->_size_upt_queue[context]:depth)-1);
558                          if (end_event)
559                            {
560//                               reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context];
561
562                              if (reg_EVENT_STATE [context] == EVENT_STATE_EVENT_FLUSH_UPT)
563                                {
564                                  reg_EVENT_STATE [context] = EVENT_STATE_OK;
565                                }
566                              else
567                                reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
568                            }
569                          else
570                            {
571                              reg_UPT_UPDATE [context] = (((depth==0)?_param->_size_upt_queue[context]:depth)-1);
572                            }
573                        }
574                      else
575                        {
576                          // increase pointer
577                          reg_UPT_UPDATE [context] = (depth+1)%_param->_size_upt_queue[context];
578                        }
579                     
580                      // Free the branch with no accurate ?
581                      if ( (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false) and not ko)
582                        reg_IS_ACCURATE [context] = true;
583                    }
584                }
585              else
586                can_continue [context] = false;
587            }
588       
589          // Round robin
590          reg_UPDATE_PRIORITY = (reg_UPDATE_PRIORITY+1)%_param->_nb_context;
591        }
592
593        // ===================================================================
594        // =====[ BRANCH_EVENT ]==============================================
595        // ===================================================================
596        for (uint32_t i=0; i<_param->_nb_context; i++)
597          if (internal_BRANCH_EVENT_VAL [i] and PORT_READ(in_BRANCH_EVENT_ACK [i]))
598            {
599              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_EVENT [%d] - Accepted",i);
600
601#ifdef DEBUG_TEST
602              if (reg_EVENT_STATE [i] != EVENT_STATE_UPDATE_CONTEXT)
603                throw ERRORMORPHEO(FUNCTION,_("Decod : invalid event state."));
604#endif
605             
606              // Change state
607              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_WAIT_END_EVENT (branch_event)",i);
608             
609              reg_EVENT_STATE [i] = EVENT_STATE_WAIT_END_EVENT;
610            }
611
612        // ===================================================================
613        // =====[ EVENT ]=====================================================
614        // ===================================================================
615        for (uint32_t i=0; i<_param->_nb_context; ++i)
616          if (PORT_READ(in_EVENT_VAL [i]) and internal_EVENT_ACK [i])
617            {
618              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * EVENT");
619
620              //----------------------------------------------------------------
621              // Cases
622              //----------------------------------------------------------------
623              //   * EVENT_TYPE_NONE               - nothing
624              //   * EVENT_TYPE_MISS_SPECULATION   - Change state, reset pointer
625              //   * EVENT_TYPE_EXCEPTION          - Flush upft and upt, Change state, reset pointer
626              //   * EVENT_TYPE_BRANCH_NO_ACCURATE - nothing : manage in decod and update
627              //   * EVENT_TYPE_SPR_ACCESS         - nothing
628              //   * EVENT_TYPE_MSYNC              - nothing
629              //   * EVENT_TYPE_PSYNC              - nothing
630              //   * EVENT_TYPE_CSYNC              - nothing
631             
632              Tevent_type_t  event_type  = PORT_READ(in_EVENT_TYPE  [i]);
633
634              // Test if end of miss -> all previous branch is complete
635              //                     -> all next     branch is finish
636
637              switch (event_type)
638                {
639                case EVENT_TYPE_BRANCH_MISS_SPECULATION :
640                  {
641                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_BRANCH_MISS_SPECULATION");
642                   
643#ifdef DEBUG_TEST
644                    if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
645                      throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
646#endif
647                   
648                    // Change state
649                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
650                   
651                    reg_EVENT_STATE [i] = EVENT_STATE_OK;
652                    reg_IS_ACCURATE [i] = true;
653
654                    Tdepth_t depth = reg_EVENT_UPT_PTR [i];
655
656                    if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state == UPDATE_PREDICTION_STATE_END_KO)
657                      {
658                        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (event)",i,depth);
659                       
660                        reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END;
661                      }
662
663#ifdef DEBUG_TEST
664//                     if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END)
665//                       throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
666//                  if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO)
667//                    throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state."));
668#endif
669
670//                     log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth);
671                   
672//                     reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
673                   
674                    break;
675                  }
676                case EVENT_TYPE_LOAD_MISS_SPECULATION :
677                case EVENT_TYPE_EXCEPTION             :
678                  {
679                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_LOAD_MISS_SPECULATION");
680
681                    // Have a miss !!!
682                    // Flush UPFT
683                    flush_UFPT [i] = true;
684                   
685                    // Flush UPT
686                    Tdepth_t depth      = (_param->_have_port_depth)?PORT_READ(in_EVENT_DEPTH [i]):0;
687                    uint32_t top        = reg_UPT_TOP    [i];
688                    uint32_t bottom     = reg_UPT_BOTTOM [i];
689                    uint32_t new_update = ((top==0)?_param->_size_upt_queue[i]:top)-1; 
690                    uint32_t full       = ((depth == top) and (top == bottom) and not reg_UPT_EMPTY [i]);
691                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top        : %d",top);
692                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth      : %d",depth);
693                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update : %d",new_update);
694
695                    // Test empty
696                    if (not reg_UPT_EMPTY [i])
697                      {
698#ifdef DEBUG_TEST
699                        if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END)
700                          throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state."));
701#endif
702                        reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT;
703
704                        // flush all slot after the event
705                        for (uint32_t j=(depth+1)%_param->_size_upt_queue[i];
706                             j!=top; 
707                             j=(j+1)%_param->_size_upt_queue[i])
708                          reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT;
709                      }
710             
711//                  reg_UPT_BOTTOM    [i];
712                    // TODO : special case : event is an exception on branch, also depth is not valid
713                    reg_UPT_TOP       [i] = depth; // depth is again valid
714                    reg_UPT_TOP_EVENT [i] = top;
715
716                    if (bottom == reg_UPT_TOP [i])
717                      reg_UPT_EMPTY [i] = true;
718
719                    reg_EVENT_VAL     [i] = true;
720                    reg_EVENT_UPT_PTR [i] = depth;
721                    event_state_t event_state         = reg_EVENT_STATE [i];
722                    bool          previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or
723                                                         (event_state == EVENT_STATE_MISS_FLUSH_UPT          ) or
724                                                         (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or
725                                                         (event_state == EVENT_STATE_EVENT_FLUSH_UPT));
726                    bool          update_ras          = (top != depth) or full;
727
728                    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
729                   
730                    // new state :
731                    //   * test if ufpt is empty
732                    //     * ok : flush upft and upt
733                    //     * ko : test if have previous flush upt
734                    //            * ok : nothing
735                    //            * ko : flush upt
736                    if (reg_UFPT_NB_NEED_UPDATE [i] > 0)
737                      {
738                        if (update_ras)
739                          {
740                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT (branch_complete - miss)",i);
741                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT;
742                          }
743                        else
744                          {
745                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT (branch_complete - miss)",i);
746                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT;
747                          }                         
748                      }
749                    else
750                      {
751//                         if (not previous_update_ras)
752                        if (update_ras)
753                          {
754                            // have ras prediction ?
755                            log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UPT (branch_complete - miss)",i);
756                           
757                            reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UPT;
758                          }
759                        else
760                          {
761                            reg_EVENT_STATE [i] = EVENT_STATE_OK;
762                          }
763                      }
764                   
765                    if (not previous_update_ras and update_ras)
766                      {
767                        reg_UPT_UPDATE [i]  = new_update;
768                      }
769                    // else no update
770                   
771                    reg_EVENT_DEPTH           [i] = depth;
772//                  reg_EVENT_ADDRESS_SRC     [i] = address_src; // delay_slot is compute in I_State
773//                  reg_EVENT_ADDRESS_DEST_VAL[i] = good_take;
774//                  reg_EVENT_ADDRESS_DEST    [i] = good_addr;
775
776                    break;
777                  }
778                default :
779                  {
780                    // nothing
781                    break;
782                  }
783                }
784            }
785
786        // ===================================================================
787        // =====[ FLUSH ]=====================================================
788        // ===================================================================
789
790        for (uint32_t i=0; i<_param->_nb_context; ++i)
791          {
792            if (flush_UFPT [i])
793              {
794                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * Flush Update Fetch Prediction Table");
795                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context                          : %d",i);
796                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_NB_NEED_UPDATE          : %d",reg_UFPT_NB_NEED_UPDATE [i]);
797
798              // It's to accelerate miss speculation
799              if (reg_UFPT_NB_NEED_UPDATE [i] == 0)
800                {
801
802                  // No entry need prediction, flush all entry -> Reset
803                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
804                    reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EMPTY;
805                  reg_UFPT_BOTTOM [i] = 0;
806                  reg_UFPT_TOP    [i] = 0;
807//                reg_UFPT_UPDATE [i];
808                }
809              else
810                {
811                  for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; ++j)
812                    {
813                      reg_UFPT_NB_UPDATE [i] ++;
814                      reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state = UPDATE_FETCH_PREDICTION_STATE_EVENT;
815                    }
816
817                  // TOP is next write slot : last slot is TOP-1
818                  uint32_t top = reg_UFPT_TOP [i];
819                  reg_UFPT_UPDATE    [i] = ((top==0)?_param->_size_ufpt_queue[i]:top)-1;
820
821//                reg_UFPT_BOTTOM    [i];
822//                reg_UFPT_TOP       [i];
823                }
824
825              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE         (after ) : %d",reg_UFPT_UPDATE [i]);
826
827              }
828          }
829
830#ifdef STATISTICS
831        if (usage_is_set(_usage,USE_STATISTICS))
832          for (uint32_t i=0; i<_param->_nb_context; i++)
833            {
834              for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; j++)
835                if (reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state != UPDATE_FETCH_PREDICTION_STATE_EMPTY)
836                  (*_stat_ufpt_queue_nb_elt [i]) ++;
837              for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
838                if (reg_UPDATE_PREDICTION_TABLE [i][j]._state != UPDATE_PREDICTION_STATE_EMPTY)
839                  (*_stat_upt_queue_nb_elt [i]) ++;
840            }
841#endif
842       
843        // ===================================================================
844        // =====[ PRINT ]=====================================================
845        // ===================================================================
846
847#if (DEBUG >= DEBUG_TRACE)
848    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * Dump Update_Prediction_Table");
849    log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UPDATE_PRIORITY       : %d",reg_UPDATE_PRIORITY);
850    for (uint32_t i=0; i<_param->_nb_context; i++)
851      {
852        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_IS_ACCURATE           : %d",reg_IS_ACCURATE        [i]);
853        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_VAL             : %d"  ,reg_EVENT_VAL             [i]);
854        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_UPT_PTR         : %d"  ,reg_EVENT_UPT_PTR         [i]);
855        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_STATE           : %s"  ,toString(reg_EVENT_STATE [i]).c_str());
856        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_DEPTH           : %d"  ,reg_EVENT_DEPTH           [i]);
857        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_SRC     : %.8x",reg_EVENT_ADDRESS_SRC     [i]);
858        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST_VAL: %d"  ,reg_EVENT_ADDRESS_DEST_VAL[i]);
859        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_EVENT_ADDRESS_DEST    : %.8x",reg_EVENT_ADDRESS_DEST    [i]);
860
861        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update_Fetch_Prediction_Table   [%d]",i);
862        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_BOTTOM         : %d",reg_UFPT_BOTTOM         [i]);
863        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_TOP            : %d",reg_UFPT_TOP            [i]);
864        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_UPDATE         : %d",reg_UFPT_UPDATE         [i]);
865        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_NEED_UPDATE : %d",reg_UFPT_NB_NEED_UPDATE [i]);
866        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UFPT_NB_UPDATE      : %d",reg_UFPT_NB_UPDATE      [i]);
867        for (uint32_t j=0; j<_param->_size_ufpt_queue[i]; j++)
868          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d   %.1d, %.8d %.8x %.4d - %s",
869                     j,
870                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._condition,
871                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_src,
872                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_dest,
873                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._last_take,
874                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._is_accurate,
875                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._history,
876                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._address_ras,
877                     reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._index_ras,
878                     toString(reg_UPDATE_FETCH_PREDICTION_TABLE [i][j]._state).c_str()
879                     );
880
881        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update_Prediction_Table   [%d]",i);
882        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_BOTTOM          : %d",reg_UPT_BOTTOM         [i]);
883        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP             : %d",reg_UPT_TOP            [i]);
884        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP_EVENT       : %d",reg_UPT_TOP_EVENT      [i]);
885        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_UPDATE          : %d",reg_UPT_UPDATE         [i]);
886        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_EMPTY           : %d",reg_UPT_EMPTY          [i]);
887        for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
888          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"        [%d] %.4d, %.8x %.8x, %.1d %.1d %.1d, %.8d %.8x %.4d - %s",
889                     j,
890                     reg_UPDATE_PREDICTION_TABLE [i][j]._condition,
891                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_src,
892                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_dest,
893                     reg_UPDATE_PREDICTION_TABLE [i][j]._last_take,
894                     reg_UPDATE_PREDICTION_TABLE [i][j]._good_take,
895                     reg_UPDATE_PREDICTION_TABLE [i][j]._is_accurate,
896                     reg_UPDATE_PREDICTION_TABLE [i][j]._history,
897                     reg_UPDATE_PREDICTION_TABLE [i][j]._address_ras,
898                     reg_UPDATE_PREDICTION_TABLE [i][j]._index_ras,
899                     toString(reg_UPDATE_PREDICTION_TABLE [i][j]._state).c_str()
900                     );
901      }
902#endif
903      }
904
905
906#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
907    end_cycle ();
908#endif
909   
910    log_end(Update_Prediction_Table,FUNCTION);
911  };
912
913}; // end namespace update_prediction_table
914}; // end namespace prediction_unit
915}; // end namespace front_end
916}; // end namespace multi_front_end
917}; // end namespace core
918
919}; // end namespace behavioural
920}; // end namespace morpheo             
921#endif
Note: See TracBrowser for help on using the repository browser.