#ifdef SYSTEMC
/*
 * $Id$
 *
 * [ Description ]
 * 
 */

#include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h"

namespace morpheo                    {
namespace behavioural {
namespace stage_1_ifetch {
namespace predictor {
namespace meta_predictor {
namespace meta_predictor_glue {


  void Meta_Predictor_Glue::deallocation (void)
  {
    log_printf(FUNC,Meta_Predictor_Glue,"deallocation","Begin");

#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
    delete in_CLOCK;
#endif

    // Interface Predict
    for (uint32_t i=0; i<_param._nb_prediction; i++)
      {
	if (_param._have_meta_predictor)
	{
	delete  in_PREDICT_PREDICTOR_0_ACK                   [i];
	delete  in_PREDICT_PREDICTOR_1_ACK                   [i];
	}
	delete  in_PREDICT_PREDICTOR_2_ACK                   [i];
	delete out_PREDICT_ACK                               [i];
	if (_param._have_meta_predictor)
	{
	if (_param._predictor_0_have_bht)
	delete  in_PREDICT_PREDICTOR_0_BHT_HISTORY           [i];
	if (_param._predictor_0_have_pht)
	delete  in_PREDICT_PREDICTOR_0_PHT_HISTORY           [i];
	if (_param._predictor_1_have_bht)
	delete  in_PREDICT_PREDICTOR_1_BHT_HISTORY           [i];
	if (_param._predictor_1_have_pht)
	delete  in_PREDICT_PREDICTOR_1_PHT_HISTORY           [i];
	}
	if (_param._predictor_2_have_bht)
	delete  in_PREDICT_PREDICTOR_2_BHT_HISTORY           [i];
	if (_param._predictor_2_have_pht)
	delete  in_PREDICT_PREDICTOR_2_PHT_HISTORY           [i];
	delete out_PREDICT_HISTORY                           [i];
	delete out_PREDICT_DIRECTION                         [i];
      }

    if (_param._have_meta_predictor)
    {
    delete  in_PREDICT_PREDICTOR_0_ACK;
    delete  in_PREDICT_PREDICTOR_1_ACK;
    }			           
    delete  in_PREDICT_PREDICTOR_2_ACK;
    delete out_PREDICT_ACK            ;
    if (_param._have_meta_predictor)
    {
    if (_param._predictor_0_have_bht)
    delete  in_PREDICT_PREDICTOR_0_BHT_HISTORY;
    if (_param._predictor_0_have_pht)
    delete  in_PREDICT_PREDICTOR_0_PHT_HISTORY;
    if (_param._predictor_1_have_bht)
    delete  in_PREDICT_PREDICTOR_1_BHT_HISTORY;
    if (_param._predictor_1_have_pht)
    delete  in_PREDICT_PREDICTOR_1_PHT_HISTORY ;
    }
    if (_param._predictor_2_have_bht)
    delete  in_PREDICT_PREDICTOR_2_BHT_HISTORY ;
    if (_param._predictor_2_have_pht)
    delete  in_PREDICT_PREDICTOR_2_PHT_HISTORY ;
    delete out_PREDICT_HISTORY                 ;
    delete out_PREDICT_DIRECTION               ;

    // Interface Branch_complete
    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
      {
	if (_param._have_meta_predictor)
	{
	delete  in_BRANCH_COMPLETE_VAL                               [i];
	delete out_BRANCH_COMPLETE_PREDICTOR_2_VAL                   [i];

	delete  in_BRANCH_COMPLETE_PREDICTOR_0_ACK                   [i];
	delete  in_BRANCH_COMPLETE_PREDICTOR_1_ACK                   [i];
	}
	delete  in_BRANCH_COMPLETE_PREDICTOR_2_ACK                   [i];
	delete out_BRANCH_COMPLETE_ACK                               [i];
 
	if (_param._have_meta_predictor)
	{
	if (_param._predictor_0_have_bht)
	delete out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY           [i];
	if (_param._predictor_0_have_pht)
	delete out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY           [i];
	if (_param._predictor_1_have_bht)
	delete out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY           [i];
	if (_param._predictor_1_have_pht)
	delete out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY           [i];
	}
	if (_param._predictor_2_have_bht)
	delete out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY           [i];
	if (_param._predictor_2_have_pht)
	delete out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY           [i];
	delete  in_BRANCH_COMPLETE_HISTORY                           [i];
	if (_param._have_meta_predictor)
	  {
	delete  in_BRANCH_COMPLETE_DIRECTION                         [i];
	delete out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION             [i];
	  }
      }

    if (_param._have_meta_predictor)
    {
    delete  in_BRANCH_COMPLETE_VAL                     ;
    delete out_BRANCH_COMPLETE_PREDICTOR_2_VAL         ;

    delete  in_BRANCH_COMPLETE_PREDICTOR_0_ACK         ;
    delete  in_BRANCH_COMPLETE_PREDICTOR_1_ACK         ;
    }			           
    delete  in_BRANCH_COMPLETE_PREDICTOR_2_ACK         ;
    delete out_BRANCH_COMPLETE_ACK                     ;
    if (_param._have_meta_predictor)
    {
    if (_param._predictor_0_have_bht)
    delete out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY ;
    if (_param._predictor_0_have_pht)
    delete out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY ;
    if (_param._predictor_1_have_bht)
    delete out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY ;
    if (_param._predictor_1_have_pht)
    delete out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY ;
    }
    if (_param._predictor_2_have_bht)
    delete out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY ;
    if (_param._predictor_2_have_pht)
    delete out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY ;
    delete  in_BRANCH_COMPLETE_HISTORY                 ;
    if (_param._have_meta_predictor)
      {
    delete  in_BRANCH_COMPLETE_DIRECTION               ;
    delete out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   ;
      }
    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    

    log_printf(FUNC,Meta_Predictor_Glue,"deallocation","End");
  };

}; // end namespace meta_predictor_glue
}; // end namespace meta_predictor
}; // end namespace predictor
}; // end namespace stage_1_ifetch

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