/*
 * 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 SC_ARBITER_H
#define SC_ARBITER_H

#include <systemc>
#include "my_interfaces.h"

SC_MODULE(ScArbiter)
{
protected:
  SC_HAS_PROCESS(ScArbiter);

public:
  sc_in<bool> p_clk;
  sc_in<bool> p_resetn;

  SECURITY_RQ_OUT sc_ctrl;
  SECURITY_RQ_IN  *sc_rq;

  ScArbiter(sc_module_name, size_t nrq);
  ~ScArbiter();

private:
  void transition();
  void genMealy_cmdack();
  void genMealy_cmdval();
  void genMealy_rsp();

  enum fsm_state_e
  {
    FSM_IDLE,
    FSM_CMD,
    FSM_RSP
  };

  size_t m_nrq;

  sc_signal<unsigned int> selected_src_s;
  sc_signal<int> fsm_s;
};

#endif
