#ifndef MY_INTERFACES__H_
#define MY_INTERFACES__H_

#include "systemc.h"
#include "types.h"


/* Informations fetch signals */
struct CACHE_CONTROLLER_CMD_SIGNALS
{
public:
	sc_signal<addr_t>	address;
	sc_signal<bool>	enable;
	sc_signal<cmd_e> cmd;

};

/* cache controller command */
struct CACHE_CONTROLLER_CMD_IN
{

public:
	sc_in<addr_t>	address;
	sc_in<bool>		enable;
	sc_in<cmd_e>	cmd;

	void operator () (CACHE_CONTROLLER_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
	};
};

/* cache controller command */
struct CACHE_CONTROLLER_CMD_OUT
{

public:
	sc_out<addr_t> address;
	sc_out<bool> enable;
	sc_out<cmd_e>	cmd;

	void operator () (CACHE_CONTROLLER_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
	};
};


/* Informations fetch signals */
struct CACHE_CONTROLLER_ACK_SIGNALS
{
public:

	sc_signal<bool>		rack;
	sc_signal<bool>		wack;
	sc_signal<bool>		sack;
	sc_signal<bool>		rstack;
	sc_signal<bool>		full;
	sc_signal<bool>		hit;
	sc_signal<bool>		dirty;
	sc_signal<addr_t>	victim_address;
};

/* cache controller command */
struct CACHE_CONTROLLER_ACK_OUT
{

public:

	sc_out<bool>	rack;
	sc_out<bool>	wack;
	sc_out<bool>	sack;
	sc_out<bool>	rstack;
	sc_out<bool>	full;
	sc_out<bool>	hit;
	sc_out<bool>	dirty;
	sc_out<addr_t>	victim_address;


	void operator () (CACHE_CONTROLLER_ACK_SIGNALS & sig)
	{
		rack (sig.rack);
		wack (sig.wack);
		sack (sig.sack);
		rstack (sig.rstack);
		full(sig.full);
		hit (sig.hit);
		dirty (sig.dirty);
		victim_address (sig.victim_address);
	};
};

/* cache controller command */
struct CACHE_CONTROLLER_ACK_IN
{

public:

	sc_in<bool>		rack;
	sc_in<bool>		wack;
	sc_in<bool>		sack;
	sc_in<bool>		rstack;
	sc_in<bool>		full;
	sc_in<bool>		hit;
	sc_in<bool>		dirty;
	sc_in<addr_t>	victim_address;


	void operator () (CACHE_CONTROLLER_ACK_SIGNALS & sig)
	{
		rack (sig.rack);
		wack (sig.wack);
		sack (sig.sack);
		rstack (sig.rstack);
		full(sig.full);
		hit (sig.hit);
		dirty (sig.dirty);
		victim_address (sig.victim_address);
	};
};

struct SECURITY_CONTEXT_CMD_SIGNALS
{
public:
	sc_signal<addr_t>		address;
	sc_signal<bool>			enable;
	sc_signal<sec_cmd_e>		cmd;
	sc_signal<initiator_e>	initiator;

};
/* cache controller command */
struct SECURITY_CONTEXT_CMD_IN
{

public:
	sc_in<addr_t>		address;
	sc_in<bool>			enable;
	sc_in<sec_cmd_e>		cmd;
	sc_in<initiator_e>	initiator;


	void operator () (SECURITY_CONTEXT_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
		initiator (sig.initiator); 
	};
};
/* cache controller command */
struct SECURITY_CONTEXT_CMD_OUT
{

public:
	sc_out<addr_t>		address;
	sc_out<bool>		enable;
	sc_out<sec_cmd_e>		cmd;
	sc_out<initiator_e> initiator;


	void operator () (SECURITY_CONTEXT_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
		initiator (sig.initiator); 
	};
};

struct ACK_SIGNALS
{
public:
	sc_signal<bool> rack;
	sc_signal<bool> wack;
};

struct ACK_IN
{

public:
	sc_in<bool> rack;
	sc_in<bool> wack;

	void operator () (ACK_SIGNALS & sig)
	{
		rack (sig.rack);
		wack (sig.wack);

	};
};
struct ACK_OUT
{

public:
	sc_out<bool> rack;
	sc_out<bool> wack;

	void operator () (ACK_SIGNALS & sig)
	{
		rack (sig.rack);
		wack (sig.wack);

	};
};

struct INTEGRITY_CONTROLLER_CMD_SIGNALS
{
public:
	sc_signal<addr_t>			address;
	sc_signal<bool>				enable;
	sc_signal<integrity_cmd_e>	cmd;
};

struct INTEGRITY_CONTROLLER_CMD_IN
{

public:
	sc_in<addr_t>			address;
	sc_in<bool>				enable;
	sc_in<integrity_cmd_e>	cmd;

