Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_mono_context.cfg
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_mono_context.cfg	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/config_mono_context.cfg	(revision 95)
@@ -1,5 +1,5 @@
 Update_Prediction_Table
 1	1	+1	# nb_context             
-4	8	*2	# size_upt_queue         [0] [nb_context]
+4	8	+1	# size_upt_queue         [0] [nb_context]
 1	4	+1	# size_ufpt_queue        [0] [nb_context]
 32	32	*2	# size_address           
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/src/test.cpp	(revision 95)
@@ -7,6 +7,6 @@
  */
 
-#define NB_ITERATION  8
-#define CYCLE_MAX     (128*NB_ITERATION)
+#define NB_ITERATION  16
+#define CYCLE_MAX     (1024*NB_ITERATION)
 
 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/SelfTest/include/test.h"
@@ -136,4 +136,9 @@
   ALLOC1_SC_SIGNAL(out_UPDATE_RAS_INDEX               ,"out_UPDATE_RAS_INDEX               ",Tptr_t             ,_param->_nb_inst_update);
   ALLOC1_SC_SIGNAL(out_UPDATE_RAS_PREDICTION_IFETCH   ,"out_UPDATE_RAS_PREDICTION_IFETCH   ",Tcontrol_t         ,_param->_nb_inst_update);
+
+  ALLOC1_SC_SIGNAL( in_EVENT_STATE                    ," in_EVENT_STATE                    ",Tevent_state_t     ,_param->_nb_context);
+  ALLOC1_SC_SIGNAL( in_EVENT_TYPE                     ," in_EVENT_TYPE                     ",Tevent_type_t      ,_param->_nb_context);
+  ALLOC1_SC_SIGNAL( in_EVENT_DEPTH                    ," in_EVENT_DEPTH                    ",Tdepth_t           ,_param->_nb_context);
+
   ALLOC1_SC_SIGNAL(out_DEPTH_CURRENT                  ,"out_DEPTH_CURRENT                  ",Tdepth_t           ,_param->_nb_context);
   ALLOC1_SC_SIGNAL(out_DEPTH_MIN                      ,"out_DEPTH_MIN                      ",Tdepth_t           ,_param->_nb_context);
@@ -225,6 +230,9 @@
   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_INDEX               ,_param->_nb_inst_update);
   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_UPDATE_RAS_PREDICTION_IFETCH   ,_param->_nb_inst_update);
+  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_EVENT_STATE                    ,_param->_nb_context);
+  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_EVENT_TYPE                     ,_param->_nb_context);
   if (_param->_have_port_depth)
     {
+  INSTANCE1_SC_SIGNAL(_Update_Prediction_Table, in_EVENT_DEPTH                    ,_param->_nb_context);
   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_CURRENT                  ,_param->_nb_context);
   INSTANCE1_SC_SIGNAL(_Update_Prediction_Table,out_DEPTH_MIN                      ,_param->_nb_context);
@@ -253,7 +261,7 @@
   const  int32_t percent_transaction_branch_event    = 75;
 
-  const bool     test1 = false;
-  const bool     test2 = false;
-  const bool     test3 = false;
+  const bool     test1 = true;
+  const bool     test2 = true;
+  const bool     test3 = true;
   const bool     test4 = true;
 
@@ -270,16 +278,18 @@
   in_NRESET->write(1);  
 
-  Tdepth_t ufpt_bottom [_param->_nb_context];
-  Tdepth_t ufpt_top    [_param->_nb_context];
-
-  Tdepth_t upt_bottom  [_param->_nb_context];
-  Tdepth_t upt_top     [_param->_nb_context];
+  Tdepth_t ufpt_bottom  [_param->_nb_context];
+  Tdepth_t ufpt_top     [_param->_nb_context];
+                       
+  Tdepth_t upt_bottom   [_param->_nb_context];
+  Tdepth_t upt_top      [_param->_nb_context];
+  Tdepth_t upt_top_event[_param->_nb_context];
 
   for (uint32_t i=0; i<_param->_nb_context; ++i)
     {
-      ufpt_bottom [i] = 0;
-      ufpt_top    [i] = 0;
-      upt_bottom  [i] = 0;
-      upt_top     [i] = 0;
+      ufpt_bottom  [i] = 0;
+      ufpt_top     [i] = 0;
+      upt_bottom   [i] = 0;
+      upt_top      [i] = 0;
+      upt_top_event[i] = 0;
     }
 
@@ -305,5 +315,9 @@
       for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
         in_UPDATE_ACK          [i]->write(0);
-
+      for (uint32_t i=0; i<_param->_nb_context; ++i)
+        {
+        in_EVENT_STATE [i]->write(EVENT_STATE_NO_EVENT);
+        in_EVENT_TYPE  [i]->write(EVENT_TYPE_NONE     );
+        }
       //---------------------------------------------------------------------
       //---------------------------------------------------------------------
@@ -913,5 +927,16 @@
           }
         }
-
+ 
+        {
+          LABEL("EVENT_STATE");
+         
+          SC_START(1);
+          in_EVENT_STATE [context]->write(EVENT_STATE_END            );
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+
+          SC_START(1);
+          in_EVENT_STATE [context]->write(EVENT_STATE_NO_EVENT       );
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_NONE            );
+        }
 
         // Wait Garbage Collector
@@ -1337,4 +1362,16 @@
         }
 
