--------------------------------------------------------------------------------
-- Company:
--
-- File: Fourinput_42bitAdder_TestBench.vhd
--
-- File history:
--
-- Description	  : Provides stimuls vectors to the Fourinput_42bit_Adder
--				
-- Targeted device: Family		:: SmartFusion2  
-- 					  Die		:: M2S050T
--					  Package	:: 896 FBGA
--		Author	  : PHANIKIRAN T
--------------------------------------------------------------------------------


LIBRARY IEEE;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;

ENTITY Adder_Sub_88bit_TestBench IS
END Adder_Sub_88bit_TestBench;

ARCHITECTURE behavioral OF Adder_Sub_88bit_TestBench IS



COMPONENT Adder_Sub_88bit IS
PORT (
    CLK 		: IN STD_LOGIC;
    RSTN 		: IN STD_LOGIC;

-- inputs
	INP_A 		: IN STD_LOGIC_VECTOR(17 DOWNTO 0);
	INP_B 		: IN STD_LOGIC_VECTOR(17 DOWNTO 0);
	INP_88b		: IN STD_LOGIC_VECTOR(87 DOWNTO 0);

	INP_D 		: IN STD_LOGIC_VECTOR(17 DOWNTO 0);
	INP_E 		: IN STD_LOGIC_VECTOR(17 DOWNTO 0);

-- Output

   	RESULT	 	: OUT STD_LOGIC_VECTOR(87 DOWNTO 0)
	
	);
END COMPONENT Adder_Sub_88bit;

CONSTANT clk_period : time := 10 ns;

SIGNAL clk			: STD_LOGIC:= '0';
SIGNAL reset_n		: STD_LOGIC:= '0';
SIGNAL  INP_A 		: STD_LOGIC_VECTOR(17 DOWNTO 0):=(OTHERS=> '0');
SIGNAL	INP_B 		: STD_LOGIC_VECTOR(17 DOWNTO 0):=(OTHERS=> '0');
SIGNAL	INP_88b		: STD_LOGIC_VECTOR(87 DOWNTO 0):=(OTHERS=> '0');
SIGNAL	INP_D 		: STD_LOGIC_VECTOR(17 DOWNTO 0):=(OTHERS=> '0');
SIGNAL	INP_E 		: STD_LOGIC_VECTOR(17 DOWNTO 0):=(OTHERS=> '0');

SIGNAL RESULT		: STD_LOGIC_VECTOR(87 DOWNTO 0);
SIGNAL OVERFLOW_O	: STD_LOGIC;

SIGNAL stop 		: STD_LOGIC := '0';	


BEGIN


UUT: Adder_Sub_88bit
		port map(	

				CLK 	=> CLK,
				RSTN 	=> reset_n,
				-- inputs
				INP_A		=> INP_A,	
				INP_B 		=> INP_B,
				INP_88b 	=> INP_88b,
				INP_D 		=> INP_D,
				INP_E 		=> INP_E,

				-- Output
			   	RESULT	 	=> RESULT

         		);

--- Clock and Reset Generation 

 clk_proc : PROCESS
   			BEGIN
				IF(stop = '0')THEN
					clk <= '0';
    			    WAIT FOR clk_period/2;
					clk <= '1';
					WAIT FOR clk_period/2;
				ELSE
					clk <= '0';
				END IF;
			END PROCESS;

 stim_proc: PROCESS
			BEGIN
				reset_n <='0';
					WAIT FOR 20 ns;
				reset_n	<='1';
					WAIT;
			END PROCESS;


PROCESS
BEGIN
		WAIT UNTIL(reset_n ='1');
		WAIT UNTIL rising_edge(clk);
	INP_A	<= "011111111111111111";--1FFFF
	INP_B	<= "011111111111111111";--1FFFF
	INP_88b	<= x"0000000FEDCBA987654321";--FEDCBA987654321
	INP_D	<= "000000000000000000";
	INP_E	<= "000000000000000000";

	WAIT UNTIL rising_edge(clk);
	--WAIT UNTIL rising_edge(clk);
	INP_A	<= "011100110011001101";--1CCCD
	INP_B	<= "010101011001100111";--15667
	INP_88b	<= x"0000000EEDCBA987654321";--EEDCBA987654321
	INP_D	<= "000000000000000000";--0
	INP_E	<= "000000000000000000";--0

		WAIT UNTIL rising_edge(clk);

		WAIT UNTIL rising_edge(clk);
		WAIT FOR 500 ns;
		WAIT UNTIL rising_edge(clk);
			stop <=  '1';
		
		report "TEST FINISHED!"
		severity failure;
		--wait;
END PROCESS;

end behavioral;

