Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Context_State/src/Context_State_transition.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Context_State/src/Context_State_transition.cpp	(revision 105)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Context_State/src/Context_State_transition.cpp	(revision 106)
@@ -196,6 +196,4 @@
               log_printf(TRACE,Context_State,FUNCTION,"  * BRANCH_EVENT [%d]",i);
 
-//               throw ERRORMORPHEO(FUNCTION,_("Not yet implemented (Comming Soon).\n"));
-
               context_state_t state = reg_STATE [i];
 
@@ -203,13 +201,16 @@
               Tdepth_t   depth_cur  = reg_EVENT_DEPTH [i];
               Tdepth_t   depth_min  = (_param->_have_port_depth)?PORT_READ(in_DEPTH_MIN [i]):0;
-              Tdepth_t   depth_max  = _param->_array_size_depth [i];
+              Tdepth_t   depth_max  = _param->_nb_inst_branch_speculated [i];
               
-//               Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
-//               Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
-              Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
-              Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
+              Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
+              Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
+//               Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
+//               Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
 
               // priority : miss > excep > spr/sync
-              uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR) or (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR) or (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND))?2:((state == EVENT_TYPE_EXCEPTION)?1:0);
+              uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR   ) or
+                                       (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR     ) or
+                                       (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or
+                                       (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND  ))?2:((state == EVENT_TYPE_EXCEPTION)?1:0);
               uint8_t    priority1  = 2; // miss
 
@@ -217,8 +218,17 @@
               //   if context_state_ok : yes
               //   if context_state_ko : test the depth, and the priority of event
-
               bool       is_valid   = ((state == CONTEXT_STATE_OK) or
                                        (depth1< depth0) or
                                        ((depth1==depth0) and (priority1>=priority0))); // >= because another branch can be a miss prediction with same depth
+
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth     : %d",depth     );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_cur : %d",depth_cur );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_min : %d",depth_min );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_max : %d",depth_max );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth0    : %d",depth0    );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth1    : %d",depth1    );
+              log_printf(TRACE,Context_State,FUNCTION,"    * priority0 : %d",priority0 );
+              log_printf(TRACE,Context_State,FUNCTION,"    * priority1 : %d",priority1 );
+              log_printf(TRACE,Context_State,FUNCTION,"  * is_valid    : %d",is_valid  );
 
               if (is_valid)
@@ -251,10 +261,10 @@
               Tdepth_t   depth_cur  = reg_EVENT_DEPTH [context];
               Tdepth_t   depth_min = (_param->_have_port_depth      )?PORT_READ(in_DEPTH_MIN [context]):0;
-              Tdepth_t   depth_max  = _param->_array_size_depth [context];
+              Tdepth_t   depth_max  = _param->_nb_inst_branch_speculated [context];
               
-//               Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
-//               Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
-              Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
-              Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
+              Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
+              Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
+//               Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
+//               Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
 
               context_state_t state = reg_STATE [context];
@@ -262,5 +272,8 @@
               
               // miss > excep > spr/sync
-              uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR) or (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR) or (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND))?2:((state == CONTEXT_STATE_KO_EXCEP)?1:0);
+              uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR   ) or
+                                       (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR     ) or
+                                       (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or
+                                       (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND  ))?2:((state == CONTEXT_STATE_KO_EXCEP)?1:0);
               uint8_t    priority1  = (state == EVENT_TYPE_EXCEPTION)?1:0;
 
@@ -272,4 +285,14 @@
                                        (depth1< depth0) or
                                        ((depth1==depth0) and (priority1>=priority0)));
+
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth     : %d",depth     );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_cur : %d",depth_cur );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_min : %d",depth_min );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth_max : %d",depth_max );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth0    : %d",depth0    );
+              log_printf(TRACE,Context_State,FUNCTION,"    * depth1    : %d",depth1    );
+              log_printf(TRACE,Context_State,FUNCTION,"    * priority0 : %d",priority0 );
+              log_printf(TRACE,Context_State,FUNCTION,"    * priority1 : %d",priority1 );
+              log_printf(TRACE,Context_State,FUNCTION,"  * is_valid    : %d",is_valid  );
 
               if (is_valid)
@@ -371,10 +394,10 @@
             Tdepth_t   depth_cur  = reg_EVENT_DEPTH [context];
             Tdepth_t   depth_min = (_param->_have_port_depth     )?PORT_READ(in_DEPTH_MIN [context]):0;
-            Tdepth_t   depth_max  = _param->_array_size_depth [context];
+            Tdepth_t   depth_max  = _param->_nb_inst_branch_speculated [context];
             
-//          Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
-//          Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
-            Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
-            Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
+            Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
+            Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
+//             Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
+//             Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
 
             context_state_t state = reg_STATE [context];
@@ -382,5 +405,8 @@
             
             // miss > excep > spr/sync
-            uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR) or (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR) or (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND))?2:((state == CONTEXT_STATE_KO_EXCEP)?1:0);
+            uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR   ) or
+                                     (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR     ) or
+                                     (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or
+                                     (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND  ))?2:((state == CONTEXT_STATE_KO_EXCEP)?1:0);
             uint8_t    priority1  = (state == EVENT_TYPE_EXCEPTION)?1:2; // else load_miss_speculation (EVENT_TYPE_MISS_SPECULATION)
 