	void operator () (INTEGRITY_CONTROLLER_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
	};
};

struct INTEGRITY_CONTROLLER_CMD_OUT
{

public:
	sc_out<addr_t>			address;
	sc_out<bool>			enable;
	sc_out<integrity_cmd_e> cmd;
	
	void operator () (INTEGRITY_CONTROLLER_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		cmd (sig.cmd);
	};
};
struct INTEGRITY_CONTROLLER_ACK_SIGNALS
{
public:
	sc_signal<bool>				cack;
	sc_signal<bool>				uack;
	sc_signal<bool>				alap_ack;
	sc_signal<bool>				initialize_ack;
  sc_signal<bool>       init_mbht_ack;

};

struct INTEGRITY_CONTROLLER_ACK_OUT
{

public:
	sc_out<bool>			cack;
	sc_out<bool>			uack;
	sc_out<bool>			alap_ack;
	sc_out<bool>			initialize_ack;
  sc_out<bool>      init_mbht_ack;

	void operator () (INTEGRITY_CONTROLLER_ACK_SIGNALS & sig)
	{
		uack (sig.uack);
		cack (sig.cack);
		alap_ack(sig.alap_ack);
		initialize_ack (sig.initialize_ack);
    init_mbht_ack (sig.init_mbht_ack);
	};
};

struct INTEGRITY_CONTROLLER_ACK_IN
{

public:

	sc_in<bool>				cack;
	sc_in<bool>				uack;
	sc_in<bool>				alap_ack;
	sc_in<bool>			  initialize_ack;
  sc_in<bool>       init_mbht_ack;

	void operator () (INTEGRITY_CONTROLLER_ACK_SIGNALS & sig)
	{
		cack (sig.cack);
		uack (sig.uack);
		alap_ack(sig.alap_ack);
		initialize_ack (sig.initialize_ack);
    init_mbht_ack (sig.init_mbht_ack);
	};
};



struct SECURITY_CONTROLLER_SIGNALS
{
public:
	sc_signal<addr_t>		address;
	sc_signal<addr_t>		end_address;
	sc_signal<bool>			enable;
	sc_signal<cmd_e>		cmd;
	sc_signal<bool>			rack;
	sc_signal<bool>			wack;

};

struct SECURITY_CONTROLLER_IN
{

public:
	sc_in<addr_t>		address;
	sc_in<addr_t>		end_address;
	sc_in<bool>			enable;
	sc_in<cmd_e>		cmd;
	sc_out<bool>		rack;
	sc_out<bool>		wack;


	void operator () (SECURITY_CONTROLLER_SIGNALS & sig)
	{
		address (sig.address);
		end_address (sig.end_address);
		enable(sig.enable);
		cmd (sig.cmd);
		rack (sig.rack);
		wack (sig.wack);
	};
};

struct SECURITY_CONTROLLER_OUT
{

public:
	sc_out<addr_t> address;
	sc_out<addr_t> end_address;
	sc_out<bool> enable;
	sc_out<cmd_e> cmd;
	sc_in<bool> rack;
	sc_in<bool> wack;


	void operator () (SECURITY_CONTROLLER_SIGNALS & sig)
	{
		address (sig.address);
		end_address (sig.end_address);
		enable(sig.enable);
		cmd (sig.cmd);
		rack (sig.rack);
		wack (sig.wack);
	};
};

struct MEMORY_CONTROLLER_CMD_SIGNALS
{
public:
	sc_signal<addr_t>		start_address;
	sc_signal<bool>			enable;
	sc_signal<unsigned int> plen;
	sc_signal<cmd_e>		cmd;
	sc_signal<unsigned int>	id;
};

struct MEMORY_CONTROLLER_CMD_IN
{

public:
	sc_in<addr_t>			start_address;
	sc_in<bool>				enable;
	sc_in<unsigned int>		plen;
	sc_in<cmd_e>			cmd;
	sc_in<unsigned int>		id;

	void operator () (MEMORY_CONTROLLER_CMD_SIGNALS & sig)
	{
		start_address (sig.start_address);
		enable(sig.enable);
		cmd (sig.cmd);
		plen (sig.plen);
		id(sig.id);
	};
};

struct MEMORY_CONTROLLER_CMD_OUT
{

public:
	sc_out<addr_t>			start_address;
	sc_out<bool>			enable;
	sc_out<unsigned int>	plen;
	sc_out<cmd_e>			cmd;
	sc_out<unsigned int>	id;


	void operator () (MEMORY_CONTROLLER_CMD_SIGNALS & sig)
	{
		start_address (sig.start_address);
		enable(sig.enable);
		cmd (sig.cmd);
		plen (sig.plen); 
		id(sig.id);
	};
};

