Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_decod.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_decod.cpp	(revision 120)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMealy_decod.cpp	(revision 122)
@@ -28,37 +28,39 @@
     if (PORT_READ(in_NRESET) != 0)
       {
+    // for each decod instruction
     for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
       {
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * DECOD [%d]",i);
 
-        Tcontext_t    context     = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
-        bool          is_accurate = _param->_accurate_block_decod or reg_IS_ACCURATE [context];
-        event_state_t event_state = reg_EVENT_STATE [context];
-        uint32_t      ptr_write   = reg_UPT_TOP     [context];
-        // can continue if next slot is empty
-        Tcontrol_t    can_continue= ((reg_UPDATE_PREDICTION_TABLE [context][(reg_UPT_TOP [context]+1)%_param->_size_upt_queue[context]]._state == UPDATE_PREDICTION_STATE_EMPTY) and 
-                                     (reg_EVENT_STATE [context] == EVENT_STATE_OK));
+        // Read information
+        Tcontext_t         context          = (_param->_have_port_context_id)?PORT_READ(in_DECOD_CONTEXT_ID [i]):0;
+        bool               is_accurate      = (_param->_always_accurate_decod or 
+                                              (_param->_can_accurate_decod and reg_IS_ACCURATE [context]));
+        upt_event_state_t  upt_event_state  = reg_UPT_EVENT_STATE  [context];
+        ufpt_event_state_t ufpt_event_state = reg_UFPT_EVENT_STATE [context];
+        uint32_t           ptr_write        = reg_UPT_TOP     [context]; // One branch per context per cycle
+        uint32_t           ptr_write_next   = (ptr_write+1)%_param->_size_upt_queue[context];
+        // Decod can continue until the next branch if next slot is empty, and no event
+        Tcontrol_t         can_continue     = (reg_UPDATE_PREDICTION_TABLE [context][ptr_write_next]._state == UPDATE_PREDICTION_STATE_EMPTY);
 
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context     : %d",context    );
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * is_accurate : %d",is_accurate);
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * event_state : %s",toString(event_state).c_str());
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ptr_write   : %d",ptr_write  );
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * upt_state   : %s",toString(reg_UPDATE_PREDICTION_TABLE [context][ptr_write]._state).c_str());
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * can_continue: %d",can_continue);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * context          : %d",context);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * is_accurate      : %d",is_accurate);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ufpt_event_state : %s",toString(ufpt_event_state).c_str());
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * upt_event_state  : %s",toString(upt_event_state).c_str());
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ptr_write        : %d - %d",ptr_write,ptr_write_next);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * upt_state        : %s",toString(reg_UPDATE_PREDICTION_TABLE [context][ptr_write]._state).c_str());
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * can_continue     : %d",can_continue);
 
-        // ack :
+        // can decod (ack) if :
         //   * in all case (miss or hit), need empty slot
+        //   * not previous event (state = ok)
         //   * is_accurate
-        //   * event_state : don't update upt
         internal_DECOD_ACK           [i] = ((reg_UPDATE_PREDICTION_TABLE [context][ptr_write]._state == UPDATE_PREDICTION_STATE_EMPTY) and
-                                            is_accurate and
-//                                             (
-                                             (event_state == EVENT_STATE_OK)//  or
-//                                              (event_state == EVENT_STATE_MISS_FLUSH_UFPT    ) or
-//                                              (event_state == EVENT_STATE_UPDATE_CONTEXT))
-                                            );
+                                            (ufpt_event_state == UFPT_EVENT_STATE_OK) and
+                                            (upt_event_state  == UPT_EVENT_STATE_OK ) and
+                                            is_accurate);
         internal_DECOD_UPT_PTR_WRITE [i] = ptr_write;
 
-        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ack         : %d",internal_DECOD_ACK [i]);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * ack              : %d",internal_DECOD_ACK [i]);
 
 	PORT_WRITE(out_DECOD_ACK          [i], internal_DECOD_ACK [i]);
