/*****************************************************************************
 *
 * 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
 *
 ****************************************************************************/

#include <string>
#include <systemc.h>

SC_MODULE(InputSHA1Module){

	sc_fifo_out<std::string> val;

	sc_fifo_in<std::string> out;
	sc_fifo_in<sc_biguint<160> > out_int;

	void input_test(std::string str_val){
		std::cout << "[" << sc_time_stamp() << "]" << "[Input]:" << "Write val: " << str_val << std::endl;
		val->write(str_val);
		std::cout << "[" << sc_time_stamp() << "]" << "[Input]:" << "Wait for hash value..." << std::endl;
		std::string hash = out->read();

		sc_biguint<160> num_hash = out_int->read();
		//sc_string num_hash_hex("0x" + num_hash);

		std::cout << "[" << sc_time_stamp() << "]" << "[Input]:" << "Generated hash: " << hash << std::endl;
		std::cout << "[" << sc_time_stamp() << "]" << "[Input]:" << "Generated int hash (hex): " << num_hash.to_string(SC_HEX) << std::endl;
	}

	void exe(){

		input_test("Test");
		input_test("AA");

	}

	SC_CTOR(InputSHA1Module){
		SC_THREAD(exe);
	}

};