+        {
+          LABEL("EVENT_STATE");
+         
+          SC_START(1);
+          in_EVENT_STATE [context]->write(EVENT_STATE_END            );
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+
+          SC_START(1);
+          in_EVENT_STATE [context]->write(EVENT_STATE_NO_EVENT       );
+          in_EVENT_TYPE  [context]->write(EVENT_TYPE_NONE            );
+        }
+
         // Wait Garbage Collector
         {
@@ -1378,5 +1415,5 @@
                 request.take_good        = 1;                                              
                 request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
-                request.is_accurate      = false;
+                request.is_accurate      = true ;
                 request.miss_ifetch      = false;
                 request.miss_decod       = false;
@@ -1472,6 +1509,6 @@
                     LABEL("DECOD           [%d] %d - %d",
                           port,
-                          in_PREDICT_VAL [port]->read(),
-                          out_PREDICT_ACK [port]->read());
+                          in_DECOD_VAL [port]->read(),
+                          out_DECOD_ACK [port]->read());
                     
                     if (in_DECOD_VAL [port]->read() and out_DECOD_ACK [port]->read())
@@ -1520,5 +1557,5 @@
                 request.take_good        = 1;                                              
                 request.flag             = (request.condition == BRANCH_CONDITION_FLAG_SET)?request.take_good:(not request.take_good);
-                request.is_accurate      = false;
+                request.is_accurate      = true ;
                 request.miss_ifetch      = false;
                 request.miss_decod       = false;
@@ -1583,5 +1620,5 @@
           std::list<request_t>::iterator it_event;
           {
-            LABEL("BRANCH_COMPLETE - hit ifetch");
+            LABEL("BRANCH_COMPLETE - Miss ifetch");
             
             uint32_t port = rand() % _param->_nb_inst_branch_complete;
@@ -1600,5 +1637,7 @@
 
             if (update_ras(it_event->condition))
-              it_event->address_good = ~(it_event->address_dest);
+              {
+                it_event->address_good = ~(it_event->address_dest);
+              }
             else
               {
@@ -1649,5 +1688,66 @@
 		      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_event->address_good);
 
-                      upt_top [it_event->context] = it_event->upt_ptr;
+                      upt_top_event [it_event->context] = upt_top [it_event->context];
+                      upt_top       [it_event->context] = it_event->upt_ptr;
+		    }
+		  
+		  SC_START(1);
+		} while (not have_transaction);
+              
+	      in_BRANCH_COMPLETE_VAL [port]->write(0);
+	      
+              if (_param->_have_port_depth)
+              TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+              TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+	    }
+          }
+
+          {
+            LABEL("BRANCH_COMPLETE - Hit ifetch");
+            
+            uint32_t port = rand() % _param->_nb_inst_branch_complete;
+            
+            LABEL("  * port    : %d",port);
+            
+            std::list<request_t>::iterator it_upt = upt.begin();
+            
+            while (it_upt != it_event)
+            {
+	      bool have_transaction = false;
+              
+	      do
+		{
+		  in_BRANCH_COMPLETE_VAL        [port]->write((rand()%100)<percent_transaction_branch_complete);
+		  in_BRANCH_COMPLETE_CONTEXT_ID [port]->write(it_upt->context     );
+		  in_BRANCH_COMPLETE_DEPTH      [port]->write(it_upt->upt_ptr     );
+		  in_BRANCH_COMPLETE_ADDRESS    [port]->write(it_upt->address_dest);
+		  in_BRANCH_COMPLETE_FLAG       [port]->write(it_upt->flag        );
+
+                  if (_param->_have_port_depth)
+                  TEST(Tdepth_t,out_DEPTH_MIN [context]->read(), upt_bottom [context]);
+                  TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
+		  
+		  SC_START(0);
+		  
+		  LABEL("BRANCH_COMPLETE [%d] %d - %d.",port,in_BRANCH_COMPLETE_VAL [port]->read(),out_BRANCH_COMPLETE_ACK [port]->read());
+		  
+		  if (in_BRANCH_COMPLETE_VAL [port]->read() and out_BRANCH_COMPLETE_ACK [port]->read())
+		    {
+		      LABEL("BRANCH_COMPLETE [%d] - Transaction accepted",port);
+                      LABEL("  * CONTEXT_ID %d"  ,it_upt->context     );
+                      LABEL("  * DEPTH      %d"  ,it_upt->upt_ptr     );
+                      LABEL("  * CONDITION  %d"  ,it_upt->condition   );
+                      LABEL("  * ADDRESS    %.8x",it_upt->address_dest);
+                      LABEL("  * FLAG       %d"  ,it_upt->flag        );
+
+		      have_transaction = true;
+		      
+		      TEST(Tcontrol_t,out_BRANCH_COMPLETE_MISS_PREDICTION[port]->read(),it_upt->miss_commit );
+		      TEST(Tcontrol_t,out_BRANCH_COMPLETE_TAKE           [port]->read(),it_upt->take        );
+                      it_upt->take_good = it_upt->take;
+		      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_SRC    [port]->read(),it_upt->address_src );
+		      TEST(Taddress_t,out_BRANCH_COMPLETE_ADDRESS_DEST   [port]->read(),it_upt->address_dest);
+
+                      it_upt++;
 		    }
 		  
@@ -1740,5 +1840,5 @@
 
           {
-            LABEL("UPDATE - upt");
+            LABEL("UPDATE - upt (after event)");
             
             uint32_t port = 0;
@@ -1746,11 +1846,13 @@
             LABEL("  * port    : %d",port);
             std::list<request_t>::iterator it_upt = upt.end();
-            --it_upt;
 
 //             for (uint32_t i=0; i<upt.size(); i++)
-            while (it_upt != it_event)
+            do
               {
+                --it_upt;
+                
                 bool have_transaction = false;
                 
+                if (need_update(it_upt->condition))
                 do
                   {
@@ -1768,12 +1870,22 @@
                       {
                         LABEL("UPDATE [%d] - Transaction accepted",port);
+                        LABEL("  * address_src                : %.8x",it_upt->address_src);
+                        LABEL("  * out_UPDATE_BTB_ADDRESS_SRC : %.8x",out_UPDATE_BTB_ADDRESS_SRC[port]->read());
+
                         have_transaction = true;
                         
+                        bool btb_val = ((it_upt == it_event) and
+                                        (update_btb(it_upt->condition)));
+                        bool dir_val = ((it_upt == it_event) and
+                                        update_dir(it_upt->condition) and 
+                                        not (it_upt->miss_ifetch or it_upt->miss_decod));
+                        bool ras_val = update_ras(it_upt->condition);
+
                         if (_param->_have_port_context_id)
                         TEST(Tcontext_t         ,out_UPDATE_CONTEXT_ID            [port]->read(),it_upt->context);
                         TEST(Tcontrol_t         ,out_UPDATE_MISS_PREDICTION       [port]->read(),it_upt->miss_commit);
-                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
-                        TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),update_btb(it_upt->condition));
-                        if (update_btb(it_upt->condition))
+                        TEST(Tcontrol_t         ,out_UPDATE_BTB_VAL               [port]->read(),btb_val);
+
+                        if (btb_val)
                           {
                         TEST(Taddress_t         ,out_UPDATE_BTB_ADDRESS_SRC       [port]->read(),it_upt->address_src);
@@ -1781,11 +1893,15 @@
                         TEST(Tbranch_condition_t,out_UPDATE_BTB_CONDITION         [port]->read(),it_upt->condition);
                           }
-                        TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),update_dir(it_upt->condition) and not (it_upt->miss_ifetch or it_upt->miss_decod));
+                        TEST(Tcontrol_t         ,out_UPDATE_DIR_VAL               [port]->read(),dir_val);
                         
-                        if (update_dir(it_upt->condition))
+                        if (dir_val)
+                          {
+                        TEST(Tcontrol_t         ,out_UPDATE_DIRECTION_GOOD        [port]->read(),it_upt->take_good);
                         if (_param->_have_port_history)
                         TEST(Thistory_t         ,out_UPDATE_DIR_HISTORY           [port]->read(),it_upt->history);
-                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),update_ras(it_upt->condition));
-                        if (update_ras(it_upt->condition))
+                          }
+                        TEST(Tcontrol_t         ,out_UPDATE_RAS_VAL               [port]->read(),ras_val);
+
+                        if (ras_val)
                           {
 //                      TEST(Tcontrol_t         ,out_UPDATE_RAS_FLUSH             [port]->read(),0);
@@ -1796,5 +1912,5 @@
                           }
 
