// C:\XILINX\PROJECTS\CONTROLUNIT
// Verilog Test fixture created by
// HDL Bencher 5.1i
// Fri Oct 31 23:16:50 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;
	reg CLK;
	reg FUNCT0;
	reg FUNCT1;
	reg FUNCT2;
	reg FUNCT3;
	reg INTERRUPT;
	reg OPCODE0;
	reg OPCODE1;
	reg OPCODE2;
	reg OPCODE3;
	reg RESET;
	reg ZCValue;
	wire ALUOp0;
	wire ALUOp1;
	wire ALUOp2;
	wire EPCWRITE;
	wire INTWRITE;
	wire IRWRITE;
	wire MEMWRITE;
	wire Mux0;
	wire Mux1b0;
	wire Mux1b1;
	wire Mux1b2;
	wire Mux2;
	wire Mux3b0;
	wire Mux3b1;
	wire Mux5;
	wire Mux6b0;
	wire Mux6b1;
	wire Mux6b2;
	wire Mux7b0;
	wire Mux7b1;
	wire Mux7b2;
	wire Mux8b0;
	wire Mux8b1;
	wire Mux9;
	wire Mux10;
	wire OUTWRITE;
	wire PCWRITE;
	wire REGWRITE;
	wire SPECIALWRITE;

	constate UUT (
		.CLK(CLK),
		.FUNCT0(FUNCT0),
		.FUNCT1(FUNCT1),
		.FUNCT2(FUNCT2),
		.FUNCT3(FUNCT3),
		.INTERRUPT(INTERRUPT),
		.OPCODE0(OPCODE0),
		.OPCODE1(OPCODE1),
		.OPCODE2(OPCODE2),
		.OPCODE3(OPCODE3),
		.RESET(RESET),
		.ZCValue(ZCValue),
		.ALUOp0(ALUOp0),
		.ALUOp1(ALUOp1),
		.ALUOp2(ALUOp2),
		.EPCWRITE(EPCWRITE),
		.INTWRITE(INTWRITE),
		.IRWRITE(IRWRITE),
		.MEMWRITE(MEMWRITE),
		.Mux0(Mux0),
		.Mux1b0(Mux1b0),
		.Mux1b1(Mux1b1),
		.Mux1b2(Mux1b2),
		.Mux2(Mux2),
		.Mux3b0(Mux3b0),
		.Mux3b1(Mux3b1),
		.Mux5(Mux5),
		.Mux6b0(Mux6b0),
		.Mux6b1(Mux6b1),
		.Mux6b2(Mux6b2),
		.Mux7b0(Mux7b0),
		.Mux7b1(Mux7b1),
		.Mux7b2(Mux7b2),
		.Mux8b0(Mux8b0),
		.Mux8b1(Mux8b1),
		.Mux9(Mux9),
		.Mux10(Mux10),
		.OUTWRITE(OUTWRITE),
		.PCWRITE(PCWRITE),
		.REGWRITE(REGWRITE),
		.SPECIALWRITE(SPECIALWRITE)
	);

	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");

	// --------------------
	FUNCT0 = 1'b0;
	FUNCT1 = 1'b0;
	FUNCT2 = 1'b0;
	FUNCT3 = 1'b0;
	INTERRUPT = 1'b0;
	OPCODE0 = 1'b0;
	OPCODE1 = 1'b0;
	OPCODE2 = 1'b0;
	OPCODE3 = 1'b0;
	RESET = 1'b0;
	ZCValue = 1'b0;
	// --------------------
	#100 // Time=100 ns
	FUNCT0 = 1'b1;
	INTERRUPT = 1'b1;
	OPCODE0 = 1'b1;
	RESET = 1'b1;
	// --------------------
	#100 // Time=200 ns
	FUNCT0 = 1'b0;
	FUNCT1 = 1'b1;
	INTERRUPT = 1'b0;
	OPCODE0 = 1'b0;
	OPCODE1 = 1'b1;
	RESET = 1'b0;
	// --------------------
	#100 // Time=300 ns
	FUNCT0 = 1'b1;
	INTERRUPT = 1'b1;
	OPCODE0 = 1'b1;
	RESET = 1'b1;
	// --------------------
	#100 // Time=400 ns
	FUNCT0 = 1'b0;
	FUNCT1 = 1'b0;
	FUNCT2 = 1'b1;
	INTERRUPT = 1'b0;
	OPCODE0 = 1'b0;
	OPCODE1 = 1'b0;
	OPCODE2 = 1'b1;
	RESET = 1'b0;
	// --------------------
	#100 // Time=500 ns
	FUNCT0 = 1'b1;
	INTERRUPT = 1'b1;
	OPCODE0 = 1'b1;
	RESET = 1'b1;
	// --------------------
	#100 // Time=600 ns
	FUNCT0 = 1'b0;
	FUNCT1 = 1'b1;
	INTERRUPT = 1'b0;
	OPCODE0 = 1'b0;
	OPCODE1 = 1'b1;
	RESET = 1'b0;
	// --------------------
	#100 // Time=700 ns
	FUNCT0 = 1'b1;
	INTERRUPT = 1'b1;
	OPCODE0 = 1'b1;
	RESET = 1'b1;
	// --------------------
	#100 // Time=800 ns
	FUNCT0 = 1'b0;
	FUNCT1 = 1'b0;
	FUNCT2 = 1'b0;
	FUNCT3 = 1'b1;
	INTERRUPT = 1'b0;
	OPCODE0 = 1'b0;
	OPCODE1 = 1'b0;
	OPCODE2 = 1'b0;
	OPCODE3 = 1'b1;
	RESET = 1'b0;
	ZCValue = 1'b1;
	// --------------------
	#100 // Time=900 ns
	FUNCT0 = 1'b1;
	INTERRUPT = 1'b1;
	OPCODE0 = 1'b1;
	RESET = 1'b1;
	// --------------------
	#10 // Time=910 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_ALUOp0;
	input NEXT_ALUOp0;

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

