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 145)
+++ 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 146)
@@ -9,5 +9,5 @@
 #include "Behavioural/include/Selftest.h"
 
-#define NB_PARAMS 11
+#define NB_PARAMS 12
 
 void usage (int argc, char * argv[])
@@ -15,15 +15,16 @@
   err (_("<Usage> %s name_instance list_params.\n"),argv[0]);
   err (_("list_params is :\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"));
+  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 (_(" * pht_scheme             (Tpht_scheme_t)\n"));
+  err (_(" * update_on_prediction   (bool         )\n"));
 
   exit (1);
@@ -43,27 +44,29 @@
   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  ;
+  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;
+  Tpht_scheme_t pht_scheme            ;
+  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);
+  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(pht_scheme            ,Tpht_scheme_t,argv,x);
+  SELFTEST0(update_on_prediction  ,bool         ,argv,x);
 
   int _return = EXIT_SUCCESS;
@@ -82,4 +85,5 @@
          pht_nb_counter        ,
          pht_size_address_share,
+	 pht_scheme            ,
          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/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 145)
+++ 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 146)
@@ -27,55 +27,58 @@
   {
     //-----[ 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_shift       ;
-  public : Thistory_t _pht_history_mask        ;
-  public : Thistory_t _pht_history_shift       ;
-                                               
-  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_shift ;
-  public : Taddress_t _pht_address_bank_mask   ;
-  public : Taddress_t _pht_address_bank_shift  ;
+  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 : Tpht_scheme_t _pht_scheme              ;
+  public : bool          _update_on_prediction    ;
 
-  public : Thistory_t _bht_init_take           ;
-  public : Thistory_t _bht_init_ntake          ;
-
-  public : Thistory_t _pht_init_take           ;
-  public : Thistory_t _pht_init_ntake          ;
+  public : Thistory_t    _pht_counter_max         ;
+  public : Thistory_t    _pht_threshold_up        ;
+  public : Thistory_t    _pht_threshold_down      ;
+        	         
+  public : uint32_t      _size_history            ;
+                                                  
+  public : Thistory_t    _bht_history_mask        ;
+  public : Thistory_t    _bht_history_shift       ;
+  public : Thistory_t    _pht_history_mask        ;
+  public : Thistory_t    _pht_history_shift       ;
+                                                  
+  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_shift ;
+  public : Taddress_t    _pht_address_bank_mask   ;
+  public : Taddress_t    _pht_address_bank_shift  ;
+		         
+  public : Thistory_t    _bht_init_take           ;
+  public : Thistory_t    _bht_init_ntake          ;
+		         
+  public : Thistory_t    _pht_init_take           ;
+  public : Thistory_t    _pht_init_ntake          ;
 
     //-----[ methods ]-----------------------------------------------------------
-  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  (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,
+			Tpht_scheme_t pht_scheme            , 
+                        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/Types.h
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Types.h	(revision 145)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/include/Types.h	(revision 146)
@@ -21,5 +21,4 @@
 namespace two_level_branch_predictor {
 
-
 }; // end namespace two_level_branch_predictor
 }; // end namespace meta_predictor
@@ -29,5 +28,4 @@
 }; // end namespace multi_front_end
 }; // end namespace core
-
 }; // end namespace behavioural
 }; // end namespace morpheo              
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 145)
+++ 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 146)
@@ -22,16 +22,17 @@
 #undef  FUNCTION
 #define FUNCTION "Two_Level_Branch_Predictor::Parameters"
