data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v
 line:35: before: ")"
1: b'%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:4: Cannot find include file: vending_machine.v\n`include "vending_machine.v" \n         ^~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/149079484/vendingmachine-lab,data/full_repos/permissive/149079484/vending_machine.v\n             data/full_repos/permissive/149079484/vendingmachine-lab,data/full_repos/permissive/149079484/vending_machine.v.v\n             data/full_repos/permissive/149079484/vendingmachine-lab,data/full_repos/permissive/149079484/vending_machine.v.sv\n             vending_machine.v\n             vending_machine.v.v\n             vending_machine.v.sv\n             obj_dir/vending_machine.v\n             obj_dir/vending_machine.v.v\n             obj_dir/vending_machine.v.sv\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:47: Define or directive not defined: \'`kTotalBits\'\nreg [`kTotalBits-1:0] current_total;\n     ^~~~~~~~~~~\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:48: Define or directive not defined: \'`kTotalBits\'\nreg [`kTotalBits-1:0] return_temp;\n     ^~~~~~~~~~~\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:51: Define or directive not defined: \'`kTotalBits\'\nwire [`kTotalBits-1:0] current_total_wire = current_total;\n      ^~~~~~~~~~~\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:52: Define or directive not defined: \'`kTotalBits\'\nwire [`kTotalBits-1:0] return_temp_wire = return_temp;\n      ^~~~~~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:73: Unsupported: Ignoring delay on this delayed statement.\nalways #50 clk <= ~clk;  \n       ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:78: Unsupported: Ignoring delay on this delayed statement.\n #50 reset_n = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:79: Unsupported: Ignoring delay on this delayed statement.\n #100 reset_n = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:96: Unsupported: Ignoring delay on this delayed statement.\n # 200;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:123: Unsupported: Ignoring delay on this delayed statement.\n #100 $finish(0);\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:223: Unsupported: Ignoring delay on this delayed statement.\n # 200;  \n ^\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:245: Unsupported: wait statements\n  wait (o_return_coin);  \n  ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:246: Unsupported: Ignoring delay on this delayed statement.\n  # 50;  \n  ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:250: Unsupported: Ignoring delay on this delayed statement.\n  # 50;\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:269: Unsupported: Ignoring delay on this delayed statement.\n #500;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:270: Unsupported: Ignoring delay on this delayed statement.\n #50 i_trigger_return = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:271: Unsupported: Ignoring delay on this delayed statement.\n #50 reset_n = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:272: Unsupported: Ignoring delay on this delayed statement.\n #100 reset_n = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:303: Unsupported: Ignoring delay on this delayed statement.\n #500;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:304: Unsupported: Ignoring delay on this delayed statement.\n #50 reset_n = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:305: Unsupported: Ignoring delay on this delayed statement.\n #100 reset_n = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:314: Unsupported: Ignoring delay on this delayed statement.\n #50 i_trigger_return = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:315: Unsupported: Ignoring delay on this delayed statement.\n #50 i_trigger_return = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:317: Unsupported: Ignoring delay on this delayed statement.\n #500;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:331: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[0] = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:332: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[0] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:339: Unsupported: Ignoring delay on this delayed statement.\n #500;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:340: Unsupported: Ignoring delay on this delayed statement.\n #50 reset_n = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:341: Unsupported: Ignoring delay on this delayed statement.\n #100 reset_n = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:365: Unsupported: Ignoring delay on this delayed statement.\n #50 i_trigger_return = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:366: Unsupported: Ignoring delay on this delayed statement.\n #50 i_trigger_return = 0;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:367: Unsupported: Ignoring delay on this delayed statement.\n #500;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:379: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[1] = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:380: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[1] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:387: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[2] = 1;\n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:388: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_input_coin[2] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:395: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[0] = 1;\n ^\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:396: Unsupported: wait statements\n wait (o_output_item[0]);   \n ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:397: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[0] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:404: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[1] = 1;\n ^\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:405: Unsupported: wait statements\n wait (o_output_item[1]);   \n ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:406: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[1] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:413: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[2] = 1;\n ^\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:414: Unsupported: wait statements\n wait (o_output_item[2]);  \n ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:415: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[2] = 0;  \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:422: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[3] = 1;\n ^\n%Error: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:423: Unsupported: wait statements\n wait (o_output_item[3]);  \n ^~~~\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:424: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_select_item[3] = 0;   \n ^\n%Warning-STMTDLY: data/full_repos/permissive/149079484/vendingmachine-lab/vending_meachine_TB.v:430: Unsupported: Ignoring delay on this delayed statement.\n # 100 i_trigger_return = 1;\n ^\n%Error: Exiting due to 10 error(s), 39 warning(s)\n'
module vending_machine_tb;