-                        -- it_upt;
+//                         -- it_upt;
                       }
                     
@@ -1808,7 +1924,8 @@
 //               TEST(Tdepth_t,out_DEPTH_MAX [context]->read(), upt_top [context]);
               }
+            while (it_upt != it_event);
+
           }
-//           upt.clear(); // Not yet
-
+          
           {
             LABEL("BRANCH_EVENT - have miss decod");
@@ -1852,11 +1969,24 @@
             }
           }
-          
+
           {
-            LABEL("UPDATE - upt");
+            LABEL("EVENT_STATE");
+            
+            SC_START(1);
+            in_EVENT_STATE [context]->write(EVENT_STATE_END            );
+            in_EVENT_TYPE  [context]->write(EVENT_TYPE_MISS_SPECULATION);
+            
+            SC_START(1);
+            in_EVENT_STATE [context]->write(EVENT_STATE_NO_EVENT       );
+            in_EVENT_TYPE  [context]->write(EVENT_TYPE_NONE            );
+          }
+
+          {
+            LABEL("UPDATE - upt (before event)");
             
             uint32_t port = 0;
             
             LABEL("  * port    : %d",port);
+            LABEL("  * size    : %d",upt.size());
             std::list<request_t>::iterator it_upt = upt.begin();
 
@@ -1908,5 +2038,5 @@
                           }
 
-                        -- it_upt;
+                        ++ it_upt;
                       }
                     
@@ -1920,14 +2050,20 @@
               }
           }
-          upt.clear(); // Not yet
+          upt.clear();
 
           // Wait Garbage Collector
           {
-            upt_bottom [context] = (upt_bottom [context]+1)%_param->_size_upt_queue[context];
-//        upt_top    [context] = (upt_top    [context]);
+            LABEL("GARBAGE COLLECTOR");
+            LABEL(" * upt bottom : %d",upt_bottom [context]);
+            LABEL(" * upt top    : %d",upt_top    [context]);
+
+            upt_top    [context] = (upt_top_event [context]);
+            upt_bottom [context] = (upt_top       [context]);
 
             while ((upt_bottom [context] != out_DEPTH_MIN [context]->read()) or
                    (upt_top    [context] != out_DEPTH_MAX [context]->read()))
-              SC_START(1);
+              {
+                SC_START(1);
+              }
             
           }
@@ -1993,7 +2129,7 @@
   delete [] out_BRANCH_EVENT_VAL            ;
   delete []  in_BRANCH_EVENT_ACK            ;
