Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_and_pht.cfg
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_and_pht.cfg	(revision 111)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_and_pht.cfg	(revision 111)
@@ -0,0 +1,12 @@
+Two_Level_Branch_Predictor
+4       4       *2      # nb_inst_predict       
+4       4       *2      # nb_inst_update        
+30      30      *2      # size_address          
+1       1       +1      # have_bht              
+4       4       *4      # bht_size_shifter      
+16      16      *4      # bht_nb_shifter        
+1	1	+1	# have_pht              
+4	4  	*2	# pht_size_counter      
+32	32	*4	# pht_nb_counter        
+0	2	+1	# pht_size_address_share
+1       1       +1      # update_on_prediction
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_only.cfg
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_only.cfg	(revision 111)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_bht_only.cfg	(revision 111)
@@ -0,0 +1,12 @@
+Two_Level_Branch_Predictor
+4       4       *2      # nb_inst_predict       
+4       4       *2      # nb_inst_update        
+30      30      *2      # size_address          
+1       1       +1      # have_bht              
+1       16      *4      # bht_size_shifter      
+1       16      *4      # bht_nb_shifter        
+0	0	+1	# have_pht              
+0	0	+1	# pht_size_counter      
+0	0	*2	# pht_nb_counter        
+0	0	+1	# pht_size_address_share
+1       1       +1      # update_on_prediction
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_pht_only.cfg
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_pht_only.cfg	(revision 111)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/config_pht_only.cfg	(revision 111)
@@ -0,0 +1,12 @@
+Two_Level_Branch_Predictor
+4       4       *2      # nb_inst_predict       
+4       4       *2      # nb_inst_update        
+30      30      *2      # size_address          
+0       0       +1      # have_bht              
+0       0       *4      # bht_size_shifter      
+0       0       *4      # bht_nb_shifter        
+1	1	+1	# have_pht              
+1	4  	*2	# pht_size_counter      
+1	16	*4	# pht_nb_counter        
+0	0	+1	# pht_size_address_share
+1       1       +1      # update_on_prediction
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/configuration.cfg
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/configuration.cfg	(revision 110)
+++ 	(revision )
@@ -1,1 +1,0 @@
-Two_Level_Branch_Predictor
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h	(revision 111)
@@ -11,5 +11,5 @@
 #endif
 
-#define NB_ITERATION  1
+#define NB_ITERATION  16
 #define CYCLE_MAX     (1024*NB_ITERATION)
 
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/main.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/main.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/main.cpp	(revision 111)
@@ -7,6 +7,7 @@
 
 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/include/test.h"
+#include "Behavioural/include/Selftest.h"
 
-#define NB_PARAMS 0
+#define NB_PARAMS 11
 
 void usage (int argc, char * argv[])
@@ -14,5 +15,15 @@
   err (_("<Usage> %s name_instance list_params.\n"),argv[0]);
   err (_("list_params is :\n"));
-  err (_(" *  ()\n"));
+  err (_(" * nb_inst_predict        (uint32_t)\n"));
+  err (_(" * nb_inst_update         (uint32_t)\n"));
+  err (_(" * size_address           (uint32_t)\n"));
+  err (_(" * have_bht               (bool    )\n"));
+  err (_(" * bht_size_shifter       (uint32_t)\n"));
+  err (_(" * bht_nb_shifter         (uint32_t)\n"));
+  err (_(" * have_pht               (bool    )\n"));
+  err (_(" * pht_size_counter       (uint32_t)\n"));
+  err (_(" * pht_nb_counter         (uint32_t)\n"));
+  err (_(" * pht_size_address_share (uint32_t)\n"));
+  err (_(" * update_on_prediction   (bool    )\n"));
 
   exit (1);
@@ -32,4 +43,28 @@
   string name = argv[x++];
 
+  uint32_t nb_inst_predict       ;
+  uint32_t nb_inst_update        ;
+  uint32_t size_address          ;
+  bool     have_bht              ;
+  uint32_t bht_size_shifter      ;
+  uint32_t bht_nb_shifter        ;
+  bool     have_pht              ;
+  uint32_t pht_size_counter      ;
+  uint32_t pht_nb_counter        ;
+  uint32_t pht_size_address_share;
+  bool     update_on_prediction  ;
+
+  SELFTEST0(nb_inst_predict       ,uint32_t,argv,x);
+  SELFTEST0(nb_inst_update        ,uint32_t,argv,x);
+  SELFTEST0(size_address          ,uint32_t,argv,x);
+  SELFTEST0(have_bht              ,bool    ,argv,x);
+  SELFTEST0(bht_size_shifter      ,uint32_t,argv,x);
+  SELFTEST0(bht_nb_shifter        ,uint32_t,argv,x);
+  SELFTEST0(have_pht              ,bool    ,argv,x);
+  SELFTEST0(pht_size_counter      ,uint32_t,argv,x);
+  SELFTEST0(pht_nb_counter        ,uint32_t,argv,x);
+  SELFTEST0(pht_size_address_share,uint32_t,argv,x);
+  SELFTEST0(update_on_prediction  ,bool    ,argv,x);
+
   int _return = EXIT_SUCCESS;
   try 