reg clk;
reg reset_n;
reg [2:0]i_input_coin;
reg [3:0]i_select_item;
reg i_trigger_return;
wire [3:0]o_available_item;
wire [3:0]o_output_item;
wire [2:0]o_return_coin;

reg [3:0]stopwatch;
reg [`kTotalBits-1:0] current_total;
reg [`kTotalBits-1:0] return_temp;

wire [3:0]stopwatch_wire = stopwatch;
wire [`kTotalBits-1:0] current_total_wire = current_total;
wire [`kTotalBits-1:0] return_temp_wire = return_temp;

integer Passed;
integer Failed;
integer Current;


	vending_machine UUT (
		.clk(clk),
		.reset_n(reset_n),
		.i_input_coin(i_input_coin),
		.i_select_item(i_select_item),
		.i_trigger_return(i_trigger_return),
		.o_available_item(o_available_item),
		.o_output_item(o_output_item),
		.o_return_coin(o_return_coin),
		.current_total(current_total_wire),
		.return_temp(return_temp_wire),
		.stopwatch(stopwatch_wire));

initial clk <= 0;
always #50 clk <= ~clk;

initial begin

	reset_n = 1;
	#50 reset_n = 0;
	#100 reset_n = 1;


	i_input_coin[0] = 0;
	i_input_coin[1] = 0;
	i_input_coin[2] = 0;
	i_select_item[0] = 0;
	i_select_item[1] = 0;
	i_select_item[2] = 0;
	i_select_item[3] = 0;
	i_trigger_return = 0;


	Passed = 0;
	Failed = 0;
	Current = 0;

	# 200;


	InitialTest();
	Insert100CoinTest();
	Insert500CoinTest();
	Insert1000CoinTest();


	Select1stItemTest();
	Select2ndItemTest();
	Select3rdItemTest();
	Select4thItemTest();


	WaitReturnTest();
	TriggerReturnTest();


	ItemTest();

	CoinTest1();
	CoinTest2();


	$display("Passed = %0d, Failed = %0d", Passed, Failed);

	#100 $finish(0);
end