-//   delete []  in_BRANCH_EVENT_CONTEXT_ID     ;
-//   delete []  in_BRANCH_EVENT_DEPTH          ;
-//   delete [] out_BRANCH_EVENT_MISS_PREDICTION;
+//delete []  in_BRANCH_EVENT_CONTEXT_ID     ;
+//delete []  in_BRANCH_EVENT_DEPTH          ;
+//delete [] out_BRANCH_EVENT_MISS_PREDICTION;
   delete [] out_BRANCH_EVENT_ADDRESS_SRC    ;
   delete [] out_BRANCH_EVENT_ADDRESS_DEST_VAL;
@@ -2019,4 +2155,8 @@
   delete [] out_UPDATE_RAS_PREDICTION_IFETCH;
 
+  DELETE1_SC_SIGNAL( in_EVENT_STATE                    ,_param->_nb_context);
+  DELETE1_SC_SIGNAL( in_EVENT_TYPE                     ,_param->_nb_context);
+  DELETE1_SC_SIGNAL( in_EVENT_DEPTH                    ,_param->_nb_context);
+
   // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   delete [] out_DEPTH_CURRENT;
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Types.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Types.h	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Types.h	(revision 95)
@@ -21,10 +21,10 @@
   typedef enum
     {
-      EVENT_STATE_OK                 , // Can predict
-      EVENT_STATE_FLUSH_UFPT         , // in decod  stage, detect a miss, continue to execute but flush ufpt
-      EVENT_STATE_FLUSH_UFPT_AND_UPT , // in commit stage, detect a miss, stop context and flush ufpt and upt
-      EVENT_STATE_FLUSH_UPT_RAS      , // in commit stage, detect a miss, context is stop and ufpt is flush, update RAS
-      EVENT_STATE_FLUSH_UPT          , // in commit stage, detect a miss, context is stop and ufpt is flush
-      EVENT_STATE_UPDATE_CONTEXT       // prediction unit is update, send signal to context manager
+      EVENT_STATE_OK                    , // Can predict
+      EVENT_STATE_FLUSH_UFPT            , // in decod  stage, detect a miss, continue to execute but flush ufpt
+      EVENT_STATE_FLUSH_UFPT_AND_UPT    , // in commit stage, detect a miss, stop context and flush ufpt and upt
+      EVENT_STATE_FLUSH_UPT             , // in commit stage, detect a miss, context is stop and ufpt is flush, update RAS
+      EVENT_STATE_UPDATE_CONTEXT        , // prediction unit is update, send signal to context manager
+      EVENT_STATE_WAIT_END_EVENT          // prediction unit is ok, wait the end of envent (send by Context State)
     } event_state_t;
 
@@ -44,5 +44,6 @@
       UPDATE_PREDICTION_STATE_KO                , // this branch is a miss prediction
       UPDATE_PREDICTION_STATE_EVENT             , // previous branch is a miss prediction
-      UPDATE_PREDICTION_STATE_END                 // branch is updated 
+      UPDATE_PREDICTION_STATE_END_OK            , // branch is updated,       update pointer
+      UPDATE_PREDICTION_STATE_END_KO              // branch is updated, don't update pointer
     } upt_state_t;
 
@@ -114,10 +115,10 @@
     switch (x)
       {
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_OK                   : return "ok"                  ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT           : return "flush_ufpt"          ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT_AND_UPT   : return "flush_ufpt_and_upt"  ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UPT_RAS        : return "flush_upt_ras"       ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UPT            : return "flush_upt"           ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_UPDATE_CONTEXT       : return "update_context"      ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_OK                      : return "ok"                     ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT              : return "flush_ufpt"             ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UFPT_AND_UPT      : return "flush_ufpt_and_upt"     ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_FLUSH_UPT               : return "flush_upt"              ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_UPDATE_CONTEXT          : return "update_context"         ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::EVENT_STATE_WAIT_END_EVENT          : return "wait_and_event"         ; break;
       default    : return ""      ; break;
       }
@@ -145,5 +146,6 @@
       case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_KO         : return "ko"        ; break;
       case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_EVENT      : return "event"     ; break;
-      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_END        : return "end"       ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_END_OK     : return "end_ok"    ; break;
+      case morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::UPDATE_PREDICTION_STATE_END_KO     : return "end_ko"    ; break;
       default    : return ""      ; break;
       }
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Update_Prediction_Table.h	(revision 95)
@@ -170,4 +170,5 @@
   private   : uint32_t                      * reg_UPT_BOTTOM                     ; //[nb_context]
   private   : uint32_t                      * reg_UPT_TOP                        ; //[nb_context]
+  private   : uint32_t                      * reg_UPT_TOP_EVENT                  ; //[nb_context]
   private   : uint32_t                      * reg_UPT_UPDATE                     ; //[nb_context]
                                                                                               
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_allocation.cpp	(revision 95)
@@ -197,4 +197,5 @@
     ALLOC1(reg_UPT_BOTTOM                   ,uint32_t     ,_param->_nb_context);
     ALLOC1(reg_UPT_TOP                      ,uint32_t     ,_param->_nb_context);
+    ALLOC1(reg_UPT_TOP_EVENT                ,uint32_t     ,_param->_nb_context);
     ALLOC1(reg_UPT_UPDATE                   ,uint32_t     ,_param->_nb_context);
 
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_deallocation.cpp	(revision 95)
@@ -80,15 +80,13 @@
 
 	// ~~~~~[ Interface : "branch_event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	delete [] out_BRANCH_EVENT_VAL            ;
