-- C:\MATLAB6P5\WORK\ISNIAMY\XSPARTAN2
-- VHDL Test Bench created by
-- HDL Bencher 6.1i
-- Mon Aug 15 14:28:40 2005
-- 
-- Notes:
-- 1) This testbench has been automatically generated from
--   your Test Bench Waveform
-- 2) To use this as a user modifiable testbench do the following:
--   - Save it as a file with a .vhd extension (i.e. File->Save As...)
--   - Add it to your project as a testbench source (i.e. Project->Add Source...)
-- 

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
LIBRARY WORK;
USE WORK.CONV_PKG.ALL;
USE WORK.CLOCK_PKG.ALL;
USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;
library synopsys;  
use synopsys.arithmetic.all;  
use synopsys.all; 

ENTITY tv_3_tbw1 IS
END tv_3_tbw1;

ARCHITECTURE testbench_arch OF tv_3_tbw1 IS
-- If you get a compiler error on the following line,
-- from the menu do Options->Configuration select VHDL 87
FILE RESULTS: TEXT OPEN WRITE_MODE IS "results.txt";
	COMPONENT spartan2_clk_wrapper
		PORT (
			ce : In  std_logic;
			clk : In  std_logic;
			in_x_0 : In  std_logic_vector (15 DOWNTO 0);
			out_x_0 : Out  std_logic_vector (23 DOWNTO 0)
		);
	END COMPONENT;

	SIGNAL ce : std_logic;
	SIGNAL clk : std_logic;
	SIGNAL in_x_0 : std_logic_vector (15 DOWNTO 0);
	SIGNAL out_x_0 : std_logic_vector (23 DOWNTO 0);

BEGIN
	UUT : spartan2_clk_wrapper
	PORT MAP (
		ce => ce,
		clk => clk,
		in_x_0 => in_x_0,
		out_x_0 => out_x_0
	);
    PROCESS
		VARIABLE my_outp : line;
		FILE MYOUTPUT: TEXT OPEN WRITE_MODE IS "allout_3.txt";
	BEGIN
		wait on in_x_0,out_x_0;
		STD.TEXTIO.write(my_outp, string'("input= "));
		hwrite(my_outp, in_x_0);
		--IEEE.STD_LOGIC_TEXTIO.write(my_outp, in_x_0);
		STD.TEXTIO.write(my_outp, string'(" "));
		STD.TEXTIO.write(my_outp, string'("output= "));
		hwrite(my_outp, out_x_0);		
		STD.TEXTIO.writeline(myoutput, my_outp);
		END PROCESS;
	PROCESS -- clock process for clk,
	BEGIN
		CLOCK_LOOP : LOOP
		clk <= transport '0';
		WAIT FOR 10 ns;
		clk <= transport '1';
		WAIT FOR 10 ns;
		WAIT FOR 40 ns;
		clk <= transport '0';
		WAIT FOR 40 ns;
		END LOOP CLOCK_LOOP;
	END PROCESS;

	PROCESS   -- Process for clk
		VARIABLE TX_OUT : LINE;
		VARIABLE TX_ERROR : INTEGER := 0;

		PROCEDURE CHECK_out_x_0(
			next_out_x_0 : std_logic_vector (23 DOWNTO 0);
			TX_TIME : INTEGER
		) IS
			VARIABLE TX_STR : String(1 to 4096);
			VARIABLE TX_LOC : LINE;
		BEGIN
			-- If compiler error ("/=" is ambiguous) occurs in the next line of code
			-- change compiler settings to use explicit declarations only
			IF (out_x_0 /= next_out_x_0) THEN 
				STD.TEXTIO.write(TX_LOC,string'("Error at time="));
				STD.TEXTIO.write(TX_LOC, TX_TIME);
				STD.TEXTIO.write(TX_LOC,string'("ns out_x_0="));
				IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, out_x_0);
				STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
				IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_out_x_0);
				STD.TEXTIO.write(TX_LOC, string'(" "));
				TX_STR(TX_LOC.all'range) := TX_LOC.all;
				STD.TEXTIO.writeline(results, TX_LOC);
				STD.TEXTIO.Deallocate(TX_LOC);
				ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
				TX_ERROR := TX_ERROR + 1;
			END IF;
		END;

		BEGIN
		-- --------------------
		ce <= transport '1';
		in_x_0 <= transport std_logic_vector'("0000001100000000"); --300
		-- --------------------
		WAIT FOR 25000 ns; -- Time=25000 ns
		ce <= transport '0';
		-- --------------------
		WAIT FOR 110 ns; -- Time=25110 ns
		-- --------------------

		IF (TX_ERROR = 0) THEN 
			STD.TEXTIO.write(TX_OUT,string'("No errors or warnings"));
			STD.TEXTIO.writeline(results, TX_OUT);
			ASSERT (FALSE) REPORT
				"Simulation successful (not a failure).  No problems detected. "
				SEVERITY FAILURE;
		ELSE
			STD.TEXTIO.write(TX_OUT, TX_ERROR);
			STD.TEXTIO.write(TX_OUT, string'(
				" errors found in simulation"));
			STD.TEXTIO.writeline(results, TX_OUT);
			ASSERT (FALSE) REPORT
				"Errors found during simulation"
				SEVERITY FAILURE;
		END IF;
	END PROCESS;
END testbench_arch;

CONFIGURATION spartan2_clk_wrapper_cfg OF tv_3_tbw1 IS
	FOR testbench_arch
	END FOR;
END spartan2_clk_wrapper_cfg;