task InitialTest;
	AvailableItemTest("InitialTest",  4'b0);
endtask


task Insert100CoinTest;
	begin
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		AvailableItemTest("Insert100CoinTest", 4'b0011);
	end
endtask

task Insert500CoinTest;
begin
	Insert500Coin();
	Insert500Coin();
	AvailableItemTest("Insert500CoinTest", 4'b0111);
end
endtask

task Insert1000CoinTest;
begin
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	AvailableItemTest("Insert1000CoinTest", 4'b1111);
end
endtask


task Select1stItemTest;
begin
	Select1stItem();
	Select1stItem();
	AvailableItemTest("Select1stItemTest", 4'b1111);
end
endtask

task Select2ndItemTest;
begin
	Select2ndItem();
	Select2ndItem();
	AvailableItemTest("Select2ndItemTest", 4'b1111);
end
endtask

task Select3rdItemTest;
begin
	Select3rdItem();
	AvailableItemTest("Select3rdItemTest", 4'b1111);
end
endtask

task Select4thItemTest;
begin
	Select4thItem();
	AvailableItemTest("Select4thItemTest", 4'b0011);
end
endtask

task WaitReturnTest;
begin
	Insert100Coin();
	Insert500Coin();
	Insert1000Coin();
	ReturnTest("WaitReturnTest");
end
endtask

task TriggerReturnTest;
begin
	Insert100Coin();
	Insert100Coin();
	Insert100Coin();
	Insert500Coin();
	Insert500Coin();
	Insert500Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	TriggerReturn();
	ReturnTest("TriggerReturnTest");
end
endtask


task AvailableItemTest;
	input [32 * 8 : 0] Testname;
	input [3:0] o_available_item_expected;
begin
	$display("TEST %s :", Testname);

	# 200;
	if (o_available_item == o_available_item_expected)
		begin
			$display("PASSED");
			Passed = Passed + 1;
		end
	else
		begin
			$display("FAILED");
			$display("o_available_item = %0b (Ans: %0b)", o_available_item, o_available_item_expected);
			Failed = Failed + 1;
		end
end
endtask

task ReturnTest;
	input [32 * 8 : 0] Testname;
begin
	$display("TEST %s :", Testname);

	while (Current > 0) begin

		wait (o_return_coin);
		# 50;
		if (o_return_coin[0]) Current = Current - 'd100;
		if (o_return_coin[1]) Current = Current - 'd500;
		if (o_return_coin[2]) Current = Current - 'd1000;
		# 50;
	end

	if (Current == 0)
		begin
			$display("PASSED");
		    Passed = Passed + 1;
		end
	else
		begin
			$display("FAILED");
			$display("%d", Current);
			Failed = Failed + 1;
		end
end
endtask

task ItemTest;
begin
	#500;
	#50 i_trigger_return = 0;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();

	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();


	AvailableItemTest("ItemTestTest",  4'b1101);
end
endtask

task CoinTest1;
begin
	#500;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();

	Select1stItem();
	Select1stItem();
	Select1stItem();
	Select1stItem();
	#50 i_trigger_return = 1;
	#50 i_trigger_return = 0;

	#500;

	Insert1000Coin();
	Insert1000Coin();

	AvailableItemTest("ItemTestTest",  4'b1111);
end
endtask




task Insert100Coin;
begin
	# 100 i_input_coin[0] = 1;
	# 100 i_input_coin[0] = 0;
	Current = Current + 'd100;
end
endtask

task CoinTest2;
begin
	#500;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();

	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();

	#50 i_trigger_return = 1;
	#50 i_trigger_return = 0;
	#500;

	Insert1000Coin();
	Insert1000Coin();

	AvailableItemTest("ItemTestTest",  4'b1101);
end
endtask


task Insert500Coin;
begin
	# 100 i_input_coin[1] = 1;
	# 100 i_input_coin[1] = 0;
	Current = Current + 'd500;
end
endtask

task Insert1000Coin;
begin
	# 100 i_input_coin[2] = 1;
	# 100 i_input_coin[2] = 0;
	Current = Current + 'd1000;
end
endtask

task Select1stItem;
begin
	# 100 i_select_item[0] = 1;
	wait (o_output_item[0]);
	# 100 i_select_item[0] = 0;
	Current = Current - 'd400;
end
endtask

task Select2ndItem;
begin
	# 100 i_select_item[1] = 1;
	wait (o_output_item[1]);
	# 100 i_select_item[1] = 0;
	Current = Current - 'd500;
end
endtask

task Select3rdItem;
begin
	# 100 i_select_item[2] = 1;
	wait (o_output_item[2]);
	# 100 i_select_item[2] = 0;
	Current = Current - 'd1000;
end
endtask

task Select4thItem;
begin
	# 100 i_select_item[3] = 1;
	wait (o_output_item[3]);
	# 100 i_select_item[3] = 0;
	Current = Current - 'd2000;
end
endtask

task TriggerReturn;
	# 100 i_trigger_return = 1;
endtask

endmodule
module vending_machine_tb;








reg clk;
reg reset_n;
reg [2:0]i_input_coin;
reg [3:0]i_select_item;
reg i_trigger_return;
wire [3:0]o_available_item;
wire [3:0]o_output_item;
wire [2:0]o_return_coin;

reg [3:0]stopwatch;
reg [`kTotalBits-1:0] current_total;
reg [`kTotalBits-1:0] return_temp;

wire [3:0]stopwatch_wire = stopwatch;
wire [`kTotalBits-1:0] current_total_wire = current_total;
wire [`kTotalBits-1:0] return_temp_wire = return_temp;

integer Passed;
integer Failed;
integer Current;


	vending_machine UUT (
		.clk(clk),
		.reset_n(reset_n),
		.i_input_coin(i_input_coin),
		.i_select_item(i_select_item),
		.i_trigger_return(i_trigger_return),
		.o_available_item(o_available_item),
		.o_output_item(o_output_item),
		.o_return_coin(o_return_coin),
		.current_total(current_total_wire),
		.return_temp(return_temp_wire),
		.stopwatch(stopwatch_wire));

initial clk <= 0;
always #50 clk <= ~clk;

initial begin

	reset_n = 1;
	#50 reset_n = 0;
	#100 reset_n = 1;


	i_input_coin[0] = 0;
	i_input_coin[1] = 0;
	i_input_coin[2] = 0;
	i_select_item[0] = 0;
	i_select_item[1] = 0;
	i_select_item[2] = 0;
	i_select_item[3] = 0;
	i_trigger_return = 0;


	Passed = 0;
	Failed = 0;
	Current = 0;

	# 200;


	InitialTest();
	Insert100CoinTest();
	Insert500CoinTest();
	Insert1000CoinTest();


	Select1stItemTest();
	Select2ndItemTest();
	Select3rdItemTest();
	Select4thItemTest();


	WaitReturnTest();
	TriggerReturnTest();


	ItemTest();

	CoinTest1();
	CoinTest2();


	$display("Passed = %0d, Failed = %0d", Passed, Failed);

	#100 $finish(0);
end

task InitialTest;
	AvailableItemTest("InitialTest",  4'b0);
endtask


task Insert100CoinTest;
	begin
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		Insert100Coin();
		AvailableItemTest("Insert100CoinTest", 4'b0011);
	end
endtask

task Insert500CoinTest;
begin
	Insert500Coin();
	Insert500Coin();
	AvailableItemTest("Insert500CoinTest", 4'b0111);
end
endtask

task Insert1000CoinTest;
begin
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	AvailableItemTest("Insert1000CoinTest", 4'b1111);
end
endtask


task Select1stItemTest;
begin
	Select1stItem();
	Select1stItem();
	AvailableItemTest("Select1stItemTest", 4'b1111);
end
endtask

task Select2ndItemTest;
begin
	Select2ndItem();
	Select2ndItem();
	AvailableItemTest("Select2ndItemTest", 4'b1111);
end
endtask

task Select3rdItemTest;
begin
	Select3rdItem();
	AvailableItemTest("Select3rdItemTest", 4'b1111);
end
endtask

task Select4thItemTest;
begin
	Select4thItem();
	AvailableItemTest("Select4thItemTest", 4'b0011);
end
endtask

task WaitReturnTest;
begin
	Insert100Coin();
	Insert500Coin();
	Insert1000Coin();
	ReturnTest("WaitReturnTest");
end
endtask

task TriggerReturnTest;
begin
	Insert100Coin();
	Insert100Coin();
	Insert100Coin();
	Insert500Coin();
	Insert500Coin();
	Insert500Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	TriggerReturn();
	ReturnTest("TriggerReturnTest");
end
endtask


task AvailableItemTest;
	input [32 * 8 : 0] Testname;
	input [3:0] o_available_item_expected;
begin
	$display("TEST %s :", Testname);

	# 200;
	if (o_available_item == o_available_item_expected)
		begin
			$display("PASSED");
			Passed = Passed + 1;
		end
	else
		begin
			$display("FAILED");
			$display("o_available_item = %0b (Ans: %0b)", o_available_item, o_available_item_expected);
			Failed = Failed + 1;
		end
end
endtask

task ReturnTest;
	input [32 * 8 : 0] Testname;
begin
	$display("TEST %s :", Testname);

	while (Current > 0) begin

		wait (o_return_coin);
		# 50;
		if (o_return_coin[0]) Current = Current - 'd100;
		if (o_return_coin[1]) Current = Current - 'd500;
		if (o_return_coin[2]) Current = Current - 'd1000;
		# 50;
	end

	if (Current == 0)
		begin
			$display("PASSED");
		    Passed = Passed + 1;
		end
	else
		begin
			$display("FAILED");
			$display("%d", Current);
			Failed = Failed + 1;
		end
end
endtask

task ItemTest;
begin
	#500;
	#50 i_trigger_return = 0;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();

	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();


	AvailableItemTest("ItemTestTest",  4'b1101);
end
endtask

task CoinTest1;
begin
	#500;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();

	Select1stItem();
	Select1stItem();
	Select1stItem();
	Select1stItem();
	#50 i_trigger_return = 1;
	#50 i_trigger_return = 0;

	#500;

	Insert1000Coin();
	Insert1000Coin();

	AvailableItemTest("ItemTestTest",  4'b1111);
end
endtask




task Insert100Coin;
begin
	# 100 i_input_coin[0] = 1;
	# 100 i_input_coin[0] = 0;
	Current = Current + 'd100;
end
endtask

task CoinTest2;
begin
	#500;
	#50 reset_n = 0;
	#100 reset_n = 1;

	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();
	Insert1000Coin();

	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();
	Select2ndItem();

	#50 i_trigger_return = 1;
	#50 i_trigger_return = 0;
	#500;

	Insert1000Coin();
	Insert1000Coin();

	AvailableItemTest("ItemTestTest",  4'b1101);
end
endtask


task Insert500Coin;
begin
	# 100 i_input_coin[1] = 1;
	# 100 i_input_coin[1] = 0;
	Current = Current + 'd500;
end
endtask

task Insert1000Coin;
begin
	# 100 i_input_coin[2] = 1;
	# 100 i_input_coin[2] = 0;
	Current = Current + 'd1000;
end
endtask

task Select1stItem;
begin
	# 100 i_select_item[0] = 1;
	wait (o_output_item[0]);
	# 100 i_select_item[0] = 0;
	Current = Current - 'd400;
end
endtask

task Select2ndItem;
begin
	# 100 i_select_item[1] = 1;
	wait (o_output_item[1]);
	# 100 i_select_item[1] = 0;
	Current = Current - 'd500;
end
endtask

task Select3rdItem;
begin
	# 100 i_select_item[2] = 1;
	wait (o_output_item[2]);
	# 100 i_select_item[2] = 0;
	Current = Current - 'd1000;
end
endtask

task Select4thItem;
begin
	# 100 i_select_item[3] = 1;
	wait (o_output_item[3]);
	# 100 i_select_item[3] = 0;
	Current = Current - 'd2000;
end
endtask

task TriggerReturn;
	# 100 i_trigger_return = 1;
endtask

endmodule