-  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)
+  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,
+			  Tpht_scheme_t pht_scheme            ,
+                          bool          update_on_prediction  ,
+                          bool          is_toplevel)
   {
     log_begin(Two_Level_Branch_Predictor,FUNCTION);
@@ -47,4 +48,5 @@
     _pht_nb_counter          = (have_pht)?(pht_nb_counter  ):0;
     _pht_size_address_share  = (have_bht and have_pht)?(pht_size_address_share):0;
+    _pht_scheme              = pht_scheme            ;
     _update_on_prediction    = update_on_prediction  ;
                              
@@ -97,5 +99,7 @@
       {
         _pht_counter_max         = (1<<_pht_size_counter)-1;
-        
+	_pht_threshold_up        = (1<<(_pht_size_counter-1))+1;
+	_pht_threshold_down      = (1<<(_pht_size_counter-1))-1;
+
         _pht_size_bank           = (_have_bht)?(1<<_bht_size_shifter):1;
         _pht_nb_bank             = _pht_nb_counter / _pht_size_bank;
Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_print.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_print.cpp	(revision 145)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/src/Parameters_print.cpp	(revision 146)
@@ -9,5 +9,5 @@
 #include "Behavioural/include/XML.h"
 
-namespace morpheo                    {
+namespace morpheo {
 namespace behavioural {
 namespace core {
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 145)
+++ 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 146)
@@ -10,5 +10,5 @@
 // #include <assert.h>
 
-namespace morpheo                    {
+namespace morpheo {
 namespace behavioural {
 namespace core {
@@ -77,7 +77,30 @@
                         log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (old): %llx",pht_history);
                         
+			// TODO -> don't change PHT here !
+			Thistory_t min = 0;
+			Thistory_t max = _param->_pht_counter_max;
+
                         // 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));
-                        
+			switch (_param->_pht_scheme)
+			  {
+			  case PHT_SCHEME_COUNTER :
+			    {
+			      pht_history = (direction==1)?((pht_history<max)?(pht_history+1):(max)):((pht_history>min)?(pht_history-1):(min));
+			      break;
+			    }
+			  case PHT_SCHEME_FSM :
+			    {
+			      Thistory_t down = _param->_pht_threshold_down;
+			      Thistory_t up   = _param->_pht_threshold_up;
+
+			      pht_history = (direction==1)?(((pht_history==max) or (pht_history==up))?(max):(pht_history+1)):(((pht_history==min) or (pht_history==down))?(min):(pht_history-1));
+			      break;
+			    }
+			  default :
+			    {
+			      break;
+			    }
+			  }
+
                         log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history (new): %llx",pht_history);
                         
@@ -169,5 +192,48 @@
                       else
 			{
-			  pht_history = (direction==1)?((pht_history<_param->_pht_counter_max)?(pht_history+1):(pht_history)):((pht_history>0)?(pht_history-1):(pht_history));
+			  Thistory_t min = 0;
+			  Thistory_t max = _param->_pht_counter_max;
+			  
+			  // PHT : saturation counter
+			  switch (_param->_pht_scheme)
+			    {
+			    case PHT_SCHEME_COUNTER :
+			      {
+				//  [ 11 ] -- NT -> [ 10 ] 
+				//  [    ] <-  T -- [    ]
+				//                   ^  |
+				//                   |  |
+				//                   T NT
+				//                   |  |
+				//                   |  V
+				//  [ 00 ] --  T -> [ 01 ] 
+				//  [    ] <- NT -- [    ]
+
+ 				pht_history = (direction==1)?((pht_history<max)?(pht_history+1):(max)):((pht_history>min)?(pht_history-1):(min));
+				break;
+			      }
+			    case PHT_SCHEME_FSM :
+			      {
+				//  [11] -- NT -> [10] 
+				//  [  ] <-  T -- [  ]
+				//   ^              |
+				//   |   	    |
+				//   T   	   NT
+				//   |   	    |
+				//   |   	    V
+				//  [00] -- NT -> [00] 
+				//  [  ] <-  T -- [  ]
+
+				Thistory_t down = _param->_pht_threshold_down;
+				Thistory_t up   = _param->_pht_threshold_up;
+				
+				pht_history = (direction==1)?(((pht_history==max) or (pht_history==up))?(max):(pht_history+1)):(((pht_history==min) or (pht_history==down))?(min):(pht_history-1));
+				break;
+			      }
+			    default :
+			      {
+				break;
+			      }
+			    }
 			}
                       
