#ifdef SYSTEMC
//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
/*
 * $Id: Register_unit_Glue_genMealy_insert.cpp 88 2008-12-10 18:31:39Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Register_unit/Register_unit_Glue/include/Register_unit_Glue.h"

namespace morpheo                    {
namespace behavioural {
namespace core {
namespace multi_execute_loop {
namespace execute_loop {
namespace register_unit {
namespace register_unit_glue {


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

    for (uint32_t i=0; i<_param->_nb_ooo_engine; i++)
      for (uint32_t j=0; j<_param->_nb_inst_insert_rob [i]; j++)
        {
          Tcontrol_t val            = PORT_READ(in_INSERT_ROB_VAL [i][j]);
          Tcontrol_t gpr_use        = PORT_READ(in_INSERT_ROB_RD_USE [i][j]);
          Tcontrol_t spr_use        = PORT_READ(in_INSERT_ROB_RE_USE [i][j]);
          Tcontrol_t gpr_status_ack = PORT_READ(in_INSERT_ROB_GPR_STATUS_ACK [i][j]);
          Tcontrol_t spr_status_ack = PORT_READ(in_INSERT_ROB_SPR_STATUS_ACK [i][j]);
	  
          Tcontrol_t ack            = (gpr_status_ack and 
                                       spr_status_ack);	    
          Tcontrol_t gpr_status_val = (val     and 
                                       gpr_use and 
                                       spr_status_ack);
          Tcontrol_t spr_status_val = (val     and 
                                       spr_use and
                                       gpr_status_ack);

          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"  * insert_rob [%d][%d]",i,j);
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * val            (r) : %d",val           );
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * ack            (w) : %d",ack           );
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * gpr_use (rd)   (r) : %d",gpr_use       );
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * gpr_status_val (w) : %d",gpr_status_val);
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * gpr_status_ack (r) : %d",gpr_status_ack);
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * spr_use (re)   (r) : %d",spr_use       );
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * spr_status_val (w) : %d",spr_status_val);
          log_printf(TRACE,OOO_Engine_Glue,FUNCTION,"    * spr_status_ack (r) : %d",spr_status_ack);

          PORT_WRITE(out_INSERT_ROB_ACK            [i][j], ack           );
          PORT_WRITE(out_INSERT_ROB_GPR_STATUS_VAL [i][j], gpr_status_val);
          PORT_WRITE(out_INSERT_ROB_SPR_STATUS_VAL [i][j], spr_status_val);

        }

    log_end(Register_unit_Glue,FUNCTION);
  };

}; // end namespace register_unit_glue
}; // end namespace register_unit
}; // end namespace execute_loop
}; // end namespace multi_execute_loop
}; // end namespace core

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