/*****************************************************************************
 *
 * Copyright (c) 2018-19, Eduard Gerlits, Paula Herber, Josef Treus
 * Westfälische Wilhelms-Universität Münster, AG Embedded Systems 
 * All rights reserved.
 *
 * This file is part of SysCSec
 *
 * SysCSec is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * SysCSec is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SysCSec.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 *  Please report any problems or bugs to: sysc.sec@uni-muenster.de
 *
 ****************************************************************************/

#ifndef _IO_H_
#define _IO_H_

#include <iostream>
#include <systemc.h>
#include "commons.h"

/*
This module provides methods to pack 160 bit data into 960 bit data packet and to unpack it again. 
*/

SC_MODULE(IOModule){

	private:
	sc_biguint<960> p_data;

	public:

	/// in

	// port of the selected operation
	sc_fifo_in<sc_uint<3> > io_control_in;

	// data port 
	sc_fifo_in<sc_biguint<160> > data_in;

	// data packet port 
	sc_fifo_in<sc_biguint<960> > p_data_in;

	/// out
	
	// status port 
	sc_fifo_out<sc_uint<3> > io_status;
	sc_fifo_out<sc_biguint<160> > data_out;
	sc_fifo_out<sc_biguint<960> > p_data_out;  

	void exe();

	void set_data(sc_biguint<960> data, sc_biguint<960> &target);
	void get_data(sc_biguint<960> &data);
	void pack_data(sc_biguint<160> data, sc_biguint<960> &target);
	void unpack_data(sc_biguint<160> &data, sc_biguint<960> &source);
	

	SC_CTOR(IOModule){
		
		SC_THREAD(exe);
	}

};

#endif