-	delete []  in_BRANCH_EVENT_ACK            ;
-// 	if (_param->_have_port_context_id)
-// 	delete []  in_BRANCH_EVENT_CONTEXT_ID     ;
-// 	if (_param->_have_port_depth)
-// 	delete []  in_BRANCH_EVENT_DEPTH          ;
-// 	delete [] out_BRANCH_EVENT_MISS_PREDICTION;
-	delete [] out_BRANCH_EVENT_ADDRESS_SRC    ;
-	delete [] out_BRANCH_EVENT_ADDRESS_DEST_VAL;
-	delete [] out_BRANCH_EVENT_ADDRESS_DEST   ;
-	
+        DELETE1_SIGNAL(out_BRANCH_EVENT_VAL              ,_param->_nb_context,1);
+        DELETE1_SIGNAL( in_BRANCH_EVENT_ACK              ,_param->_nb_context,1);
+//      DELETE1_SIGNAL(out_BRANCH_EVENT_CONTEXT_ID       ,_param->_nb_context,_param->_size_context_id);
+//      DELETE1_SIGNAL(out_BRANCH_EVENT_DEPTH            ,_param->_nb_context,_param->_size_depth);
+//      DELETE1_SIGNAL(out_BRANCH_EVENT_MISS_PREDICTION  ,_param->_nb_context,1);
+        DELETE1_SIGNAL(out_BRANCH_EVENT_ADDRESS_SRC      ,_param->_nb_context,_param->_size_instruction_address);
+        DELETE1_SIGNAL(out_BRANCH_EVENT_ADDRESS_DEST_VAL ,_param->_nb_context,1);
+        DELETE1_SIGNAL(out_BRANCH_EVENT_ADDRESS_DEST     ,_param->_nb_context,_param->_size_instruction_address);
+
 	// ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 	delete [] out_UPDATE_VAL                  ;
@@ -118,11 +116,8 @@
 
 	// ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	if (_param->_have_port_depth)
-	  {
-	delete [] out_DEPTH_CURRENT;
-	delete [] out_DEPTH_MIN;
-	  }
-	delete [] out_DEPTH_MAX;
-        
+        DELETE1_SIGNAL(out_DEPTH_CURRENT      ,_param->_nb_context,_param->_size_depth);
+        DELETE1_SIGNAL(out_DEPTH_MIN          ,_param->_nb_context,_param->_size_depth);
+        DELETE1_SIGNAL(out_DEPTH_MAX          ,_param->_nb_context,_param->_size_depth+1);
+
         // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         DELETE1(internal_PREDICT_ACK                     ,_param->_nb_inst_predict);
@@ -155,4 +150,5 @@
         DELETE1(reg_UPT_BOTTOM                   ,_param->_nb_context);
         DELETE1(reg_UPT_TOP                      ,_param->_nb_context);
+        DELETE1(reg_UPT_TOP_EVENT                ,_param->_nb_context);
         DELETE1(reg_UPT_UPDATE                   ,_param->_nb_context);
         
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 94)
+++ 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 95)
@@ -26,4 +26,6 @@
     
     // WARNING : One branch per context per cycle
+    if (PORT_READ(in_NRESET) != 0)
+      {
     for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
       {
@@ -58,5 +60,5 @@
 	PORT_WRITE(out_DECOD_ACK [i], internal_DECOD_ACK [i]);
       }
-
+      }
     log_end(Update_Prediction_Table,FUNCTION);
   };
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_genMoore.cpp	(revision 95)
@@ -57,7 +57,7 @@
         event_state_t event_state = reg_EVENT_STATE [i];
 
-        retire_ras_from_ufpt [i] = ((event_state == EVENT_STATE_FLUSH_UFPT        ) or
+        retire_ras_from_ufpt [i] = ((event_state == EVENT_STATE_FLUSH_UFPT            ) or
                                     (event_state == EVENT_STATE_FLUSH_UFPT_AND_UPT));
-        retire_ras_from_upt  [i] = (event_state == EVENT_STATE_FLUSH_UPT_RAS);
+        retire_ras_from_upt  [i] = (event_state == EVENT_STATE_FLUSH_UPT);
 
         ufpt_update          [i] = true;
@@ -154,7 +154,8 @@
                 log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * condition       : %s",toString(condition).c_str());
               
-                Tcontrol_t          state_is_ok_ko           = ((state == UPDATE_PREDICTION_STATE_OK) or
-                                                                (state == UPDATE_PREDICTION_STATE_KO));
-                Tcontrol_t          state_is_event           = (state == UPDATE_PREDICTION_STATE_EVENT);
+                Tcontrol_t          state_is_ok_ko           = ((state == UPDATE_PREDICTION_STATE_OK   ) or
+                                                                (state == UPDATE_PREDICTION_STATE_KO   ));
+                Tcontrol_t          state_is_event           = ((state == UPDATE_PREDICTION_STATE_KO   ) or
+                                                                (state == UPDATE_PREDICTION_STATE_EVENT));
                 Tcontrol_t          state_is_event_update    = state_is_event and     need_update(condition);
                 Tcontrol_t          state_is_event_no_update = state_is_event and not need_update(condition);
@@ -167,5 +168,5 @@
                 else
                   {
-                val                   = state_is_ok_ko;
+                val                   = (state == UPDATE_PREDICTION_STATE_OK);
                 val_without_ack       = false;
                   }                  
@@ -173,9 +174,9 @@
                 miss_prediction       = (state != UPDATE_PREDICTION_STATE_OK);
                 direction_good        = reg_UPDATE_PREDICTION_TABLE [context][depth]._good_take   ;
-                btb_val               = update_btb(condition);
+                btb_val               = state_is_ok_ko and update_btb(condition);
                 btb_address_src       = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src ;
                 btb_address_dest      = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_dest;
                 btb_condition         = condition;
-                dir_val               = update_dir(condition) and ifetch; // if not ifetch, then static prediction
+                dir_val               = state_is_ok_ko and update_dir(condition) and ifetch; // if not ifetch, then static prediction
                 dir_history           = reg_UPDATE_PREDICTION_TABLE [context][depth]._history     ;
                 ras_val               = update_ras(condition); // repop/ repush data -> don't corrupt ras
@@ -208,7 +209,9 @@
               }
           }
