#ifdef SYSTEMC
//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/include/Load_store_unit.h"

namespace morpheo                    {
namespace behavioural {
namespace core {
namespace multi_execute_loop {
namespace execute_loop {
namespace multi_execute_unit {
namespace execute_unit {
namespace load_store_unit {


#undef  FUNCTION
#define FUNCTION "Load_store_unit::function_speculative_load_commit_genMoore"
  void Load_store_unit::function_speculative_load_commit_genMoore (void)
  {
    log_printf(FUNC,Load_store_unit,FUNCTION,"Begin");

    // ~~~~~[ Interface "memory_out" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Test store and load queue
    Tcontext_t         memory_out_context_id = 0;
    Tpacket_t          memory_out_packet_id  = 0;
#ifdef HAVE_MEMORY_OUT_OPERATION
    Toperation_t       memory_out_operation  = 0;
#endif
#ifdef HAVE_MEMORY_OUT_TYPE
    Ttype_t            memory_out_type       = 0;
#endif
    Tcontrol_t         memory_out_write_rd   = 0;
    Tgeneral_address_t memory_out_num_reg_rd = 0;
    Tgeneral_data_t    memory_out_data_rd    = 0;
//  Tcontrol_t         memory_out_write_re   = 0;
//  Tspecial_address_t memory_out_num_reg_re = 0;
//  Tspecial_data_t    memory_out_data_re    = 0;
    Texception_t       memory_out_exception  = 0;

    internal_MEMORY_OUT_VAL          = 0;

    // TODO : now only store queue

    // Test an store must be commited.

    
    if (_store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._state == STORE_QUEUE_COMMIT)
      {
	internal_MEMORY_OUT_VAL          = 1;
	internal_MEMORY_OUT_SELECT_QUEUE = SELECT_STORE_QUEUE;
	
	memory_out_context_id= _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._context_id;
	memory_out_packet_id = _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._packet_id ;
#ifdef HAVE_MEMORY_OUT_OPERATION
	memory_out_operation = _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._operation;
#endif
#ifdef HAVE_MEMORY_OUT_TYPE
  	memory_out_type      = _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._type;
#endif
//	memory_out_write_rd  
//	memory_out_num_reg_rd
//	memory_out_data_rd   
	memory_out_exception = _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._exception;
      }

    PORT_WRITE(out_MEMORY_OUT_VAL       , internal_MEMORY_OUT_VAL);

    PORT_WRITE(out_MEMORY_OUT_CONTEXT_ID, memory_out_context_id);
    PORT_WRITE(out_MEMORY_OUT_PACKET_ID , memory_out_packet_id );
#ifdef HAVE_MEMORY_OUT_OPERATION
    PORT_WRITE(out_MEMORY_OUT_OPERATION , memory_out_operation );
#endif
#ifdef HAVE_MEMORY_OUT_TYPE
    PORT_WRITE(out_MEMORY_OUT_TYPE      , memory_out_type      );
#endif
    PORT_WRITE(out_MEMORY_OUT_WRITE_RD  , memory_out_write_rd  );
    PORT_WRITE(out_MEMORY_OUT_NUM_REG_RD, memory_out_num_reg_rd);
    PORT_WRITE(out_MEMORY_OUT_DATA_RD   , memory_out_data_rd   );
//  PORT_WRITE(out_MEMORY_OUT_WRITE_RE  , memory_out_write_re  );
//  PORT_WRITE(out_MEMORY_OUT_NUM_REG_RE, memory_out_num_reg_re);
//  PORT_WRITE(out_MEMORY_OUT_DATA_RE   , memory_out_data_re   );
    PORT_WRITE(out_MEMORY_OUT_EXCEPTION , memory_out_exception );


    log_printf(FUNC,Load_store_unit,FUNCTION,"End");
  };

}; // end namespace load_store_unit
}; // end namespace execute_unit
}; // end namespace multi_execute_unit
}; // end namespace execute_loop
}; // end namespace multi_execute_loop
}; // end namespace core

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