/*
 * $Id: Context_State_deallocation.cpp 97 2008-12-19 15:34:00Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Core/Multi_Front_end/Front_end/Context_State/include/Context_State.h"
#include "Behavioural/include/Allocation.h"

namespace morpheo                    {
namespace behavioural {
namespace core {
namespace multi_front_end {
namespace front_end {
namespace context_state {


#undef  FUNCTION
#define FUNCTION "Context_State::deallocation"
  void Context_State::deallocation (void)
  {
    log_begin(Context_State,FUNCTION);

    if (usage_is_set(_usage,USE_SYSTEMC))
      {
	delete    in_CLOCK ;
	delete    in_NRESET;

        DELETE1_SIGNAL( in_BRANCH_EVENT_VAL                   ,_param->_nb_context,1);
        DELETE1_SIGNAL(out_BRANCH_EVENT_ACK                   ,_param->_nb_context,1);
//      DELETE1_SIGNAL( in_BRANCH_EVENT_CONTEXT_ID            ,_param->_nb_context,_param->_size_context_id);
//      DELETE1_SIGNAL( in_BRANCH_EVENT_DEPTH                 ,_param->_nb_context,_param->_size_depth);
//      DELETE1_SIGNAL( in_BRANCH_EVENT_MISS_PREDICTION       ,_param->_nb_context,1);
        DELETE1_SIGNAL( in_BRANCH_EVENT_ADDRESS_SRC           ,_param->_nb_context,_param->_size_instruction_address);
        DELETE1_SIGNAL( in_BRANCH_EVENT_ADDRESS_DEST_VAL      ,_param->_nb_context,1);
        DELETE1_SIGNAL( in_BRANCH_EVENT_ADDRESS_DEST          ,_param->_nb_context,_param->_size_instruction_address);

        DELETE1_SIGNAL( in_DECOD_EVENT_VAL                    ,_param->_nb_decod_unit,1);
        DELETE1_SIGNAL(out_DECOD_EVENT_ACK                    ,_param->_nb_decod_unit,1);
        DELETE1_SIGNAL( in_DECOD_EVENT_CONTEXT_ID             ,_param->_nb_decod_unit,_param->_size_context_id);
        DELETE1_SIGNAL( in_DECOD_EVENT_DEPTH                  ,_param->_nb_decod_unit,_param->_size_depth);
        DELETE1_SIGNAL( in_DECOD_EVENT_TYPE                   ,_param->_nb_decod_unit,_param->_size_event_type);
        DELETE1_SIGNAL( in_DECOD_EVENT_IS_DELAY_SLOT          ,_param->_nb_decod_unit,1);
        DELETE1_SIGNAL( in_DECOD_EVENT_ADDRESS                ,_param->_nb_decod_unit,_param->_size_instruction_address);
        DELETE1_SIGNAL( in_DECOD_EVENT_ADDRESS_EPCR           ,_param->_nb_decod_unit,_param->_size_instruction_address);
        
	DELETE_SIGNAL ( in_COMMIT_EVENT_VAL                   ,1);
        DELETE_SIGNAL (out_COMMIT_EVENT_ACK                   ,1);
        DELETE_SIGNAL ( in_COMMIT_EVENT_CONTEXT_ID            ,_param->_size_context_id);
        DELETE_SIGNAL ( in_COMMIT_EVENT_DEPTH                 ,_param->_size_depth);
        DELETE_SIGNAL ( in_COMMIT_EVENT_TYPE                  ,_param->_size_event_type);
        DELETE_SIGNAL ( in_COMMIT_EVENT_IS_DELAY_SLOT         ,1);
        DELETE_SIGNAL ( in_COMMIT_EVENT_ADDRESS               ,_param->_size_instruction_address);
        DELETE_SIGNAL ( in_COMMIT_EVENT_ADDRESS_EPCR          ,_param->_size_instruction_address);
	DELETE_SIGNAL ( in_COMMIT_EVENT_ADDRESS_EEAR_VAL      ,_param->_size_instruction_address);
	DELETE_SIGNAL ( in_COMMIT_EVENT_ADDRESS_EEAR          ,1);

	DELETE1_SIGNAL( in_BRANCH_COMPLETE_VAL                ,_param->_nb_inst_branch_complete,1);
	DELETE1_SIGNAL(out_BRANCH_COMPLETE_ACK                ,_param->_nb_inst_branch_complete,1);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_CONTEXT_ID         ,_param->_nb_inst_branch_complete,_param->_size_context_id);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_DEPTH              ,_param->_nb_inst_branch_complete,_param->_size_depth);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_MISS_PREDICTION    ,_param->_nb_inst_branch_complete,1);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_TAKE               ,_param->_nb_inst_branch_complete,1);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_ADDRESS_SRC        ,_param->_nb_inst_branch_complete,_param->_size_instruction_address);
	DELETE1_SIGNAL( in_BRANCH_COMPLETE_ADDRESS_DEST       ,_param->_nb_inst_branch_complete,_param->_size_instruction_address);
        
	DELETE1_SIGNAL( in_NB_INST_DECOD_ALL                  ,_param->_nb_context,_param->_size_nb_inst_decod);
        DELETE1_SIGNAL( in_NB_INST_COMMIT_ALL                 ,_param->_nb_context,_param->_size_nb_inst_commit);
        DELETE1_SIGNAL( in_NB_INST_COMMIT_MEM                 ,_param->_nb_context,_param->_size_nb_inst_commit);
        
	DELETE1_SIGNAL(out_EVENT_VAL                          ,_param->_nb_context,1);
        DELETE1_SIGNAL( in_EVENT_ACK                          ,_param->_nb_context,1);
        DELETE1_SIGNAL(out_EVENT_ADDRESS                      ,_param->_nb_context,_param->_size_instruction_address);
        DELETE1_SIGNAL(out_EVENT_ADDRESS_NEXT                 ,_param->_nb_context,_param->_size_instruction_address);
        DELETE1_SIGNAL(out_EVENT_ADDRESS_NEXT_VAL             ,_param->_nb_context,1);
        DELETE1_SIGNAL(out_EVENT_IS_DS_TAKE                   ,_param->_nb_context,1);
        DELETE1_SIGNAL(out_EVENT_TYPE                         ,_param->_nb_context,_param->_size_event_type);
        DELETE1_SIGNAL(out_EVENT_DEPTH                        ,_param->_nb_context,_param->_size_depth);

	DELETE1_SIGNAL(out_SPR_EVENT_VAL                      ,_param->_nb_context,1);
        DELETE1_SIGNAL( in_SPR_EVENT_ACK                      ,_param->_nb_context,1);
        DELETE1_SIGNAL(out_SPR_EVENT_EPCR                     ,_param->_nb_context,_param->_size_instruction_address);
        DELETE1_SIGNAL(out_SPR_EVENT_EEAR                     ,_param->_nb_context,_param->_size_instruction_address);
        DELETE1_SIGNAL(out_SPR_EVENT_EEAR_WEN                 ,_param->_nb_context,1);
	DELETE1_SIGNAL(out_SPR_EVENT_SR_DSX                   ,_param->_nb_context,1);
	DELETE1_SIGNAL(out_SPR_EVENT_SR_TO_ESR                ,_param->_nb_context,1);
        
	DELETE1_SIGNAL(out_CONTEXT_DECOD_ENABLE               ,_param->_nb_context,1);

	DELETE1_SIGNAL( in_DEPTH_MIN                          ,_param->_nb_context,_param->_size_depth);

        DELETE1_SIGNAL( in_SPR_SR_IEE                         ,_param->_nb_context,1);
        DELETE1_SIGNAL( in_SPR_SR_EPH                         ,_param->_nb_context,1);

        DELETE1_SIGNAL( in_INTERRUPT_ENABLE                   ,_param->_nb_context,1);

        // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
        delete [] reg_STATE                 ;
        delete [] reg_EVENT_ADDRESS         ;
        delete [] reg_EVENT_ADDRESS_EPCR    ; 
        delete [] reg_EVENT_ADDRESS_EPCR_VAL;
        delete [] reg_EVENT_ADDRESS_EEAR    ; 
        delete [] reg_EVENT_ADDRESS_EEAR_VAL;
        delete [] reg_EVENT_IS_DELAY_SLOT   ;
        delete [] reg_EVENT_IS_DS_TAKE      ;
        delete [] reg_EVENT_DEPTH           ;
        delete [] reg_INTERRUPT_ENABLE      ;
        
        // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        delete [] internal_BRANCH_EVENT_ACK ;
        delete [] internal_DECOD_EVENT_ACK  ;
        delete [] internal_EVENT_VAL        ;
        delete [] internal_SPR_EVENT_VAL    ;
      }
        
    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    

    delete _component;

    log_end(Context_State,FUNCTION);
  };

}; // end namespace context_state
}; // end namespace front_end
}; // end namespace multi_front_end
}; // end namespace core

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