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

#include "Behavioural/Generic/Select/Select_Priority_Fixed/include/Select_Priority_Fixed.h"

namespace morpheo{
namespace behavioural {
namespace generic {
namespace select {
namespace select_priority_fixed {

  void Select_Priority_Fixed::allocation (void)
  {
    log_printf(FUNC,Select_Priority_Fixed,"allocation","Begin");

    _component   = new Component ();

    Entity * entity = _component->set_entity (_name                 
#ifdef POSITION
					     ,"Select_Priority_Fixed"
					     ,COMBINATORY            
#endif
					      );
    
    _interfaces = entity->set_interfaces();

    // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Interface_fifo * interface = _interfaces->set_interface(""
#ifdef POSITION
							    ,IN  
							    ,WEST
							    ,"Generalist interface"
#endif
							    );

     in_CLOCK        = interface->set_signal_clk              ("clock" ,1, CLOCK_VHDL_NO);
     in_NRESET       = interface->set_signal_in  <Tcontrol_t> ("nreset",1);
     in_VAL          = new SC_IN (Tcontrol_t)           * [_param._nb_entity];
    if (_param._encoding_one_hot)
    out_ACK          = new SC_OUT(Tcontrol_t)           * [_param._nb_entity];

    for (uint32_t i=0; i<_param._nb_entity; i++)
      {
	 in_VAL [i]    = interface->set_signal_in  <Tcontrol_t> ("val_"+toString(i),1);
	if (_param._encoding_one_hot)
	out_ACK [i]    = interface->set_signal_out <Tcontrol_t> ("ack_"+toString(i),1);
      }

    if (_param._encoding_compact)
      {
	out_ENTITY     = interface->set_signal_out <Tentity_t > ("entity"    , _param._size_entity);
	out_ENTITY_ACK = interface->set_signal_out <Tcontrol_t> ("entity_ack", 1);
      }

    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    

#ifdef POSITION
    _component->generate_file();
#endif

    log_printf(FUNC,Select_Priority_Fixed,"allocation","End");
  };

}; // end namespace select_priority_fixed
}; // end namespace select
}; // end namespace generic
}; // end namespace behavioural
}; // end namespace morpheo              
#endif