@@ -392,4 +418,14 @@
                                      (depth1< depth0) or
                                      ((depth1==depth0) and (priority1>=priority0)));
+
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth     : %d",depth     );
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth_cur : %d",depth_cur );
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth_min : %d",depth_min );
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth_max : %d",depth_max );
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth0    : %d",depth0    );
+            log_printf(TRACE,Context_State,FUNCTION,"    * depth1    : %d",depth1    );
+            log_printf(TRACE,Context_State,FUNCTION,"    * priority0 : %d",priority0 );
+            log_printf(TRACE,Context_State,FUNCTION,"    * priority1 : %d",priority1 );
+            log_printf(TRACE,Context_State,FUNCTION,"  * is_valid    : %d",is_valid  );
 
             if (is_valid)
@@ -427,56 +463,4 @@
 
         // -------------------------------------------------------------------
-        // -----[ BRANCH_COMPLETE ]-------------------------------------------
-        // -------------------------------------------------------------------
-
-//         for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
-//           if (PORT_READ(in_BRANCH_COMPLETE_VAL [i]) and internal_BRANCH_COMPLETE_ACK [i])
-//             {
-//               log_printf(TRACE,Context_State,FUNCTION,"  * BRANCH_COMPLETE [%d]",i);
-//               if (PORT_READ(in_BRANCH_COMPLETE_MISS_PREDICTION [i]))
-//                 {
-//                   Tcontext_t context    = (_param->_have_port_context_id)?PORT_READ(in_BRANCH_COMPLETE_CONTEXT_ID [i]):0;
-//                   Tdepth_t   depth      = (_param->_have_port_depth     )?PORT_READ(in_BRANCH_COMPLETE_DEPTH      [i]):0;
-//                   Tdepth_t   depth_cur  = reg_EVENT_DEPTH [context];
-//                   Tdepth_t   depth_min = (_param->_have_port_depth     )?PORT_READ(in_DEPTH_MIN [context]):0;
-//                   Tdepth_t   depth_max  = _param->_array_size_depth [context];
-                  
-// //                   Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur-depth_min):((depth_cur+depth_max-depth_min));
-// //                   Tdepth_t   depth1     = (depth    >=depth_min)?(depth    -depth_min):((depth    +depth_max-depth_min));
-//                   Tdepth_t   depth0     = (depth_cur>=depth_min)?(depth_cur):((depth_cur+depth_max));
-//                   Tdepth_t   depth1     = (depth    >=depth_min)?(depth    ):((depth    +depth_max));
-                  
-//                   context_state_t state = reg_STATE [context];
-                  
-//                   // miss > excep > spr/sync
-//                   uint8_t    priority0  = ((state == CONTEXT_STATE_KO_MISS_BRANCH_ADDR) or (state == CONTEXT_STATE_KO_MISS_LOAD_ADDR) or (state == CONTEXT_STATE_KO_MISS_BRANCH_WAITEND) or (state == CONTEXT_STATE_KO_MISS_LOAD_WAITEND))?2:((state == CONTEXT_STATE_KO_EXCEP)?1:0);
-//                   uint8_t    priority1  = 2; // miss
-                  
-//                   // is_valid = can modify local information
-//                   //  if context_state_ok : yes
-//                   //  if context_state_ko : test the depth, and the priority of envent
-                  
-//                   bool       is_valid   = ((state == CONTEXT_STATE_OK) or
-//                                            (depth1< depth0) or
-//                                            ((depth1==depth0) and (priority1>=priority0)));
-                  
-//                   if (is_valid)
-//                     {
-//                       // commit
-//                       Tcontrol_t take = PORT_READ(in_BRANCH_COMPLETE_TAKE [i]);
-//                       reg_STATE                  [context] = CONTEXT_STATE_KO_MISS;
-//                       reg_EVENT_ADDRESS          [context] = PORT_READ(in_BRANCH_COMPLETE_ADDRESS_SRC  [i])+1; //DELAY_SLOT
-//                       reg_EVENT_ADDRESS_EPCR     [context] = PORT_READ(in_BRANCH_COMPLETE_ADDRESS_DEST [i]); 
-//                       reg_EVENT_ADDRESS_EPCR_VAL [context] = take; // if not take : in sequence
-//                     //reg_EVENT_ADDRESS_EEAR     [context]; 
-//                       reg_EVENT_ADDRESS_EEAR_VAL [context] = 0;
-//                       reg_EVENT_IS_DELAY_SLOT    [context] = take;
-//                       reg_EVENT_IS_DS_TAKE       [context] = take;
-//                       reg_EVENT_DEPTH            [context] = depth;
-//                     }
-//                 }
-//             }
-
-        // -------------------------------------------------------------------
         // -----[ EVENT ]-----------------------------------------------------
         // -------------------------------------------------------------------
