// C:\XILINX\PROJECTS\BARRELSH
// Verilog Test fixture created by
// HDL Bencher 5.1i
// Sat Nov 01 14:04:17 2003
// 
// 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

`define ADDR_SZ	4
`define RAM_B_UPPER	30
`define RAM_C_UPPER	50
`define RAM_B_LOWER	20
`define RAM_WIDTH	16
`define RAM_A_LOWER	0
`define RAM_C_LOWER	40
`define RAM_A_UPPER	10
`define REG_WIDTH	16

module testbench;
	wire [15:0] DataOut;
	reg [15:0] DataIn;
	reg [3:0] ShiftDistance;

	barrelshifter2 UUT (
		.DataOut(DataOut),
		.DataIn(DataIn),
		.ShiftDistance(ShiftDistance)
	);

	integer TX_FILE;
	integer TX_ERROR;

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

	// --------------------
	DataIn = 16'b0000000000000000; //0
	ShiftDistance = 4'b0000; //0
	// --------------------
	#100 // Time=100 ns
	DataIn = 16'b0000000000000001; //1
	ShiftDistance = 4'b0001; //1
	// --------------------
	#100 // Time=200 ns
	DataIn = 16'b0000000000000010; //2
	ShiftDistance = 4'b0010; //2
	// --------------------
	#100 // Time=300 ns
	DataIn = 16'b0000000000000011; //3
	ShiftDistance = 4'b0011; //3
	// --------------------
	#100 // Time=400 ns
	DataIn = 16'b0000000000000100; //4
	ShiftDistance = 4'b0100; //4
	// --------------------
	#100 // Time=500 ns
	DataIn = 16'b0000000000000101; //5
	ShiftDistance = 4'b0101; //5
	// --------------------
	#100 // Time=600 ns
	DataIn = 16'b0000000000000110; //6
	ShiftDistance = 4'b0110; //6
	// --------------------
	#100 // Time=700 ns
	DataIn = 16'b0000000000000111; //7
	ShiftDistance = 4'b0111; //7
	// --------------------
	#100 // Time=800 ns
	DataIn = 16'b0000000000001000; //8
	ShiftDistance = 4'b1000; //8
	// --------------------
	#100 // Time=900 ns
	DataIn = 16'b0000000000001001; //9
	ShiftDistance = 4'b1001; //9
	// --------------------
	#100 // Time=1000 ns
	DataIn = 16'b0000000000001010; //A
	ShiftDistance = 4'b1010; //A
	// --------------------
	#100 // Time=1100 ns
	DataIn = 16'b0000000000001011; //B
	ShiftDistance = 4'b1011; //B
	// --------------------
	#100 // Time=1200 ns
	DataIn = 16'b0000000000001100; //C
	ShiftDistance = 4'b1100; //C
	// --------------------
	#100 // Time=1300 ns
	DataIn = 16'b0000000000001101; //D
	ShiftDistance = 4'b1101; //D
	// --------------------
	#100 // Time=1400 ns
	DataIn = 16'b0000000000001110; //E
	ShiftDistance = 4'b1110; //E
	// --------------------
	#100 // Time=1500 ns
	DataIn = 16'b0000000000001111; //F
	ShiftDistance = 4'b1111; //F
	// --------------------
	#350 // Time=1850 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_DataOut;
	input [15:0] NEXT_DataOut;

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

endmodule
