// C:\XILINX\PROJECTS\ALU5BIT
// Verilog Test fixture created by
// HDL Bencher 5.1i
// Tue Oct 14 15:45:43 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

module testbench;
	reg a;
	reg b;
	reg ci;
	wire co;
	wire do;

	x1bitadder UUT (
		.a(a),
		.b(b),
		.ci(ci),
		.co(co),
		.do(do)
	);

	integer TX_FILE;
	integer TX_ERROR;

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

	// --------------------
	a = 1'b0;
	b = 1'b0;
	ci = 1'b0;
	// --------------------
	#200 // Time=200 ns
	a = 1'b1;
	// --------------------
	#100 // Time=300 ns
	a = 1'b0;
	b = 1'b1;
	// --------------------
	#100 // Time=400 ns
	a = 1'b1;
	// --------------------
	#100 // Time=500 ns
	a = 1'b0;
	b = 1'b0;
	ci = 1'b1;
	// --------------------
	#100 // Time=600 ns
	a = 1'b1;
	// --------------------
	#100 // Time=700 ns
	a = 1'b0;
	b = 1'b1;
	// --------------------
	#100 // Time=800 ns
	a = 1'b1;
	// --------------------
	#100 // Time=900 ns
	a = 1'b0;
	b = 1'b0;
	ci = 1'b0;
	// --------------------
	#150 // Time=1050 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_co;
	input NEXT_co;

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

task CHECK_do;
	input NEXT_do;

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

endmodule
