Index: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/src/Decod_genMealy.cpp
===================================================================
--- trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/src/Decod_genMealy.cpp	(revision 87)
+++ trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/src/Decod_genMealy.cpp	(revision 88)
@@ -22,5 +22,6 @@
   void Decod::genMealy (void)
   {
-    log_printf(TRACE,Decod,FUNCTION,"Begin");
+    log_begin(Decod,FUNCTION);
+    log_function(Decod,FUNCTION,_name.c_str());
 
     //-----------------------------------
@@ -38,4 +39,5 @@
       {
 	decod_val   [i] = false;
+	predict_val [i] = false;
       }
 
@@ -57,18 +59,16 @@
     //-----------------------------------
     // scan all decod "slot_out"
-    log_printf(TRACE,Decod,FUNCTION,"KANE LIVE");    
-    std::list<select_t>::iterator it=select.begin();
+    std::list<generic::priority::select_t> * select = _priority->select();
+    std::list<generic::priority::select_t>::iterator it=select->begin();
     for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
       {
-	while ((it != select.end())     and  // have a no scanned "slot_in" ?
+	while ((it != select->end())    and  // have a no scanned "slot_in" ?
 	       (decod_val [i] == false) and  // have not a previous selected entry?
 	       (context_event_val == false)) // Have not a context_event (spr_access, exception, ...)
 	  {
-	    log_printf(TRACE,Decod,FUNCTION,"loop");    
-
 	    predict_val [i] = false;
 
-	    Tcontext_t x = it->_context ;
-	    uint32_t   y = it->_inst_fetch;
+	    Tcontext_t x = it->grp;
+	    uint32_t   y = it->elt;
 
 	    // Test if this instruction is valid
@@ -76,5 +76,7 @@
 		(can_continue [x]                == 1))    // context can decod instruction (have not a previous event)
 	      {
-		can_continue      [x] = can_continue_next [x];
+                log_printf(TRACE,Decod,FUNCTION,"  * IFETCH [%d][%d]",x,y);    
+
+		can_continue [x] = can_continue_next [x];
 
 		decod_val  [i]    = true;                        // fetch_val and decod_enable 
@@ -90,21 +92,47 @@
 		_decod_instruction->_is_delay_slot    = internal_CONTEXT_IS_DELAY_SLOT [x];
 
-		// Decod !
-		log_printf(TRACE,Decod,FUNCTION,"DECOD [%d]",i);
-		log_printf(TRACE,Decod,FUNCTION,"  * context       : %d",x);
-		log_printf(TRACE,Decod,FUNCTION,"  * fetch         : %d",y);
-		log_printf(TRACE,Decod,FUNCTION,"  * address       : %.8x",addr);
-		log_printf(TRACE,Decod,FUNCTION,"  * is_delay_slot : %d",internal_CONTEXT_IS_DELAY_SLOT [x]);
-
-		instruction_decod (_decod_instruction, _decod_param[x]);
-
-		Ttype_t type = _decod_instruction->_type;
+                // Test IFetch exception
+                Texception_t ifetch_exception = PORT_READ(in_IFETCH_EXCEPTION [x]);
+
+                if (ifetch_exception == EXCEPTION_IFETCH_NONE)
+                  {
+                    // Decod !
+                    log_printf(TRACE,Decod,FUNCTION,"  * DECOD [%d]",i);
+                    log_printf(TRACE,Decod,FUNCTION,"    * context       : %d",x);
+                    log_printf(TRACE,Decod,FUNCTION,"    * fetch         : %d",y);
+                    log_printf(TRACE,Decod,FUNCTION,"    * address       : %.8x (%.8x)",addr,(addr<<2));
+                    log_printf(TRACE,Decod,FUNCTION,"    * is_delay_slot : %d",internal_CONTEXT_IS_DELAY_SLOT [x]);
+                    
+                    instruction_decod (_decod_instruction, _decod_param[x]);
+                  }
+                else
+                  {
+                    // No decod : nop
+                    instruction_l_nop (_decod_instruction, _decod_param[x]);
+
+                    _decod_instruction->_exception_use = EXCEPTION_USE_NONE;
+                    _decod_instruction->_exception     = exception_ifetch_to_exception_decod(ifetch_exception);
+                    
+                    // INSTRUCTION_TLB  
+                    // INSTRUCTION_PAGE 
+                    // BUS_ERROR        
+                    if (_decod_instruction->_is_delay_slot)
+                      _decod_instruction->_address_next       = _decod_instruction->_address_previous;
+                    else
+                      _decod_instruction->_address_next       = _decod_instruction->_address;
+                    
+                    _decod_instruction->_event_type         = EVENT_TYPE_EXCEPTION;
+                  }
+
+		Ttype_t  type  = _decod_instruction->_type;
+                Tdepth_t depth = (_param->_have_port_depth)?PORT_READ(in_CONTEXT_DEPTH [x]):0; // DEPTH_CURRENT
 
 		if (_param->_have_port_context_id)
 		PORT_WRITE(out_DECOD_CONTEXT_ID    [i], x);
 		if (_param->_have_port_depth)
-		PORT_WRITE(out_DECOD_DEPTH         [i], PORT_READ(in_CONTEXT_DEPTH [x]));
+                PORT_WRITE(out_DECOD_DEPTH         [i], depth);
 		PORT_WRITE(out_DECOD_TYPE          [i], type);
 		PORT_WRITE(out_DECOD_OPERATION     [i], _decod_instruction->_operation     );
+ 		PORT_WRITE(out_DECOD_NO_EXECUTE    [i], _decod_instruction->_no_execute    );
 		PORT_WRITE(out_DECOD_IS_DELAY_SLOT [i], _decod_instruction->_is_delay_slot );
 		PORT_WRITE(out_DECOD_ADDRESS       [i], addr);
@@ -122,8 +150,11 @@
 		PORT_WRITE(out_DECOD_NUM_REG_RE    [i], _decod_instruction->_num_reg_re    );
 		PORT_WRITE(out_DECOD_EXCEPTION_USE [i], _decod_instruction->_exception_use );
+// 		PORT_WRITE(out_DECOD_EXCEPTION     [i], _decod_instruction->_exception     );
 
 		if (type == TYPE_BRANCH)
 		  {
-		    log_printf(TRACE,Decod,FUNCTION,"  * type is branch");
+		    log_printf(TRACE,Decod,FUNCTION,"    * type is branch");
+		    log_printf(TRACE,Decod,FUNCTION,"      * address src  : %.8x (%.8x)",_decod_instruction->_address     ,_decod_instruction->_address     <<2);
+		    log_printf(TRACE,Decod,FUNCTION,"      * address dest : %.8x (%.8x)",_decod_instruction->_address_next,_decod_instruction->_address_next<<2);
 
 		    predict_val [i]     = ifetch_ack  [x][y] // and decod_val [i]
@@ -136,6 +167,6 @@
 		    PORT_WRITE(out_PREDICT_MATCH_INST_IFETCH_PTR       [i],y == ((_param->_have_port_inst_ifetch_ptr)?PORT_READ(in_IFETCH_INST_IFETCH_PTR [x]):0));
 		    PORT_WRITE(out_PREDICT_BRANCH_STATE                [i],PORT_READ(in_IFETCH_BRANCH_STATE                [x]));
-		    if (_param->_have_port_branch_update_prediction_id)
-		    PORT_WRITE(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [i],PORT_READ(in_IFETCH_BRANCH_UPDATE_PREDICTION_ID [x]));
+		    if (_param->_have_port_depth)
+                    PORT_WRITE(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [i],PORT_READ(in_IFETCH_BRANCH_UPDATE_PREDICTION_ID [x]));
 		    PORT_WRITE(out_PREDICT_BRANCH_CONDITION            [i],_decod_instruction->_branch_condition  );
 // 		    PORT_WRITE(out_PREDICT_BRANCH_STACK_WRITE          [i],_decod_instruction->_branch_stack_write);
@@ -145,5 +176,5 @@
 		
 		    //can_continue_next [x] = PORT_READ(in_PREDICT_CAN_CONTINUE [i]); // can continue is set if direction is "not take" (also, continue is sequential order)
-		    can_continue_next [x] = false; // one branch per context
+		    can_continue_next [x] = false; // one branch per context, the DS don't execute
 		  }
 
@@ -160,4 +191,6 @@
 		    if (_param->_have_port_context_id)
 		    PORT_WRITE(out_CONTEXT_EVENT_CONTEXT_ID   , x);
+                    if (_param->_have_port_depth)
+		    PORT_WRITE(out_CONTEXT_EVENT_DEPTH        , depth);
 		    PORT_WRITE(out_CONTEXT_EVENT_TYPE         , _decod_instruction->_event_type    );
 		    PORT_WRITE(out_CONTEXT_EVENT_IS_DELAY_SLOT, _decod_instruction->_is_delay_slot );
@@ -184,9 +217,9 @@
 	      }
 
-	    log_printf(TRACE,Decod,FUNCTION,"  - num_(decod, context, fetch) : %d %d %d",i, x, y);
-	    log_printf(TRACE,Decod,FUNCTION,"    - ifetch_ack        : %d",ifetch_ack  [x][y]);
-	    log_printf(TRACE,Decod,FUNCTION,"    - context_event_val : %d",context_event_val );
-	    log_printf(TRACE,Decod,FUNCTION,"    - predict_val       : %d",predict_val [i]   );
-	    log_printf(TRACE,Decod,FUNCTION,"    - decod_val         : %d",decod_val   [i]   );
+	    log_printf(TRACE,Decod,FUNCTION,"    - num_(decod, context, fetch) : %d %d %d",i, x, y);
+	    log_printf(TRACE,Decod,FUNCTION,"      - ifetch_ack        : %d",ifetch_ack  [x][y]);
+	    log_printf(TRACE,Decod,FUNCTION,"      - context_event_val : %d",context_event_val );
+	    log_printf(TRACE,Decod,FUNCTION,"      - predict_val       : %d",predict_val [i]   );
+	    log_printf(TRACE,Decod,FUNCTION,"      - decod_val         : %d",decod_val   [i]   );
 	    
 	    it ++;
@@ -207,7 +240,11 @@
 	PORT_WRITE(out_PREDICT_VAL [i], predict_val [i]);
 	PORT_WRITE(out_DECOD_VAL   [i], decod_val   [i]);
-      }
-
-    log_printf(FUNC,Decod,FUNCTION,"End");
+        
+#ifdef STATISTICS
+        internal_DECOD_VAL [i] = decod_val [i];
+#endif
+      }
+
+    log_end(Decod,FUNCTION);
   };
 
