/*
 * SecBus - This file is part of SecBus
 * Copyright (C) 2012 - Telecom ParisTech
 * 
 * This file must be used under the terms of the CeCILL.
 * This source file is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at    
 * http://www.cecill.info/licences/Licence_CeCILL_V1.1-US.txt
 *
 */

#ifndef _GEN_MUX_H
#define _GEN_MUX_H

#include <systemc>

#include "my_interfaces.h"

/**
 * Generic version of multiplexor 
 * 
 * An input is plugged to the ouput only if its signal enable
 * is up. The input signals must implement the operator << with
 * sc_sensitive destination. The output signal must implement the
 * operator () with input signal as source.
 * 
 * Example :
 * sc_core::sc_sensitive& operator <<(
 *               sc_core::sc_sensitive &ss,
 *               DATA_REGISTER_WRITE_IN &sig )
 * {
 * ...
 * }
 * 
 * void DATA_REGISTER_WRITE_OUT::operator () 
 *        (DATA_REGISTER_WRITE_IN &sig)
 * {
 * ...
 * }
 *
 */
template<typename in, typename out>
SC_MODULE(Mux)
{
protected:
  SC_HAS_PROCESS(Mux);

public:
  in  *input;
  out output;

  Mux(sc_module_name name, size_t ninput);
  ~Mux();

private:
  size_t m_ninput;

  void genMoore();
};

#endif