template<int size_in_word>
struct DATA_SIGNALS
{
public:
	sc_signal<int> data[size_in_word];
};

template<int size_in_word>
struct DATA_IN
{

public:
	sc_in<int>		data[size_in_word];

	void operator () (DATA_SIGNALS<size_in_word> & sig)
	{
		for(int i=0;i<size_in_word;i++)
			data[i] (sig.data[i]);
	};
};

template<int size_in_word>
struct DATA_OUT
{

public:
	sc_out<int>		data[size_in_word];

	void operator () (DATA_SIGNALS<size_in_word> & sig)
	{
		for(int i=0;i<size_in_word;i++)
			data[i] (sig.data[i]);
	};
};


struct SECURITY_CONTEXT_REGISTER_READ_SIGNALS
{
public:

	sc_signal<addr_t> page_address;
	sc_signal<addr_t> spspe_address;
	sc_signal<addr_t> sp_address;
	sc_signal<int*> spspe;
	sc_signal<int*> mpspe;
	sc_signal<int*> sp;
	sc_signal<addr_t> alap_page_address;
	sc_signal<addr_t> alap_spspe_address;
	sc_signal<int*> alap_spspe;
};



struct SECURITY_CONTEXT_REGISTER_READ_OUT
{
public:

	sc_in<addr_t> page_address;
	sc_in<addr_t> spspe_address;
	sc_in<addr_t> sp_address;
	sc_in<int*> spspe;
	sc_in<int*> mpspe;
	sc_in<int*> sp;
	sc_in<addr_t> alap_page_address;
	sc_in<addr_t> alap_spspe_address;
	sc_in<int*> alap_spspe;

	void operator () (SECURITY_CONTEXT_REGISTER_READ_SIGNALS & sig)
	{
		page_address (sig.page_address);
		spspe_address (sig.spspe_address);
		sp_address (sig.sp_address);
		mpspe (sig.mpspe);
		spspe (sig.spspe);
		sp (sig.sp);
		alap_page_address (sig.alap_page_address);
		alap_spspe_address (sig.alap_spspe_address);
		alap_spspe (sig.alap_spspe);
	};
};

struct SECURITY_CONTEXT_REGISTER_READ_IN
{
public:

	sc_out<addr_t> page_address;
	sc_out<addr_t> spspe_address;
	sc_out<addr_t> sp_address;
	sc_out<int*> spspe;
	sc_out<int*> mpspe;
	sc_out<int*> sp;
	sc_out<addr_t> alap_page_address;
	sc_out<addr_t> alap_spspe_address;
	sc_out<int*> alap_spspe;

	void operator () (SECURITY_CONTEXT_REGISTER_READ_SIGNALS & sig)
	{
		page_address (sig.page_address);
		spspe_address (sig.spspe_address);
		sp_address (sig.sp_address);
		mpspe (sig.mpspe);
		spspe (sig.spspe);
		sp (sig.sp);
		alap_page_address (sig.alap_page_address);
		alap_spspe_address (sig.alap_spspe_address);
		alap_spspe (sig.alap_spspe);
	};
};

struct SECURITY_CONTEXT_REGISTER_WRITE_SIGNALS
{
public:

	sc_signal<addr_t> page_address;
	sc_signal<addr_t> spspe_address;
	sc_signal<addr_t> sp_address;
	sc_signal<bool> enable;
	sc_signal<unsigned int> sel;
	sc_signal<int> spspe[2];
	sc_signal<int> mpspe[2];
	sc_signal<int> sp[4];

};


struct SECURITY_CONTEXT_REGISTER_WRITE_OUT
{
public:

	sc_out<addr_t> page_address;
	sc_out<addr_t> spspe_address;
	sc_out<addr_t> sp_address;
	sc_out<bool> enable;
	sc_out<unsigned int> sel;
	sc_out<int> spspe[2];
	sc_out<int> mpspe[2];
	sc_out<int> sp[4];


	void operator () (SECURITY_CONTEXT_REGISTER_WRITE_SIGNALS & sig)
	{
		page_address (sig.page_address);
		spspe_address (sig.spspe_address);
		sp_address (sig.sp_address);
		enable(sig.enable);
		sel(sig.sel);
		for (int i=0;i<8;i++)
    {
		  mpspe[i] (sig.mpspe[i]);
		  spspe[i] (sig.spspe[i]);
    }
		for (int i=0;i<4;i++)
			sp[i] (sig.sp[i]);
	};
};

struct SECURITY_CONTEXT_REGISTER_WRITE_IN
{
public:

	sc_in<addr_t> page_address;
	sc_in<addr_t> spspe_address;
	sc_in<addr_t> sp_address;
	sc_in<bool> enable;
	sc_in<unsigned int> sel;
	sc_in<int> spspe[2];
	sc_in<int> mpspe[2];
	sc_in<int> sp[4];