@@ -37,4 +72,15 @@
       morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters * param = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::two_level_branch_predictor::Parameters
 	(
+         nb_inst_predict       ,
+         nb_inst_update        ,
+         size_address          ,
+         have_bht              ,
+         bht_size_shifter      ,
+         bht_nb_shifter        ,
+         have_pht              ,
+         pht_size_counter      ,
+         pht_nb_counter        ,
+         pht_size_address_share,
+         update_on_prediction  ,
          true //is_toplevel
         );
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/test.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/test.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/SelfTest/src/test.cpp	(revision 111)
@@ -50,4 +50,19 @@
   sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);	 
   sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
+
+  ALLOC1_SC_SIGNAL( in_PREDICT_VAL          ," in_PREDICT_VAL          ",Tcontrol_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL(out_PREDICT_ACK          ,"out_PREDICT_ACK          ",Tcontrol_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL( in_PREDICT_ADDRESS      ," in_PREDICT_ADDRESS      ",Taddress_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION    ,"out_PREDICT_DIRECTION    ",Tcontrol_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL(out_PREDICT_HISTORY      ,"out_PREDICT_HISTORY      ",Thistory_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL( in_PREDICT_DIRECTION_VAL," in_PREDICT_DIRECTION_VAL",Tcontrol_t,_param->_nb_inst_predict);
+  ALLOC1_SC_SIGNAL( in_PREDICT_DIRECTION    ," in_PREDICT_DIRECTION    ",Tcontrol_t,_param->_nb_inst_predict);
+  
+  ALLOC1_SC_SIGNAL( in_UPDATE_VAL           ," in_UPDATE_VAL           ",Tcontrol_t,_param->_nb_inst_update);
+  ALLOC1_SC_SIGNAL(out_UPDATE_ACK           ,"out_UPDATE_ACK           ",Tcontrol_t,_param->_nb_inst_update);
+  ALLOC1_SC_SIGNAL( in_UPDATE_ADDRESS       ," in_UPDATE_ADDRESS       ",Taddress_t,_param->_nb_inst_update);
+  ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY       ," in_UPDATE_HISTORY       ",Thistory_t,_param->_nb_inst_update);
+  ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION     ," in_UPDATE_DIRECTION     ",Tcontrol_t,_param->_nb_inst_update);
+  ALLOC1_SC_SIGNAL( in_UPDATE_MISS          ," in_UPDATE_MISS          ",Tcontrol_t,_param->_nb_inst_update);
   
   /********************************************************
@@ -60,4 +75,22 @@
   (*(_Two_Level_Branch_Predictor->in_NRESET))       (*(in_NRESET));
 
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_VAL          ,_param->_nb_inst_predict);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_ACK          ,_param->_nb_inst_predict);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_ADDRESS      ,_param->_nb_inst_predict);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_DIRECTION    ,_param->_nb_inst_predict);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_PREDICT_HISTORY      ,_param->_nb_inst_predict);
+  if (_param->_update_on_prediction)
+    {
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_PREDICT_DIRECTION    ,_param->_nb_inst_predict);
+    }
+
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_VAL           ,_param->_nb_inst_update);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor,out_UPDATE_ACK           ,_param->_nb_inst_update);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_ADDRESS       ,_param->_nb_inst_update);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_HISTORY       ,_param->_nb_inst_update);
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_DIRECTION     ,_param->_nb_inst_update);
+  if (_param->_update_on_prediction)
+  INSTANCE1_SC_SIGNAL(_Two_Level_Branch_Predictor, in_UPDATE_MISS          ,_param->_nb_inst_update);
 
   msg(_("<%s> : Start Simulation ............\n"),name.c_str());
@@ -76,6 +109,14 @@
   srand(seed);
 
+  const  int32_t percent_transaction_predict = 75;
+  const  int32_t percent_transaction_update  = 75;
+
   SC_START(0);
   LABEL("Initialisation");
+
+  for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
+    in_PREDICT_VAL [i]->write(0);
+  for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
+    in_UPDATE_VAL [i]->write(0);
 
   LABEL("Reset");
@@ -85,9 +126,92 @@
 
   LABEL("Loop of Test");
-
+  
+  Thistory_t bht;
+  Thistory_t pht [_param->_pht_size_bank];
+  
   for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
     {
       LABEL("Iteration %d",iteration);
 
+      uint32_t bht_num_reg  = (_param->_have_bht)?(rand()%_param->_bht_nb_shifter):0;
+      uint32_t pht_num_bank = (_param->_have_pht)?(rand()%_param->_pht_nb_bank   ):0;
+
+      LABEL("  * bht_num_reg  : %d",bht_num_reg );
+      LABEL("  * pht_num_bank : %d",pht_num_bank);
+
+      {
+        LABEL("Init BHT and PHT");
+
+        bht = 0;
+        for (uint32_t i=0; i<_param->_pht_size_bank; ++i)
+          pht [i] = 0;
+        
+        uint32_t port = rand()%_param->_nb_inst_update;
+
+        if (_param->_have_bht)
+          {        
+            bool find = false;
+            while (not find)
+              {
+                bool val = ((rand()%2)<percent_transaction_update);
+                in_UPDATE_VAL       [port]->write(val);
+                in_UPDATE_DIRECTION [port]->write(0);
+                
+                if (_param->_update_on_prediction)
+                  in_UPDATE_MISS      [port]->write(1); // miss
+                in_UPDATE_HISTORY   [port]->write(0);
+                in_UPDATE_ADDRESS   [port]->write(bht_num_reg);
+                
+                SC_START(0);
+                
+                if (val and out_UPDATE_ACK [port]->read())
+                  {
+                    LABEL("UPDATE[%d] - Transaction accepted",port);
+                    find = true;
+                  }
+                
+                SC_START(1);
+              }
+            in_UPDATE_VAL [port]->write(0);
+          }
+
+        if (_param->_have_pht)
+          {        
+            for (uint32_t i=0; i<_param->_pht_size_bank; ++i)
+              {
+                bool find = false;
+                
+                while (not find)
+                  {
+                    bool val = ((rand()%2)<percent_transaction_update);
+                    in_UPDATE_VAL       [port]->write(val);
+                    in_UPDATE_DIRECTION [port]->write(0);
+                    
+                    if (_param->_update_on_prediction)
+                      in_UPDATE_MISS      [port]->write(1); // miss
+                    in_UPDATE_HISTORY   [port]->write(i<<_param->_bht_history_rshift);
+                    in_UPDATE_ADDRESS   [port]->write(pht_num_bank<<_param->_pht_address_bank_rshift);
+                    
+                    SC_START(0);
+                    
+                    if (val and out_UPDATE_ACK [port]->read())
+                      {
+                        LABEL("UPDATE[%d] - Transaction accepted",port);
+                        find = true;
+                      }
+                    
+                    SC_START(1);
+                  }
+                in_UPDATE_VAL [port]->write(0);
+              }
+          }
+      }
+
+//       if (1)
+//         {
+//           LABEL("Saturation all PHT");
+          
+//         }
+
       SC_START(1);
     }
@@ -104,4 +228,19 @@
   delete in_CLOCK;
   delete in_NRESET;
+
+  DELETE1_SC_SIGNAL( in_PREDICT_VAL          ,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL(out_PREDICT_ACK          ,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL( in_PREDICT_ADDRESS      ,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL(out_PREDICT_DIRECTION    ,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL(out_PREDICT_HISTORY      ,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL( in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict);
+  DELETE1_SC_SIGNAL( in_PREDICT_DIRECTION    ,_param->_nb_inst_predict);
+
+  DELETE1_SC_SIGNAL( in_UPDATE_VAL           ,_param->_nb_inst_update);
+  DELETE1_SC_SIGNAL(out_UPDATE_ACK           ,_param->_nb_inst_update);
+  DELETE1_SC_SIGNAL( in_UPDATE_ADDRESS       ,_param->_nb_inst_update);
+  DELETE1_SC_SIGNAL( in_UPDATE_HISTORY       ,_param->_nb_inst_update);
+  DELETE1_SC_SIGNAL( in_UPDATE_DIRECTION     ,_param->_nb_inst_update);
+  DELETE1_SC_SIGNAL( in_UPDATE_MISS          ,_param->_nb_inst_update);
     }
 #endif
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h	(revision 111)
@@ -9,4 +9,5 @@
  */
 
+#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Types.h"
 #include "Behavioural/include/Parameters.h"
 #include "Common/include/Debug.h"
@@ -26,7 +27,49 @@
   {
     //-----[ fields ]------------------------------------------------------------
+  public : uint32_t   _nb_inst_predict         ;
+  public : uint32_t   _nb_inst_update          ;
+  public : uint32_t   _size_address            ;
+  public : bool       _have_bht                ;
+  public : uint32_t   _bht_size_shifter        ;
+  public : uint32_t   _bht_nb_shifter          ;
+  public : bool       _have_pht                ;
+  public : uint32_t   _pht_size_counter        ;
+  public : uint32_t   _pht_nb_counter          ;
+  public : uint32_t   _pht_size_address_share  ;
+  public : bool       _update_on_prediction    ;
+                                       
+  public : Thistory_t _pht_counter_max         ;
+        
+  public : uint32_t   _size_history            ;
+                                               
+  public : Thistory_t _bht_history_mask        ;
+  public : Thistory_t _bht_history_rshift      ;
+  public : Thistory_t _pht_history_mask        ;
+  public : Thistory_t _pht_history_rshift      ;
+                                               
+  public : uint32_t   _bht_size_address        ;
+  public : uint32_t   _pht_size_address        ;
+                                               
+  public : Taddress_t _bht_address_mask        ;
+  public : uint32_t   _pht_nb_bank             ;
+  public : uint32_t   _pht_size_bank           ;
+  public : Taddress_t _pht_address_share_mask  ;
+  public : Taddress_t _pht_address_share_lshift;
+  public : Taddress_t _pht_address_bank_mask   ;
+  public : Taddress_t _pht_address_bank_rshift ;
 
     //-----[ methods ]-----------------------------------------------------------
-  public : Parameters  (bool is_toplevel=false);
+  public : Parameters  (uint32_t nb_inst_predict       ,
+			uint32_t nb_inst_update        ,
+			uint32_t size_address          ,
+                        bool     have_bht              ,
+			uint32_t bht_size_shifter      ,
+			uint32_t bht_nb_shifter        ,
+			bool     have_pht              ,
+			uint32_t pht_size_counter      ,
+			uint32_t pht_nb_counter        ,
+			uint32_t pht_size_address_share,
+                        bool     update_on_prediction  ,
+                        bool is_toplevel=false);
 //public : Parameters  (Parameters & param) ;
   public : ~Parameters (void);
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h	(revision 111)
@@ -66,9 +66,34 @@
   public    : SC_IN (Tcontrol_t)            *  in_NRESET       ;
 
+    // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  public    : SC_IN (Tcontrol_t)           **  in_PREDICT_VAL          ;//[nb_inst_predict]
+  public    : SC_OUT(Tcontrol_t)           ** out_PREDICT_ACK          ;//[nb_inst_predict]
+  public    : SC_IN (Taddress_t)           **  in_PREDICT_ADDRESS      ;//[nb_inst_predict]
+  public    : SC_OUT(Tcontrol_t)           ** out_PREDICT_DIRECTION    ;//[nb_inst_predict] // = MSB[history]
+  public    : SC_OUT(Thistory_t)           ** out_PREDICT_HISTORY      ;//[nb_inst_predict]
+  public    : SC_IN (Tcontrol_t)           **  in_PREDICT_DIRECTION_VAL;//[nb_inst_predict] // if update_on_prediction
+  public    : SC_IN (Tcontrol_t)           **  in_PREDICT_DIRECTION    ;//[nb_inst_predict] // if update_on_prediction
+
+    // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  public    : SC_IN (Tcontrol_t)           **  in_UPDATE_VAL           ;//[nb_inst_update]
+  public    : SC_OUT(Tcontrol_t)           ** out_UPDATE_ACK           ;//[nb_inst_update]
+  public    : SC_IN (Taddress_t)           **  in_UPDATE_ADDRESS       ;//[nb_inst_update]
+  public    : SC_IN (Thistory_t)           **  in_UPDATE_HISTORY       ;//[nb_inst_update]
+  public    : SC_IN (Tcontrol_t)           **  in_UPDATE_DIRECTION     ;//[nb_inst_update]
+  public    : SC_IN (Tcontrol_t)           **  in_UPDATE_MISS          ;//[nb_inst_update] // if update_on_prediction
+
     // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
-
+    
     // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
+  private   : Thistory_t                    * reg_BHT                       ;//[bht_nb_shifter]
+  private   : Thistory_t                   ** reg_PHT                       ;//[pht_nb_counter][pht_nb_bank]
 
     // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  private   : Tcontrol_t                    * internal_PREDICT_ACK          ;//[nb_inst_predict]
+  private   : Thistory_t                    * internal_PREDICT_BHT_NUM_REG  ;//[nb_inst_predict] // if update_on_prediction
+  private   : Thistory_t                    * internal_PREDICT_PHT_NUM_BANK ;//[nb_inst_predict] // if update_on_prediction
+  private   : Thistory_t                    * internal_PREDICT_PHT_NUM_REG  ;//[nb_inst_predict] // if update_on_prediction
+
+  private   : Tcontrol_t                    * internal_UPDATE_ACK           ;//[nb_inst_update]
 #endif
 
@@ -104,5 +129,5 @@
 #ifdef SYSTEMC				       
   public  : void        transition                (void);
-//public  : void        genMoore                  (void);
+  public  : void        genMealy_predict          (void);
 #endif					       
 
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters.cpp	(revision 111)
@@ -7,4 +7,5 @@
 
 #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Parameters.h"
+#include "Common/include/BitManipulation.h"
 
 namespace morpheo {
@@ -21,14 +22,78 @@
 #undef  FUNCTION
 #define FUNCTION "Two_Level_Branch_Predictor::Parameters"
-  Parameters::Parameters (bool is_toplevel)
+  Parameters::Parameters (uint32_t nb_inst_predict       ,
+                          uint32_t nb_inst_update        ,
+                          uint32_t size_address          ,
+                          bool     have_bht              ,
+                          uint32_t bht_size_shifter      ,
+                          uint32_t bht_nb_shifter        ,
+                          bool     have_pht              ,
+                          uint32_t pht_size_counter      ,
+                          uint32_t pht_nb_counter        ,
+                          uint32_t pht_size_address_share,
+                          bool     update_on_prediction  ,
+                          bool is_toplevel)
   {
     log_begin(Two_Level_Branch_Predictor,FUNCTION);
 
-    test();
+    _nb_inst_predict         = nb_inst_predict       ;
+    _nb_inst_update          = nb_inst_update        ;
+    _size_address            = size_address          ;
+    _have_bht                = have_bht              ;
+    _bht_size_shifter        = (have_bht)?(bht_size_shifter):0;
+    _bht_nb_shifter          = (have_bht)?(bht_nb_shifter  ):0;
+    _have_pht                = have_pht              ;
+    _pht_size_counter        = (have_pht)?(pht_size_counter      ):0;
+    _pht_nb_counter          = (have_pht)?(pht_nb_counter        ):0;
+    _pht_size_address_share  = (have_bht and have_pht)?(pht_size_address_share):0;
+    _update_on_prediction    = update_on_prediction  ;
+                             
+    _bht_size_address        = (_have_bht)?log2(_bht_nb_shifter):0;
+    _pht_size_address        = (_have_pht)?log2(_pht_nb_counter):0;
+                             
+    test();                  
+
+    _size_history            = _bht_size_shifter + _pht_size_counter;
+                             
+    _bht_history_mask        = gen_mask<Thistory_t>(_bht_size_shifter);
+    _bht_history_rshift      = 0;
+    _pht_history_mask        = gen_mask<Thistory_t>(_pht_size_counter);
+    _pht_history_rshift      = _bht_size_shifter;
+                             
+    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _size_history             : %d",_size_history  );
+    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_history_mask         : 0x%x",_bht_history_mask  );
+    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_history_rshift       : %d",_bht_history_rshift);
+    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_history_mask         : 0x%x",_pht_history_mask  );
+    log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_history_rshift       : %d",_pht_history_rshift);
+
+    if (_have_bht)
+      {
+        _bht_address_mask        = gen_mask<Taddress_t>(_bht_size_address);
+
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _bht_address_mask         : 0x%x",_bht_address_mask  );
+      }
+
+    if (_have_pht)
+      {
+        _pht_counter_max         = (1<<_pht_size_counter)-1;
+        
+        _pht_nb_bank             = (_pht_nb_counter - (1<<_bht_size_shifter))+1;
+        _pht_size_bank           = _pht_nb_counter / _pht_nb_bank;
+
+        _pht_address_share_mask  = gen_mask<Taddress_t>(_pht_size_address_share);
+        _pht_address_share_lshift= _bht_size_shifter-_pht_size_address_share;
+        _pht_address_bank_mask   = gen_mask<Taddress_t>(log2(_pht_nb_bank));
+        _pht_address_bank_rshift = _pht_size_address_share;
+
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_nb_bank              : %d"  ,_pht_nb_bank   );
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_size_bank            : %d"  ,_pht_size_bank );
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_share_mask   : 0x%x",_pht_address_share_mask  );
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_share_lshift : %d"  ,_pht_address_share_lshift);
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_bank_mask    : 0x%x",_pht_address_bank_mask   );
+        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * _pht_address_bank_rshift  : %d"  ,_pht_address_bank_rshift );
+      }
 
     if (is_toplevel)
-      {
-        copy();
-      }
+      copy();
 
     log_end(Two_Level_Branch_Predictor,FUNCTION);
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_msg_error.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_msg_error.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_msg_error.cpp	(revision 111)
@@ -29,4 +29,19 @@
     Parameters_test test ("Two_Level_Branch_Predictor");
 
+    if ((_have_bht or _have_pht) == false)
+      test.error(_("They have no Branch History Table and no Pattern History Table. You need a less of a BHT or a PHT\n"));
+
+    if ( _have_bht and (_size_address < _bht_size_address))
+      test.error(_("The address's size must to large to the number of shifter in the Branch History Table.\n"));
+
+    if (_have_pht and (_size_address < _pht_size_address))
+      test.error(_("The address's size must to large to the number of counter in the Pattern History Table.\n"));
+
+    if (_have_pht and _have_bht and (_bht_size_address > _pht_nb_counter))
+      test.error (_("The size of shifter don't must too large that the number of counter in the Pattern History Table.\n"));
+
+    if (_have_pht and _have_bht and (_pht_size_address_share > _bht_size_shifter))
+      test.error (_("The size of address share don't must too large that the size of shifter in the Branch History Table.\n"));
+
     log_end(Two_Level_Branch_Predictor,FUNCTION);
 
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor.cpp	(revision 111)
@@ -72,4 +72,17 @@
     if (usage_is_set(_usage,USE_SYSTEMC))
       {
+        // Constants :
+        for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
+          {
+            internal_PREDICT_ACK [i] = 1;
+            PORT_WRITE(out_PREDICT_ACK [i], internal_PREDICT_ACK [i]);
+          }
+        for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
+          {
+            internal_UPDATE_ACK [i] = 1;
+            PORT_WRITE(out_UPDATE_ACK [i], internal_UPDATE_ACK [i]);
+          }
+        
+
 	log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - transition"),_name.c_str());
 
@@ -82,13 +95,18 @@
 # endif    
 
-// 	log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - genMoore"),_name.c_str());
+	log_printf(INFO,Two_Level_Branch_Predictor,FUNCTION,_("<%s> : Method - genMealy_predict"),_name.c_str());
 
-// 	SC_METHOD (genMoore);
-// 	dont_initialize ();
-// 	sensitive << (*(in_CLOCK)).neg(); // need internal register
-	
-// # ifdef SYSTEMCASS_SPECIFIC
-// 	// List dependency information
-// # endif    
+	SC_METHOD (genMealy_predict);
+	dont_initialize ();
+	sensitive << (*(in_CLOCK)).neg(); // need internal register
+
+        for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
+          sensitive 
+//             << (*(in_PREDICT_VAL     [i]))
+            << (*(in_PREDICT_ADDRESS [i]));
+        	
+# ifdef SYSTEMCASS_SPECIFIC
+	// List dependency information
+# endif    
 	
 #endif
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_allocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_allocation.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_allocation.cpp	(revision 111)
@@ -19,6 +19,4 @@
 namespace meta_predictor {
 namespace two_level_branch_predictor {
-
-
 
 #undef  FUNCTION
@@ -58,6 +56,69 @@
       in_NRESET       = interface->set_signal_in  <Tcontrol_t> ("nreset",1, RESET_VHDL_YES);
     }
+
+    // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    {
+      ALLOC1_INTERFACE("predict",IN,WEST,_("Predict direction interface"),_param->_nb_inst_predict);
+
+      ALLOC1_VALACK_IN ( in_PREDICT_VAL          ,VAL);
+      ALLOC1_VALACK_OUT(out_PREDICT_ACK          ,ACK);
+      ALLOC1_SIGNAL_IN ( in_PREDICT_ADDRESS      ,"ADDRESS"      ,Taddress_t,_param->_size_address);
+      ALLOC1_SIGNAL_OUT(out_PREDICT_DIRECTION    ,"DIRECTION"    ,Tcontrol_t,1                    );
+      ALLOC1_SIGNAL_OUT(out_PREDICT_HISTORY      ,"HISTORY"      ,Thistory_t,_param->_size_history);
+      if (_param->_update_on_prediction)
+        {
+      ALLOC1_SIGNAL_IN ( in_PREDICT_DIRECTION_VAL,"DIRECTION_VAL",Tcontrol_t,1                    );
+      ALLOC1_SIGNAL_IN ( in_PREDICT_DIRECTION    ,"DIRECTION"    ,Tcontrol_t,1                    );
+        }
+    }
+
+    // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    {
+      ALLOC1_INTERFACE("update",IN,WEST,_("Update direction interface"),_param->_nb_inst_update);
+
+      ALLOC1_VALACK_IN ( in_UPDATE_VAL           ,VAL);
+      ALLOC1_VALACK_OUT(out_UPDATE_ACK           ,ACK);
+      ALLOC1_SIGNAL_IN ( in_UPDATE_ADDRESS       ,"ADDRESS"      ,Taddress_t,_param->_size_address);
+      ALLOC1_SIGNAL_IN ( in_UPDATE_HISTORY       ,"HISTORY"      ,Thistory_t,_param->_size_history);
+      ALLOC1_SIGNAL_IN ( in_UPDATE_DIRECTION     ,"DIRECTION"    ,Tcontrol_t,1                    );
+      if (_param->_update_on_prediction)
+      ALLOC1_SIGNAL_IN ( in_UPDATE_MISS          ,"MISS"         ,Tcontrol_t,1                    );
+    }
+
+    if (usage_is_set(_usage,USE_SYSTEMC))
+      {
+        if (_param->_have_bht)
+          {
+        ALLOC1(reg_BHT                       ,Thistory_t,_param->_bht_nb_shifter);
+
+        for (uint32_t i=0; i<_param->_bht_nb_shifter; ++i)
+          reg_BHT [i] = 0;
+          }
+
+        if (_param->_have_pht)
+          {
+        ALLOC2(reg_PHT                       ,Thistory_t,_param->_pht_nb_bank,_param->_pht_size_bank);
+
+        for (uint32_t i=0; i<_param->_pht_nb_bank; ++i)
+          for (uint32_t j=0; j<_param->_pht_size_bank; ++j)
+            reg_PHT [i][j] = 0;
+          }
+
+
+        ALLOC1(internal_PREDICT_ACK          ,Tcontrol_t,_param->_nb_inst_predict);
+        if (_param->_update_on_prediction)
+          {
+        if (_param->_have_bht)
+        ALLOC1(internal_PREDICT_BHT_NUM_REG  ,Thistory_t,_param->_nb_inst_predict);
+        if (_param->_have_pht)
+          {
+        ALLOC1(internal_PREDICT_PHT_NUM_BANK ,Thistory_t,_param->_nb_inst_predict);
+        ALLOC1(internal_PREDICT_PHT_NUM_REG  ,Thistory_t,_param->_nb_inst_predict);
+          }
+          }
+        ALLOC1(internal_UPDATE_ACK           ,Tcontrol_t,_param->_nb_inst_update );
+      }
+
     // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
-
 #ifdef POSITION
     if (usage_is_set(_usage,USE_POSITION))
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_deallocation.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_deallocation.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_deallocation.cpp	(revision 111)
@@ -30,4 +30,41 @@
 	delete    in_CLOCK ;
 	delete    in_NRESET;
+
+        DELETE1_SIGNAL( in_PREDICT_VAL          ,_param->_nb_inst_predict,1                    );
+        DELETE1_SIGNAL(out_PREDICT_ACK          ,_param->_nb_inst_predict,1                    );
+        DELETE1_SIGNAL( in_PREDICT_ADDRESS      ,_param->_nb_inst_predict,_param->_size_address);
+        DELETE1_SIGNAL(out_PREDICT_DIRECTION    ,_param->_nb_inst_predict,1                    );
+        DELETE1_SIGNAL(out_PREDICT_HISTORY      ,_param->_nb_inst_predict,_param->_size_history);
+        if (_param->_update_on_prediction)                               
+          {                                                              
+        DELETE1_SIGNAL( in_PREDICT_DIRECTION_VAL,_param->_nb_inst_predict,1                    );
+        DELETE1_SIGNAL( in_PREDICT_DIRECTION    ,_param->_nb_inst_predict,1                    );
+          }
+        
+        DELETE1_SIGNAL( in_UPDATE_VAL           ,_param->_nb_inst_update,1                    );
+        DELETE1_SIGNAL(out_UPDATE_ACK           ,_param->_nb_inst_update,1                    );
+        DELETE1_SIGNAL( in_UPDATE_ADDRESS       ,_param->_nb_inst_update,_param->_size_address);
+        DELETE1_SIGNAL( in_UPDATE_HISTORY       ,_param->_nb_inst_update,_param->_size_history);
+        DELETE1_SIGNAL( in_UPDATE_DIRECTION     ,_param->_nb_inst_update,1                    );
+        if (_param->_update_on_prediction)                              
+        DELETE1_SIGNAL( in_UPDATE_MISS          ,_param->_nb_inst_update,1                    );
+        
+        if (_param->_have_bht)
+        DELETE1(reg_BHT                         ,_param->_bht_nb_shifter);
+        if (_param->_have_pht)
+        DELETE2(reg_PHT                         ,_param->_pht_nb_bank,_param->_pht_size_bank);
+        
+        DELETE1(internal_PREDICT_ACK            ,_param->_nb_inst_predict);
+        if (_param->_update_on_prediction)      
+          {                                     
+        if (_param->_have_bht)
+        DELETE1(internal_PREDICT_BHT_NUM_REG    ,_param->_nb_inst_predict);
+        if (_param->_have_pht)
+          {
+        DELETE1(internal_PREDICT_PHT_NUM_BANK   ,_param->_nb_inst_predict);
+        DELETE1(internal_PREDICT_PHT_NUM_REG    ,_param->_nb_inst_predict);
+          }
+          }                                     
+        DELETE1(internal_UPDATE_ACK             ,_param->_nb_inst_update );
       }
     // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_genMealy_predict.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_genMealy_predict.cpp	(revision 111)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_genMealy_predict.cpp	(revision 111)
@@ -0,0 +1,102 @@
+#ifdef SYSTEMC
+/*
+ * $Id$
+ *
+ * [ Description ]
+ * 
+ */
+
+#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h"
+
+namespace morpheo                    {
+namespace behavioural {
+namespace core {
+namespace multi_front_end {
+namespace front_end {
+namespace prediction_unit {
+namespace direction {
+namespace meta_predictor {
+namespace two_level_branch_predictor {
+
+
+#undef  FUNCTION
+#define FUNCTION "Two_Level_Branch_Predictor::genMealy_predict"
+  void Two_Level_Branch_Predictor::genMealy_predict (void)
+  {
+    log_begin(Two_Level_Branch_Predictor,FUNCTION);
+    log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str());
+
+    // ===================================================================
+    // =====[ PREDICT ]===================================================
+    // ===================================================================
+
+    for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
+//       if (PORT_READ(in_PREDICT_VAL[i]))
+        {
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
+
+          Taddress_t address     = PORT_READ(in_PREDICT_ADDRESS   [i]);
+          Thistory_t history     = 0;
+          Tcontrol_t direction;
+
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : 0x%.8x",address);
+
+          Thistory_t pht_bht_history = 0;
+          if (_param->_have_bht)
+            {
+              Thistory_t bht_num_reg = address & _param->_bht_address_mask;
+              Thistory_t bht_history = reg_BHT [bht_num_reg];
+              pht_bht_history = bht_history;
+
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",bht_history);
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %d",bht_num_reg);
+
+              history   = (bht_history << _param->_bht_history_rshift)&_param->_bht_history_mask ;
+              direction = (bht_history >> (_param->_bht_size_shifter-1))&1;
+
+              if (_param->_update_on_prediction)
+              internal_PREDICT_BHT_NUM_REG [i] = bht_num_reg;
+            }
+
+          if (_param->_have_pht)
+            {
+              Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask;
+              Thistory_t pht_num_reg = (pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift));
+              Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
+              
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",pht_bht_history);
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history      : 0x%x",pht_history);
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %d",pht_num_reg);
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %d",pht_num_bank);
+              
+              history  |= (pht_history << _param->_pht_history_rshift)&_param->_pht_history_mask;
+              direction = (pht_history >> (_param->_pht_size_counter-1))&1;
+
+              if (_param->_update_on_prediction)
+                {
+              internal_PREDICT_PHT_NUM_REG [i] = pht_num_reg;
+              internal_PREDICT_PHT_NUM_BANK[i] = pht_num_bank;
+                }
+            }
+
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * history          : 0x%x",history);
+
+          PORT_WRITE(out_PREDICT_DIRECTION [i],direction);
+          PORT_WRITE(out_PREDICT_HISTORY   [i],history  );
+        }
+
+    log_end(Two_Level_Branch_Predictor,FUNCTION);
+  };
+
+}; // end namespace two_level_branch_predictor
+}; // end namespace meta_predictor
+}; // end namespace direction
+}; // end namespace prediction_unit
+}; // end namespace front_end
+}; // end namespace multi_front_end
+}; // end namespace core
+
+}; // end namespace behavioural
+}; // end namespace morpheo              
+#endif
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp	(revision 110)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_transition.cpp	(revision 111)
@@ -25,4 +25,180 @@
   {
     log_begin(Two_Level_Branch_Predictor,FUNCTION);
+    log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str());
+
+    if (PORT_READ(in_NRESET) == 0)
+      {
+      }
+    else
+      {
+        // ===================================================================
+        // =====[ PREDICT ]===================================================
+        // ===================================================================
+
+        for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
+          if (PORT_READ(in_PREDICT_VAL[i]) and internal_PREDICT_ACK[i])
+            {
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
+
+              // Predict if 
+              //  * update_on_prediction and direction is valid
+              if (_param->_update_on_prediction)
+                if (PORT_READ(in_PREDICT_DIRECTION_VAL [i]))
+                  {
+                    Tcontrol_t direction = PORT_READ(in_PREDICT_DIRECTION [i]);
+                    
+                    if (_param->_have_bht)
+                      {
+                        Thistory_t bht_num_reg = internal_PREDICT_BHT_NUM_REG [i];
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %d",bht_num_reg);
+
+                        Thistory_t bht_history = reg_BHT[bht_num_reg];
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",bht_history);
+
+                        
+                        bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ;
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (new): %x",bht_history);
+                        reg_BHT [bht_num_reg] = bht_history;
+                      }
+
+                    if (_param->_have_pht)
+                      {
+                        Thistory_t pht_num_reg = internal_PREDICT_PHT_NUM_REG  [i];
+                        Thistory_t pht_num_bank= internal_PREDICT_PHT_NUM_BANK [i];
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %d",pht_num_reg);
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %d",pht_num_bank);
+
+                        Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (old): %x",pht_history);
+                        
+                        // PHT : saturation counter
+                        pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history));
+                        
+                        log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (new): %x",pht_history);
+                        
+                        reg_PHT [pht_num_bank][pht_num_reg] = pht_history;
+                      }
+                  }
+            }        
+
+        // ===================================================================
+        // =====[ UPDATE ]====================================================
+        // ===================================================================
+        
+        for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
+          if (PORT_READ(in_UPDATE_VAL[i]) and internal_UPDATE_ACK[i])
+            {
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * UPDATE [%d]",i);
+              
+              // Update if 
+              //  * update_on_prediction and miss
+              //  * not update_on_prediction
+              if (not _param->_update_on_prediction or (_param->_update_on_prediction and PORT_READ(in_UPDATE_MISS [i])))
+                {
+                  Taddress_t address     = PORT_READ(in_UPDATE_ADDRESS   [i]);
+                  Thistory_t history     = PORT_READ(in_UPDATE_HISTORY   [i]);
+                  Tcontrol_t direction   = PORT_READ(in_UPDATE_DIRECTION [i])&1;
+
+                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : %.8x",address);
+                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
+
+                  Thistory_t pht_bht_history = 0;
+
+                  if (_param->_have_bht)
+                    {
+                      Thistory_t bht_history = (history>>_param->_bht_history_rshift)&_param->_bht_history_mask;
+                      Thistory_t bht_num_reg = address & _param->_bht_address_mask;
+                      
+                      pht_bht_history = bht_history;
+                      
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",bht_history);
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %x",bht_num_reg);
+                      
+                      // BHT : shift register
+                      
+                      bht_history = ((bht_history<<1) | direction)&_param->_bht_history_mask ;
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (new): %x",bht_history);
+                      reg_BHT [bht_num_reg]               = bht_history;
+                    }
+
+                  if (_param->_have_pht)
+                    {
+                      Thistory_t pht_history = (history>>_param->_pht_history_rshift)&_param->_pht_history_mask;
+                      Thistory_t pht_num_reg = pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift);
+                      Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask;
+                      
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history (old): %x",pht_bht_history);
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (old): %x",pht_history);
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %x",pht_num_reg);
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %x",pht_num_bank);
+                      
+                      // PHT : saturation counter
+                      pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history));
+                      
+                      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (new): %x",pht_history);
+                      
+                      reg_PHT [pht_num_bank][pht_num_reg] = pht_history;
+                    }
+                }
+            }
+      }
+
+#if defined(DEBUG) and DEBUG_Two_Level_Branch_Predictor and (DEBUG >= DEBUG_TRACE)
+    if (0)
+    {
+      log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump Two_Level_Branch_Predictor");
+
+      if (_param->_have_bht)
+        {
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump BHT");
+
+          uint32_t limit = 4;
+
+          for (uint32_t i=0; i<_param->_bht_nb_shifter; i+=limit)
+            {
+              std::string str = "";
+
+              for (uint32_t j=0; j<limit; j++)
+                {
+                  uint32_t index = i+j;
+                  if (index >= _param->_bht_nb_shifter)
+                    break;
+                  else
+                    str+=toString("[%.4d] %.4x ",index,reg_BHT[index]);
+                }
+              
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"    %s",str.c_str());
+            }
+        }
+
+      if (_param->_have_pht)
+        {
+          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * Dump PHT");
+
+          uint32_t limit = 4;
+
+          for (uint32_t num_bank=0; num_bank <_param->_pht_nb_bank; ++num_bank)
+            {
+              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  [%.4d]",num_bank);
+
+              for (uint32_t i=0; i<_param->_pht_size_bank; i+=limit)
+                {
+                  std::string str = "";
+                  
+                  for (uint32_t j=0; j<limit; j++)
+                    {
+                      uint32_t index = i+j;
+                      if (index >= _param->_pht_nb_counter)
+                        break;
+                      else
+                        str+=toString("[%.4d] %.4x ",index,reg_PHT[num_bank][index]);
+                    }
+                  
+                  log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"    %s",str.c_str());
+                }
+            }
+        }
+    }
+#endif
 
 #if defined(STATISTICS) or defined(VHDL_TESTBENCH)
