#ifdef SYSTEMC
/*
 * $Id: Rename_unit_Glue_genMealy_insert_valack.cpp 123 2009-06-08 20:43:30Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Rename_unit_Glue/include/Rename_unit_Glue.h"

namespace morpheo                    {
namespace behavioural {
namespace core {
namespace multi_ooo_engine {
namespace ooo_engine {
namespace rename_unit {
namespace rename_unit_glue {


#undef  FUNCTION
#define FUNCTION "Rename_unit_Glue::genMealy_insert_valack"
  void Rename_unit_Glue::genMealy_insert_valack (void)
  {
    log_begin(Rename_unit_Glue,FUNCTION);
    log_function(Rename_unit_Glue,FUNCTION,_name.c_str());

    if (PORT_READ(in_NRESET))
      {
//     // Transaction must be in-order - made in rename_select
//     Tcontrol_t previous_transaction = true;
    
    for (uint32_t i=0; i<_param->_nb_inst_insert; i++)
      {
      //Tcontrol_t ACK                          = PORT_READ(in_INSERT_ACK                          [i]);
	Tcontrol_t NO_EXECUTE                   = PORT_READ(in_INSERT_RENAME_SELECT_NO_EXECUTE     [i]);
	Tcontrol_t RENAME_SELECT_VAL            = PORT_READ(in_INSERT_RENAME_SELECT_VAL            [i]);
	Tcontrol_t REGISTER_TRANSLATION_ACK     = PORT_READ(in_INSERT_REGISTER_TRANSLATION_ACK     [i]);
	Tcontrol_t LOAD_STORE_QUEUE_POINTER_ACK = PORT_READ(in_INSERT_LOAD_STORE_QUEUE_POINTER_ACK [i]);

// 	Tcontrol_t VAL                          = (
// 						   previous_transaction         and
// 						   RENAME_SELECT_VAL            and
// 						   REGISTER_TRANSLATION_ACK     and
// 						   LOAD_STORE_QUEUE_POINTER_ACK );
	Tcontrol_t RENAME_SELECT_ACK            = (
//                                                 previous_transaction         and
// 						   ACK                          and
						   REGISTER_TRANSLATION_ACK     and
						   LOAD_STORE_QUEUE_POINTER_ACK );
	Tcontrol_t REGISTER_TRANSLATION_VAL     = (
//                                                 previous_transaction         and
// 						   ACK                          and
						   RENAME_SELECT_VAL            and
						   LOAD_STORE_QUEUE_POINTER_ACK );
	Tcontrol_t LOAD_STORE_QUEUE_POINTER_VAL = (
//                                                 previous_transaction         and
// 						   ACK                          and
						   RENAME_SELECT_VAL            and
						   REGISTER_TRANSLATION_ACK     and
						   not NO_EXECUTE               );

        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"  * insert [%d]",i);
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * no_execute                   (r) : %d",NO_EXECUTE);
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * rename_select_val            (r) : %d",RENAME_SELECT_VAL           );
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * rename_select_ack            (w) : %d",RENAME_SELECT_ACK           );
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * register_translation_val     (w) : %d",REGISTER_TRANSLATION_VAL    );
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * register_translation_ack     (r) : %d",REGISTER_TRANSLATION_ACK    );
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * load_store_queue_pointer_val (w) : %d",LOAD_STORE_QUEUE_POINTER_VAL);
        log_printf(TRACE,Rename_unit_Glue,FUNCTION,"    * load_store_queue_pointer_ack (r) : %d",LOAD_STORE_QUEUE_POINTER_ACK);
	
 	PORT_WRITE(out_INSERT_NO_EXECUTE                   [i], NO_EXECUTE                  );
// 	PORT_WRITE(out_INSERT_VAL                          [i], VAL                         );
	PORT_WRITE(out_INSERT_RENAME_SELECT_ACK            [i], RENAME_SELECT_ACK           );
	PORT_WRITE(out_INSERT_REGISTER_TRANSLATION_VAL     [i], REGISTER_TRANSLATION_VAL    );
	PORT_WRITE(out_INSERT_LOAD_STORE_QUEUE_POINTER_VAL [i], LOAD_STORE_QUEUE_POINTER_VAL);

// 	previous_transaction = RENAME_SELECT_VAL and RENAME_SELECT_ACK;
      }
      }
    else
      {
        for (uint32_t i=0; i<_param->_nb_inst_insert; i++)
          {
// 	PORT_WRITE(out_INSERT_VAL                          [i], 0);
	PORT_WRITE(out_INSERT_RENAME_SELECT_ACK            [i], 0);
	PORT_WRITE(out_INSERT_REGISTER_TRANSLATION_VAL     [i], 0);
	PORT_WRITE(out_INSERT_LOAD_STORE_QUEUE_POINTER_VAL [i], 0);
          }
      }

    log_end(Rename_unit_Glue,FUNCTION);
  };

}; // end namespace rename_unit_glue
}; // end namespace rename_unit
}; // end namespace ooo_engine
}; // end namespace multi_ooo_engine
}; // end namespace core

}; // end namespace behavioural
}; // end namespace morpheo              
#endif