	void operator () (SECURITY_CONTEXT_REGISTER_WRITE_SIGNALS & sig)
	{
		page_address (sig.page_address);
		spspe_address (sig.spspe_address);
		sp_address (sig.sp_address);
		enable(sig.enable);
		sel(sig.sel);
		for (int i=0;i<8;i++)
    {
		  mpspe[i] (sig.mpspe[i]);
		  spspe[i] (sig.spspe[i]);
    }
		for (int i=0;i<4;i++)
			sp[i] (sig.sp[i]);
	};
};

struct DATA_REGISTER_READ_SIGNALS
{
public:

	sc_signal<int>				data[8];
	sc_signal<unsigned int>		be;
	sc_signal<addr_t>			address;
};



struct DATA_REGISTER_READ_IN
{
public:

	sc_in<addr_t>			address;
	sc_in<int>				data[8];
	sc_in<unsigned int>		be;


	void operator () (DATA_REGISTER_READ_SIGNALS & sig)
	{
		be(sig.be);
		address (sig.address);
		for (int i=0;i<8;i++)
			data[i] (sig.data[i]);
	};
};

struct DATA_REGISTER_READ_OUT
{
public:

	sc_out<addr_t>			address;
	sc_out<int>				data[8];
	sc_out<unsigned int>	be;

	void operator () (DATA_REGISTER_READ_SIGNALS & sig)
	{
		be(sig.be);
		address (sig.address);
		for (int i=0;i<8;i++)
			data[i] (sig.data[i]);
	};
};

struct DATA_REGISTER_WRITE_SIGNALS
{
public:

	sc_signal<addr_t>		address;
	sc_signal<bool>			enable;
	sc_signal<bool>			flush;
	sc_signal<int>			data[8];
	sc_signal<unsigned int>	be;

};

struct DATA_REGISTER_WRITE_OUT
{
public:

	sc_out<addr_t>			address;
	sc_out<int>				data[8];
	sc_out<unsigned int>	be;
	sc_out<bool>			enable;
	sc_out<bool>			flush;

	void operator () (DATA_REGISTER_WRITE_SIGNALS & sig)
	{
		address (sig.address);
		for (int i=0;i<8;i++)
			data[i] (sig.data[i]);
		enable(sig.enable);
		flush(sig.flush);
		be (sig.be);
	};
};

struct DATA_REGISTER_WRITE_IN
{
public:

	sc_in<addr_t>		address;
	sc_in<int>			data[8];
	sc_in<unsigned int>	be;
	sc_in<bool>			enable;
	sc_in<bool>			flush;

	void operator () (DATA_REGISTER_WRITE_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		flush(sig.flush);
		for (int i=0;i<8;i++)
			data[i] (sig.data[i]);
		be (sig.be);
	};
};

struct CRYPTOGRAPHIC_ENGINE_CMD_SIGNALS
{
public:
	sc_signal<addr_t>			address;
	sc_signal<bool>				enable;
	sc_signal<bool>				stage_0;
	sc_signal<int*>				key;
	sc_signal<unsigned int>		size;
	sc_signal<unsigned int>		index;
	sc_signal<confidentiality_mode_e>	cmode;
	sc_signal<integrity_mode_e>	imode;

};


struct CRYPTOGRAPHIC_ENGINE_CMD_IN
{

public:

	sc_in<addr_t>			address;
	sc_in<bool>				enable;
	sc_in<bool>				stage_0;
	sc_in<int*>				key;
	sc_in<unsigned int>		size;
	sc_in<unsigned int>		index;
	sc_in<confidentiality_mode_e>	cmode;
	sc_in<integrity_mode_e>	imode;

	void operator () (CRYPTOGRAPHIC_ENGINE_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		stage_0(sig.stage_0);
		key (sig.key);
		size (sig.size); 
		imode(sig.imode);
		cmode(sig.cmode);
		index(sig.index);
	};
};

struct CRYPTOGRAPHIC_ENGINE_CMD_OUT
{

public:

	sc_out<addr_t>				address;
	sc_out<bool>				enable;
	sc_out<bool>				stage_0;
	sc_out<int*>				key;
	sc_out<unsigned int>		size;
	sc_out<unsigned int>		index;
	sc_out<confidentiality_mode_e>		cmode;
	sc_out<integrity_mode_e>	imode;

	void operator () (CRYPTOGRAPHIC_ENGINE_CMD_SIGNALS & sig)
	{
		address (sig.address);
		enable(sig.enable);
		stage_0(sig.stage_0);
		key (sig.key);
		size (sig.size); 
		imode(sig.imode);
		cmode(sig.cmode);
		index(sig.index);
	};
};


#endif

