Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp	(revision 4)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp	(revision 5)
@@ -45,4 +45,7 @@
 
     // Interface Branch_complete
+  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_VAL                    ;
+  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_VAL        ;
+
   sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_0_ACK        ;
   sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_1_ACK        ;
@@ -57,5 +60,6 @@
   sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY;
   sc_signal<Thistory_t>           ** BRANCH_COMPLETE_HISTORY                ;
-
+  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_DIRECTION              ;
+  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_DIRECTION  ;
   string rename;
 
@@ -108,5 +112,6 @@
 
     // Interface Branch_complete
-    
+    BRANCH_COMPLETE_VAL                     = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
+    BRANCH_COMPLETE_PREDICTOR_2_VAL         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
     BRANCH_COMPLETE_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
     BRANCH_COMPLETE_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
@@ -120,7 +125,13 @@
     BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
     BRANCH_COMPLETE_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_branch_complete     ];
+    BRANCH_COMPLETE_DIRECTION               = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
+    BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
 
     for (uint32_t i=0; i<_param._nb_branch_complete; i++)
       {
+	rename = "BRANCH_COMPLETE_VAL_"                      +toString(i);
+	BRANCH_COMPLETE_VAL                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
+	rename = "BRANCH_COMPLETE_PREDICTOR_2_VAL_"          +toString(i);
+	BRANCH_COMPLETE_PREDICTOR_2_VAL                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
 	rename = "BRANCH_COMPLETE_PREDICTOR_0_ACK_"          +toString(i);
 	BRANCH_COMPLETE_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
@@ -145,4 +156,8 @@
 	rename = "BRANCH_COMPLETE_HISTORY_"                +toString(i);
 	BRANCH_COMPLETE_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
+	rename = "BRANCH_COMPLETE_DIRECTION_"              +toString(i);
+	BRANCH_COMPLETE_DIRECTION                         [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
+	rename = "BRANCH_COMPLETE_PREDICTOR_2_DIRECTION_"  +toString(i);
+	BRANCH_COMPLETE_PREDICTOR_2_DIRECTION             [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
       }
 
@@ -192,4 +207,7 @@
 	if (_param._have_meta_predictor)
 	  {
+	(*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_VAL                     [i])) (*(BRANCH_COMPLETE_VAL                     [i]));
+	(*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_VAL         [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]));
+
 	(*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_0_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_ACK         [i]));
 	(*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_1_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_ACK         [i]));
@@ -214,4 +232,9 @@
 	(*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]));
 	(*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_HISTORY                 [i])) (*(BRANCH_COMPLETE_HISTORY                 [i]));
+	if (_param._have_meta_predictor)	
+	  {
+	(*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_DIRECTION               [i])) (*(BRANCH_COMPLETE_DIRECTION               [i]));
+	(*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]));
+	  }
       }
 
@@ -241,4 +264,5 @@
   Tcontrol_t     predict_direction                       [_param._nb_prediction];
 	        
+  Tcontrol_t     branch_complete_predictor_2_val         [_param._nb_branch_complete];
   Tcontrol_t     branch_complete_ack                     [_param._nb_branch_complete];
   Tbht_history_t branch_complete_predictor_0_bht_history [_param._nb_branch_complete];
@@ -248,4 +272,5 @@
   Tbht_history_t branch_complete_predictor_2_bht_history [_param._nb_branch_complete];
   Tpht_history_t branch_complete_predictor_2_pht_history [_param._nb_branch_complete];
+  Tcontrol_t     branch_complete_predictor_2_direction   [_param._nb_branch_complete];
 
   uint32_t shift_0 = 0;
@@ -255,5 +280,5 @@
   uint32_t shift_4 = shift_3 + _param._predictor_1_pht_size_counter;
   uint32_t shift_5 = shift_4 + _param._predictor_2_bht_size_shifter;
-//uint32_t shift_5 = shift_5 + _param._predictor_2_pht_size_counter;
+//uint32_t shift_6 = shift_5 + _param._predictor_2_pht_size_counter;
 
   for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
@@ -353,4 +378,40 @@
 							     (branch_complete_predictor_2_bht_history [i] << shift_4) |
 							     (branch_complete_predictor_2_pht_history [i] << shift_5) );
+
+	  Tcontrol_t direction_0 = ((_param._predictor_0_have_pht)?(branch_complete_predictor_0_pht_history [i] >> (_param._predictor_0_pht_size_counter-1)):(branch_complete_predictor_0_bht_history [i] >> (_param._predictor_0_bht_size_shifter-1)))&1;
+	  Tcontrol_t direction_1 = ((_param._predictor_1_have_pht)?(branch_complete_predictor_1_pht_history [i] >> (_param._predictor_1_pht_size_counter-1)):(branch_complete_predictor_1_bht_history [i] >> (_param._predictor_1_bht_size_shifter-1)))&1;
+	  Tcontrol_t direction_2 = ((_param._predictor_2_have_pht)?(branch_complete_predictor_2_pht_history [i] >> (_param._predictor_2_pht_size_counter-1)):(branch_complete_predictor_2_bht_history [i] >> (_param._predictor_2_bht_size_shifter-1)))&1;
+
+	  Tcontrol_t direction   = ((rand()%2) != 0);
+	  Tcontrol_t val         = ((rand()%2) != 0);
+
+	  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} " << endl 
+	       << "  * val             : " << val << endl
+	       << "  * direction_good  : " << direction << endl
+	       << "    * direction_0   : " << direction_0 << endl
+	       << "    * direction_1   : " << direction_1 << endl
+	       << "    * direction_2   : " << direction_2 << endl;
+	  
+	  BRANCH_COMPLETE_VAL       [i] ->write (val);
+	  BRANCH_COMPLETE_DIRECTION [i] ->write (direction);
+	  
+	  if (val == 0)
+	    {
+	      branch_complete_predictor_2_val [i] = val;
+	    }
+	  else
+	    {
+	      branch_complete_predictor_2_val [i] = (direction_0 xor direction_1);
+	      if (direction_2 == 0)
+		if (direction_0 == direction)
+		  branch_complete_predictor_2_direction [i] = 0;
+		else
+		  branch_complete_predictor_2_direction [i] = 1;
+	      else
+		if (direction_1 == direction)
+		  branch_complete_predictor_2_direction [i] = 1;
+		else
+		  branch_complete_predictor_2_direction [i] = 0;
+	    }
 	}
 
@@ -370,4 +431,9 @@
 	if (_param._have_meta_predictor)	
 	  {					
+	  TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]->read(), branch_complete_predictor_2_val         [i]);
+
+	  if (branch_complete_predictor_2_val         [i])
+	  TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]->read(), branch_complete_predictor_2_direction   [i]);  
+
 	if (_param._predictor_0_have_bht)
 	  TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]->read(), branch_complete_predictor_0_bht_history [i]);