-
+        
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * val             : %d",val    );
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * val_without_ack : %d",val_without_ack);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss_prediction : %d",miss_prediction);
+        log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * direction_good  : %d",direction_good );
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * btb_val         : %d",btb_val);
         log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * dir_val         : %d",dir_val);
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp	(revision 94)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp	(revision 95)
@@ -44,4 +44,5 @@
             reg_UPT_BOTTOM           [i] = 0;
             reg_UPT_TOP              [i] = 0;
+            reg_UPT_TOP_EVENT        [i] = 0;
             reg_UPT_UPDATE           [i] = 0;
                                                                                     
@@ -87,7 +88,9 @@
             {
               uint32_t bottom = reg_UPT_BOTTOM [i];
-              
+              bool     end_ok = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_OK);
+              bool     end_ko = (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END_KO);
+
               // Test if state is end
-              if (reg_UPDATE_PREDICTION_TABLE [i][bottom]._state == UPDATE_PREDICTION_STATE_END)
+              if (end_ok or end_ko)
                 {
                   log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT [%d][%d]",i,bottom);
@@ -96,6 +99,14 @@
                   // Free slot
                   reg_UPDATE_PREDICTION_TABLE [i][bottom]._state = UPDATE_PREDICTION_STATE_EMPTY;
+
                   // Update pointer
                   reg_UPT_BOTTOM [i] = (bottom+1)%_param->_size_upt_queue[i];
+//                   if (bottom = reg_UPT_UPDATE [i])
+//                     reg_UPT_UPDATE [i] = reg_UPT_BOTTOM [i];
+                  if (end_ko) // free
+                    {
+                      reg_UPT_TOP    [i] = reg_UPT_TOP_EVENT [i];
+                      reg_UPT_UPDATE [i] = reg_UPT_TOP_EVENT [i];
+                    }
                 }
             }
@@ -299,7 +310,7 @@
 
 	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_COMPLETE[%d] - Accepted",i);
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss    : %d",miss);
+	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context    : %d",context);
+	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth      : %d",depth);
+	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * miss       : %d",miss);
 	      
               if (miss)
@@ -312,4 +323,8 @@
                   uint32_t top        = reg_UPT_TOP [context];
                   uint32_t new_update = ((top==0)?_param->_size_upt_queue[context]:top)-1; 
+
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * top        : %d",top);
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * new_update : %d",new_update);
+
                   for (uint32_t j=(depth+1)%_param->_size_upt_queue[context];
                                 j!=top; 
@@ -317,9 +332,8 @@
                     reg_UPDATE_PREDICTION_TABLE [context][j]._state = UPDATE_PREDICTION_STATE_EVENT;
                   
-                  // TOP is next write slot : last slot is TOP-1
-                  reg_UPT_UPDATE [context] = new_update;
-                  
-//                reg_UPT_BOTTOM [context];
-                  reg_UPT_TOP    [context] = depth;
+                  
+//                reg_UPT_BOTTOM    [context];
+                  reg_UPT_TOP       [context] = depth;
+                  reg_UPT_TOP_EVENT [context] = top;
 
 #ifdef DEBUG_TEST
@@ -331,6 +345,10 @@
                   reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_KO;
                   
-
-                  Taddress_t          address_src = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
+                  Taddress_t    address_src         = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src;
+                  event_state_t event_state         = reg_EVENT_STATE [context];
+                  bool          previous_update_ras = (event_state == EVENT_STATE_FLUSH_UPT);
+                  bool          update_ras          = (new_update != depth);
+
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * update_ras : %d",update_ras);
 
                   if (reg_UFPT_NB_NEED_UPDATE [context] > 0)
@@ -341,8 +359,19 @@
                   else
                     {
-                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UFPT_RAS (branch_complete - miss)",context);
-                      // have ras prediction ?
-                      reg_EVENT_STATE [context] = (new_update!=depth)?EVENT_STATE_FLUSH_UPT_RAS:EVENT_STATE_UPDATE_CONTEXT;
-                    }
+                      if (not previous_update_ras)
+                        {
+                          // have ras prediction ?
+                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_FLUSH_UPT (branch_complete - miss)",context);
+
+                          reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UPT;
+             
+                        }
+                    }
+
+                  if (not previous_update_ras)
+                    {
+                      reg_UPT_UPDATE [context]  = new_update;
+                    }
+                  // else no update
 
                   reg_EVENT_ADDRESS_SRC     [context] = address_src; // delay_slot is compute in Context_State
@@ -370,97 +399,129 @@
 	// =====[ UPDATE ]====================================================
 	// ===================================================================
