// C:\MATLAB6P5\WORK\ISNIAMY\XSPARTAN2
// Verilog Test fixture created by
// HDL Bencher 6.1i
// Thu Aug 11 12:10:36 2005
// 
// Notes:
// 1) This test fixture has been automatically generated from
//   your Test Bench Waveform
// 2) To use this as a user modifiable test fixture do the following:
//   - Save it as a file with a .tf extension (i.e. File->Save As...)
//   - Add it to your project as a testbench source (i.e. Project->Add Source...)
// 

`timescale 1ns/1ns

module spartan2_tb;
	reg ce;
	reg clk;
	reg [15:0] in_x_0;
	wire [23:0] out_x_0;

	spartan2_clk_wrapper UUT (
		.ce(ce),
		.clk(clk),
		.in_x_0(in_x_0),
		.out_x_0(out_x_0)
	);

	integer TX_FILE;
	integer TX_ERROR;

always
begin 			//clock process
	clk = 1'b0;
	#10
	clk = 1'b1;
	#10
	#40
	clk = 1'b0;
	#40
	clk = 1'b0;
end

initial
begin
	TX_ERROR=0;
	TX_FILE=$fopen("results.txt");

	// --------------------
	ce = 1'b1;
	in_x_0 = 16'b0000001100000000; //300
	// --------------------
	#100 // Time=100 ns
	in_x_0 = 16'b0000010000000000; //400
	// --------------------
	#110 // Time=210 ns
	// --------------------

	if (TX_ERROR == 0) begin
		$display("No errors or warnings");
		$fdisplay(TX_FILE,"No errors or warnings");
	end else begin
		$display("%d errors found in simulation",TX_ERROR);
		$fdisplay(TX_FILE,"%d errors found in simulation",TX_ERROR);
	end

	$fclose(TX_FILE);
	$stop;

end

task CHECK_out_x_0;
	input [23:0] NEXT_out_x_0;

	#0 begin
		if (NEXT_out_x_0 !== out_x_0) begin
			$display("Error at time=%dns out_x_0=%b, expected=%b",
				$time, out_x_0, NEXT_out_x_0);
			$fdisplay(TX_FILE,"Error at time=%dns out_x_0=%b, expected=%b",
				$time, out_x_0, NEXT_out_x_0);
			TX_ERROR = TX_ERROR + 1;
		end
	end
endtask

endmodule
