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

SC_MODULE(InputModule){

	// clock
	sc_port<sc_clock> clk;

	// in
	sc_in<sc_biguint<160> > in;
	sc_in<bool> done;

	// out
	sc_out<sc_biguint<160> > x;
	sc_out<sc_biguint<160> > y;
	sc_out<sc_biguint<160> > m;
	sc_out<bool> en;

	void input_test(sc_biguint<160> param_x, sc_biguint<160> param_y, sc_biguint<160> param_m){
		std::cout << "[" << sc_time_stamp() << "]: " << "Write x value: " << param_x << std::endl;
		x->write(param_x);
		std::cout << "[" << sc_time_stamp() << "]: " << "Write y value: " << param_y << std::endl;
		y->write(param_y);
		std::cout << "[" << sc_time_stamp() << "]: " << "Write m value: " << param_m << std::endl;
		m->write(param_m);
		std::cout << "[" << sc_time_stamp() << "]: " << "Write en value: " << true << std::endl;
		en->write(true);

		wait();

		while(done->read()==false){
			std::cout << "[" << sc_time_stamp() << "]: " << "Wert wird berechnet..." << std::endl;
			wait();
		}

		
		sc_biguint<160> val = in->read();
		std::cout << "[" << sc_time_stamp() << "]: " << "Wert von out wurde berechnet: " << val << std::endl;

		std::cout << "[" << sc_time_stamp() << "]: " << "Write en value: " << false << std::endl;
		en->write(false);

	}

	void exe(){
		wait();
		input_test(13,3,17);
		wait();
		input_test(9,3,17);
		wait();
		input_test(3,8,17);
		wait();
		input_test(4,6,17);
		wait();
		sc_stop();
	}

	SC_CTOR(InputModule){
		SC_THREAD(exe);
		sensitive << clk;
	}

};