-	for (uint32_t i=0; i<_param->_nb_inst_update; i++)
-	  if ((internal_UPDATE_VAL[i] and PORT_READ(in_UPDATE_ACK [i])) or
-              (internal_UPDATE_VAL_WITHOUT_ACK [i]))
-	    {
-	      Tcontext_t context = internal_UPDATE_CONTEXT_ID [i];
-	      Tdepth_t   depth   = internal_UPDATE_DEPTH      [i];
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
-
-              if (internal_UPDATE_FROM_UFPT [i])
+        {
+          bool can_continue [_param->_nb_context];
+          for (uint32_t i=0; i<_param->_nb_context; ++i)
+            can_continue [i] = true;
+
+          for (uint32_t i=0; i<_param->_nb_inst_update; i++)
+            {
+	      Tcontext_t context   = internal_UPDATE_CONTEXT_ID [i];
+
+              if ((internal_UPDATE_VAL[i] and PORT_READ(in_UPDATE_ACK [i])) or
+                  (internal_UPDATE_VAL_WITHOUT_ACK [i] and can_continue [context]))
                 {
-                // if free a slot, also all queue is updated
-                // Last slot ?
-                if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
-                  switch (reg_EVENT_STATE [context])
-                    {
-                    case EVENT_STATE_FLUSH_UFPT         : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
-                    case EVENT_STATE_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = (reg_UPT_UPDATE[context]!=reg_UPT_TOP[context])?EVENT_STATE_FLUSH_UPT_RAS:EVENT_STATE_UPDATE_CONTEXT;  break;
-                    default : break;
-                    }
-                
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
-                  
-                  // Change state
-#ifdef DEBUG_TEST
-                  if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state != UPDATE_FETCH_PREDICTION_STATE_EVENT)
-                    throw ERRORMORPHEO(FUNCTION,_("Update : invalid ufpt state."));
-#endif
-
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (update)",context,depth);
-
-                  reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
-
-
-                  // Update pointer
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (before) : %d",reg_UFPT_UPDATE [context]);
-                  reg_UFPT_UPDATE [context] = ((depth==0)?_param->_size_ufpt_queue[context]:depth)-1;
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (after ) : %d",reg_UFPT_UPDATE [context]);
-                  // Free a register that need update ?
-                  if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
-                    reg_UFPT_NB_NEED_UPDATE [context] --;
+                  Tdepth_t   depth     = internal_UPDATE_DEPTH      [i];
+                  
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * context : %d",context);
+                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * depth   : %d",depth);
+                  
+                  if (internal_UPDATE_FROM_UFPT [i])
+                    {
+                      // if free a slot, also all queue is updated
+                      // Last slot ?
+                      if (reg_UFPT_UPDATE [context] == reg_UFPT_BOTTOM [context])
+                        switch (reg_EVENT_STATE [context])
+                          {
+                          case EVENT_STATE_FLUSH_UFPT             : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;
+                            // impossible to have an update on ufpt and reg_upt_update>reg_upt_top
+                          case EVENT_STATE_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UPT ; break;
+                          default : break;
+                          }
+                      
+                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Fetch Prediction Table");
+                      
+                      // Change state
+#ifdef DEBUG_TEST
+                      if (reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state != UPDATE_FETCH_PREDICTION_STATE_EVENT)
+                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid ufpt state."));
+#endif
+                      
+                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UFPT [%d][%d].state <- UPDATE_FETCH_PREDICTION_STATE_END (update)",context,depth);
+                      
+                      reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._state = UPDATE_FETCH_PREDICTION_STATE_END;
+                      
+                      
+                      // Update pointer
+                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (before) : %d",reg_UFPT_UPDATE [context]);
+                      reg_UFPT_UPDATE [context] = ((depth==0)?_param->_size_ufpt_queue[context]:depth)-1;
+                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * reg_UFPT_UPDATE (after ) : %d",reg_UFPT_UPDATE [context]);
+                      // Free a register that need update ?
+                      if (need_update(reg_UPDATE_FETCH_PREDICTION_TABLE [context][depth]._condition))
+                        reg_UFPT_NB_NEED_UPDATE [context] --;
+                    }
+                  else
+                    {
+                      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Prediction Table");
+                      
+                      // Change state
+#ifdef DEBUG_TEST 
+                      if (internal_UPDATE_RAS [i])
+                        {
+                          if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT) and
+                              (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ))
+                            throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
+                        }
+                      else
+                        {
+                          if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_OK   )
+                            throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
+                        }
+#endif
+
+//                    bool have_event = ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO) or
+//                                       (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_EVENT));
+                      bool ko     = (reg_UPDATE_PREDICTION_TABLE [context][depth]._state == UPDATE_PREDICTION_STATE_KO);
+
+                      // Have an update, test the state to transiste to the good state
+                      if (ko)
+                        {
+                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",context,depth);
+                          
+                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO;
+                        }
+                      else
+                        {
+                          log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END_OK (update)",context,depth);
+                          
+                          reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_OK;
+                        }
+                      
+                      // Update pointer
+                      //  * if update RAS : update pointer is decreaste until it equal at top pointer
+                      if (internal_UPDATE_RAS [i])
+                        {
+                          // if end_event, restart too bottom, else decrease pointer
+                          bool end_event  = (reg_UPT_UPDATE [context] == reg_UPT_TOP [context]);
+                          
+                          reg_UPT_UPDATE [context] = (end_event)?reg_UPT_BOTTOM[context]:(((depth==0)?_param->_size_upt_queue[context]:depth)-1);
+                          if (end_event)
+                            {
+                              reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context];
+                              reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
+                            }
+                          else
+                            {
+                              reg_UPT_UPDATE [context] = (((depth==0)?_param->_size_upt_queue[context]:depth)-1);
+                            }
+                        }
+                      else
+                        {
+                          // increase pointer
+                          reg_UPT_UPDATE [context] = (depth+1)%_param->_size_upt_queue[context];
+                        }
+                      
+                      // Free the branch with no accurate ?
+                      if (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false)
+                        reg_IS_ACCURATE [context] = true;
+                    }
                 }
               else