task CHECK_ALUOp1;
	input NEXT_ALUOp1;

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

task CHECK_ALUOp2;
	input NEXT_ALUOp2;

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

task CHECK_EPCWRITE;
	input NEXT_EPCWRITE;

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

task CHECK_INTWRITE;
	input NEXT_INTWRITE;

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

task CHECK_IRWRITE;
	input NEXT_IRWRITE;

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

task CHECK_MEMWRITE;
	input NEXT_MEMWRITE;

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

task CHECK_Mux0;
	input NEXT_Mux0;

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

task CHECK_Mux1b0;
	input NEXT_Mux1b0;

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

task CHECK_Mux1b1;
	input NEXT_Mux1b1;

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

task CHECK_Mux1b2;
	input NEXT_Mux1b2;

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

task CHECK_Mux2;
	input NEXT_Mux2;

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

task CHECK_Mux3b0;
	input NEXT_Mux3b0;

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

task CHECK_Mux3b1;
	input NEXT_Mux3b1;

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

task CHECK_Mux5;
	input NEXT_Mux5;

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

task CHECK_Mux6b0;
	input NEXT_Mux6b0;

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

task CHECK_Mux6b1;
	input NEXT_Mux6b1;

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

task CHECK_Mux6b2;
	input NEXT_Mux6b2;

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

task CHECK_Mux7b0;
	input NEXT_Mux7b0;

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

task CHECK_Mux7b1;
	input NEXT_Mux7b1;

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

task CHECK_Mux7b2;
	input NEXT_Mux7b2;

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

task CHECK_Mux8b0;
	input NEXT_Mux8b0;

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

task CHECK_Mux8b1;
	input NEXT_Mux8b1;

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

task CHECK_Mux9;
	input NEXT_Mux9;

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

task CHECK_Mux10;
	input NEXT_Mux10;

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

task CHECK_OUTWRITE;
	input NEXT_OUTWRITE;

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

task CHECK_PCWRITE;
	input NEXT_PCWRITE;

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

task CHECK_REGWRITE;
	input NEXT_REGWRITE;

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

task CHECK_SPECIALWRITE;
	input NEXT_SPECIALWRITE;

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

endmodule
