/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Write_unit/Write_unit/Write_queue/include/Write_queue.h"

namespace morpheo                    {
namespace behavioural {
namespace core {
namespace multi_execute_loop {
namespace execute_loop {
namespace multi_write_unit {
namespace write_unit {
namespace write_queue {


#undef  FUNCTION
#define FUNCTION "Write_queue::deallocation"
  void Write_queue::deallocation (void)
  {
    log_printf(FUNC,Write_queue,FUNCTION,"Begin");

    if (_usage & USE_SYSTEMC)
      {
	delete    in_CLOCK ;
	delete    in_NRESET;
	
	// -----[ Interface "Write_queue_in" ]--------------------------------    
	delete      in_WRITE_QUEUE_IN_VAL          ;
	delete     out_WRITE_QUEUE_IN_ACK          ;
	if (_param->_have_port_context_id)
	delete      in_WRITE_QUEUE_IN_CONTEXT_ID   ;
	if (_param->_have_port_front_end_id)
	delete      in_WRITE_QUEUE_IN_FRONT_END_ID ;
	if (_param->_have_port_ooo_engine_id)
	delete      in_WRITE_QUEUE_IN_OOO_ENGINE_ID;
        if (_param->_have_port_packet_id)
	delete      in_WRITE_QUEUE_IN_PACKET_ID    ;
//      delete      in_WRITE_QUEUE_IN_OPERATION    ;
//      delete      in_WRITE_QUEUE_IN_TYPE         ;
        delete      in_WRITE_QUEUE_IN_WRITE_RD     ;
        delete      in_WRITE_QUEUE_IN_NUM_REG_RD   ;
        delete      in_WRITE_QUEUE_IN_DATA_RD      ;
        delete      in_WRITE_QUEUE_IN_WRITE_RE     ;
        delete      in_WRITE_QUEUE_IN_NUM_REG_RE   ;
        delete      in_WRITE_QUEUE_IN_DATA_RE      ;
        delete      in_WRITE_QUEUE_IN_EXCEPTION    ;
        delete      in_WRITE_QUEUE_IN_NO_SEQUENCE  ;
        delete      in_WRITE_QUEUE_IN_ADDRESS      ;

	// -----[ Interface "Write_queue_out" ]-------------------------------    
        delete     out_WRITE_QUEUE_OUT_VAL          ;
        delete      in_WRITE_QUEUE_OUT_ACK          ;
        if (_param->_have_port_context_id)
	delete     out_WRITE_QUEUE_OUT_CONTEXT_ID   ;
        if (_param->_have_port_front_end_id)
	delete     out_WRITE_QUEUE_OUT_FRONT_END_ID ;
        if (_param->_have_port_ooo_engine_id)
	delete     out_WRITE_QUEUE_OUT_OOO_ENGINE_ID;
        if (_param->_have_port_packet_id)
	delete     out_WRITE_QUEUE_OUT_PACKET_ID    ;
//      delete     out_WRITE_QUEUE_OUT_OPERATION    ;
//      delete     out_WRITE_QUEUE_OUT_TYPE         ;
        delete     out_WRITE_QUEUE_OUT_FLAGS        ;
        delete     out_WRITE_QUEUE_OUT_EXCEPTION    ;
        delete     out_WRITE_QUEUE_OUT_NO_SEQUENCE  ;
        delete     out_WRITE_QUEUE_OUT_ADDRESS      ;

	// -----[ Interface "gpr_write" ]-------------------------------------
        delete []  out_GPR_WRITE_VAL               ;
        delete []   in_GPR_WRITE_ACK               ;
        if (_param->_have_port_ooo_engine_id)
	delete []  out_GPR_WRITE_OOO_ENGINE_ID     ;
        delete []  out_GPR_WRITE_NUM_REG           ;
        delete []  out_GPR_WRITE_DATA              ;
	
	// -----[ Interface "spr_write" ]-------------------------------------
        delete []  out_SPR_WRITE_VAL               ;
        delete []   in_SPR_WRITE_ACK               ;
        if (_param->_have_port_ooo_engine_id)
	delete []  out_SPR_WRITE_OOO_ENGINE_ID     ;
        delete []  out_SPR_WRITE_NUM_REG           ;
        delete []  out_SPR_WRITE_DATA              ;

	// -----[ Interface "bypass_write" ]----------------------------------
        if (_param->_have_port_ooo_engine_id)
	delete []  out_BYPASS_WRITE_OOO_ENGINE_ID ;
        delete []  out_BYPASS_WRITE_GPR_VAL       ;
        delete []  out_BYPASS_WRITE_GPR_NUM_REG   ;
        delete []  out_BYPASS_WRITE_GPR_DATA      ;
        delete []  out_BYPASS_WRITE_SPR_VAL       ;
        delete []  out_BYPASS_WRITE_SPR_NUM_REG   ;
        delete []  out_BYPASS_WRITE_SPR_DATA      ;
      }

    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
    while (not _queue->empty())
      {
	delete _queue->front();
	_queue->pop_front();
      }
    delete _queue;

    delete _component;

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

}; // end namespace write_queue
}; // end namespace write_unit
}; // end namespace multi_write_unit
}; // end namespace execute_loop
}; // end namespace multi_execute_loop
}; // end namespace core

}; // end namespace behavioural
}; // end namespace morpheo              