-                {
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * Update Prediction Table");
-                  
-                  // Change state
-#ifdef DEBUG_TEST 
-                  if (internal_UPDATE_RAS [i])
-                    {
-                      if (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT)
-                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
-                    }
-                  else
-                    {
-                      if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_OK   ) and
-                          (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO   ))
-                        throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state."));
-                    }
-#endif
-
-                  log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * UPT  [%d][%d].state <- UPDATE_PREDICTION_STATE_END (update)",context,depth);
-
-                  reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END;
-
-                  // Update pointer
-                  bool end_event = (reg_UPT_UPDATE [context] == reg_UPT_TOP [context]);
-
-                  if (internal_UPDATE_RAS [i])
-                    {
-                      reg_UPT_UPDATE [context] = (end_event)?reg_UPT_BOTTOM[context]:(((depth==0)?_param->_size_upt_queue[context]:depth)-1);
-                    }
-                  else
-                    {
-                      reg_UPT_UPDATE [context] = (depth+1)%_param->_size_upt_queue[context];
-                    }
-                  
-                  // End and event ?
-                  if (end_event and
-                      (reg_EVENT_STATE [context] != EVENT_STATE_OK))
-                    {
-                      reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT;
-                    }
-
-                  // Free the branch with no accurate ?
-                  if (reg_UPDATE_PREDICTION_TABLE [context][depth]._is_accurate == false)
-                    reg_IS_ACCURATE [context] = true;
-                }
-	    }
+                can_continue [context] = false;
+            }
 	
-	// Round robin
-	reg_UPDATE_PRIORITY = (reg_UPDATE_PRIORITY+1)%_param->_nb_context;
+          // Round robin
+          reg_UPDATE_PRIORITY = (reg_UPDATE_PRIORITY+1)%_param->_nb_context;
+        }
 
  	// ===================================================================
@@ -470,5 +531,5 @@
 	  if (internal_BRANCH_EVENT_VAL [i] and PORT_READ(in_BRANCH_EVENT_ACK [i]))
             {
-	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * UPDATE[%d] - Accepted",i);
+	      log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * BRANCH_EVENT [%d] - Accepted",i);
 
 #ifdef DEBUG_TEST
@@ -478,8 +539,57 @@
               
               // Change state
-              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (branch_event)",i);
+              log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_WAIT_END_EVENT (branch_event)",i);
               
-              reg_EVENT_STATE [i] = EVENT_STATE_OK;
+              reg_EVENT_STATE [i] = EVENT_STATE_WAIT_END_EVENT;
             }
+
+ 	// ===================================================================
+	// =====[ EVENT ]=====================================================
+	// ===================================================================
+        for (uint32_t i=0; i<_param->_nb_context; ++i)
+          {
+            //----------------------------------------------------------------
+            // Cases
+            //----------------------------------------------------------------
+            //   * EVENT_TYPE_NONE               - nothing
+            //   * EVENT_TYPE_MISS_SPECULATION   
+            //     * EVENT_STATE_END             - Change state, reset pointer
+            //   * EVENT_TYPE_EXCEPTION          - 
+            //     * EVENT_STATE_EVENT           - Flush upft and upt
+            //     * EVENT_STATE_END             - Change state, reset pointer
+            //   * EVENT_TYPE_BRANCH_NO_ACCURATE - nothing : manage in decod and update
+            //   * EVENT_TYPE_SPR_ACCESS         - nothing
+            //   * EVENT_TYPE_MSYNC              - nothing
+            //   * EVENT_TYPE_PSYNC              - nothing
+            //   * EVENT_TYPE_CSYNC              - nothing
+
+            Tevent_state_t event_state = PORT_READ(in_EVENT_STATE [i]);
+            Tevent_type_t  event_type  = PORT_READ(in_EVENT_TYPE  [i]);
+//             Tdepth_t       depth       = PORT_READ(in_EVENT_DEPTH [i]);
+            
+            // Test if end of miss
+            if ((event_state == EVENT_STATE_END) and
+                (event_type  == EVENT_TYPE_MISS_SPECULATION))
+              {
+                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"  * EVENT");
+                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * state : EVENT_STATE_END");
+                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * type  : EVENT_TYPE_MISS_SPECULATION");
+
+#ifdef DEBUG_TEST
+                if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT)
+                  throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state."));
+#endif
+                
+                // Change state
+                log_printf(TRACE,Update_Prediction_Table,FUNCTION,"    * EVENT [%d] <- EVENT_STATE_OK (event)",i);
+                
+                reg_EVENT_STATE [i] = EVENT_STATE_OK;
+
+//                 uint32_t bottom = reg_UPT_BOTTOM [i];
+
+//                 reg_UPT_TOP    [i] = bottom;
+//                 reg_UPT_UPDATE [i] = bottom;
+              }
+          }
 
  	// ===================================================================
@@ -561,4 +671,5 @@
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_BOTTOM          : %d",reg_UPT_BOTTOM         [i]);
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP             : %d",reg_UPT_TOP            [i]);
+	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_TOP_EVENT       : %d",reg_UPT_TOP_EVENT      [i]);
 	log_printf(TRACE,Update_Prediction_Table,FUNCTION,"      * reg_UPT_UPDATE          : %d",reg_UPT_UPDATE         [i]);
 	for (uint32_t j=0; j<_param->_size_upt_queue[i]; j++)
