data/full_repos/permissive/117026779/sim/Test_GlueLogic.v
 line:139: before: "@"
1: b'%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:50: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:56: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:52: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:59: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:65: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:61: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:80: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:87: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:83: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:90: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:97: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:93: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:100: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Error: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:102: Too many digits for 4 bit number: 4\'b10101\n    inputs = 4\'b10101;\n             ^~~~~~~~\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:107: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:103: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:125: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:131: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:127: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:135: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:141: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:137: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:145: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:151: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:147: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:165: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:171: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:167: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:175: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:181: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:177: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:185: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:191: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:187: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:205: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:211: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:207: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:215: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:221: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:217: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:225: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:231: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:227: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:235: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:241: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:237: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:258: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:264: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:260: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:268: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:274: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:270: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:278: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:284: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:280: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:298: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:304: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:300: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:308: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:314: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:310: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:318: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:324: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:320: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:338: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:344: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:340: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:348: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:354: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:350: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:358: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:364: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:360: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:368: Unsupported: Ignoring delay on this delayed statement.\n #5\n ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:374: Unsupported: Ignoring delay on this delayed statement.\n        #10 $stop;\n        ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:370: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:387: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:389: Unsupported: Ignoring delay on this delayed statement.\n    #5\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:400: Unsupported: Ignoring delay on this delayed statement.\n  #5\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:402: Unsupported: Ignoring delay on this delayed statement.\n  #5\n  ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:410: Unsupported: Ignoring delay on this delayed statement.\n    #10\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:409: Unsupported: Ignoring delay on this delayed statement.\n    #10\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:431: Unsupported: Ignoring delay on this delayed statement.\n    #10 $stop;\n    ^\n%Warning-STMTDLY: data/full_repos/permissive/117026779/sim/Test_GlueLogic.v:432: Unsupported: Ignoring delay on this delayed statement.\n    #5 $finish;\n    ^\n%Error: Exiting due to 1 error(s), 83 warning(s)\n        ... See the manual and https://verilator.org for more assistance.\n'
module Test_GlueLogic;

`define INPUT_SIZE 4

reg [`INPUT_SIZE-1:0] inputs;
reg tribuffer_oe;
reg success_flag;
reg rst;
reg clk;

wire [`INPUT_SIZE-1:0] not_output;
wire [`INPUT_SIZE-1:0] tribuffer_output;
wire and_output;
wire or_output;
wire xor_output;
wire nand_output;
wire nor_output;
wire xnor_output;

NOT #(.WIDTH(`INPUT_SIZE)) not_GATE
(
	.in(inputs),
	.out(not_output)
);

task TEST_NOT;
begin
	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(not_output != `INPUT_SIZE'b0101)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    inputs = `INPUT_SIZE'b0101;
    #5
    if(not_output != `INPUT_SIZE'b1010)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

TRIBUFFER #(.WIDTH(`INPUT_SIZE)) tribuffer
(
	.oe(tribuffer_oe),
	.in(inputs),
	.out(tribuffer_output)
);

task TEST_TRIBUFFER;
begin
	#5
    tribuffer_oe = 1;
    inputs = `INPUT_SIZE'b1010;
    #5
    if(tribuffer_output != `INPUT_SIZE'b1010)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    tribuffer_oe = 1;
    inputs = `INPUT_SIZE'b0101;
    #5
    if(tribuffer_output != `INPUT_SIZE'b0101)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    tribuffer_oe = 0;
    inputs = `INPUT_SIZE'b10101;
    #5
    if(tribuffer_output != `INPUT_SIZE'bZ)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask





AND #(.WIDTH(`INPUT_SIZE)) and_gate
(
	.in(inputs),
	.out(and_output)
);

task TEST_AND;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(and_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(and_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(and_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

OR #(.WIDTH(`INPUT_SIZE)) or_gate
(
	.in(inputs),
	.out(or_output)
);

task TEST_OR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(or_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(or_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(or_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

XOR #(.WIDTH(`INPUT_SIZE)) xor_gate
(
	.in(inputs),
	.out(xor_output)
);

task TEST_XOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(xor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(xor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1110;
    #5
    if(xor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b0010;
    #5
    if(xor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask




NAND #(.WIDTH(`INPUT_SIZE)) nand_gate
(
	.in(inputs),
	.out(nand_output)
);

task TEST_NAND;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(nand_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(nand_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(nand_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

NOR #(.WIDTH(`INPUT_SIZE)) nor_gate
(
	.in(inputs),
	.out(nor_output)
);

task TEST_NOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(nor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(nor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(nor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

XNOR #(.WIDTH(`INPUT_SIZE)) xnor_gate
(
	.in(inputs),
	.out(xnor_output)
);

task TEST_XNOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(xnor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(xnor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end 

	#5
    inputs = `INPUT_SIZE'b1110;
    #5
    if(xnor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b0010;
    #5
    if(xnor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

task RESET;
begin
    rst = 0;
    clk = 0;
    inputs = 0;
    tribuffer_oe = 0;
    success_flag = 1;
    #5
    rst = 1;
    #5
    rst = 0;
end
endtask;

task CLOCK;
	input [31:0] count;
	integer k;
begin
	for (k=0; k < count; k = k+1)
	begin
		#5
		clk = 1;
		#5
		clk = 0;
	end
end
endtask

initial begin
    #10
    #10
	RESET;
    TEST_NOT;
    TEST_TRIBUFFER;
    TEST_AND;
    TEST_OR;
    TEST_XOR;
    TEST_NAND;
    TEST_NOR;
    TEST_XNOR;
    CLOCK(10);

    if(success_flag == 1'b1)
    begin
        $display("Test Successful");
    end
    else
    begin
        $display("Test Failure");
    end

    #10 $stop;
    #5 $finish;
end

endmodule
module Test_GlueLogic;


`define INPUT_SIZE 4

reg [`INPUT_SIZE-1:0] inputs;
reg tribuffer_oe;
reg success_flag;
reg rst;
reg clk;

wire [`INPUT_SIZE-1:0] not_output;
wire [`INPUT_SIZE-1:0] tribuffer_output;
wire and_output;
wire or_output;
wire xor_output;
wire nand_output;
wire nor_output;
wire xnor_output;

NOT #(.WIDTH(`INPUT_SIZE)) not_GATE
(
	.in(inputs),
	.out(not_output)
);

task TEST_NOT;
begin
	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(not_output != `INPUT_SIZE'b0101)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    inputs = `INPUT_SIZE'b0101;
    #5
    if(not_output != `INPUT_SIZE'b1010)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

TRIBUFFER #(.WIDTH(`INPUT_SIZE)) tribuffer
(
	.oe(tribuffer_oe),
	.in(inputs),
	.out(tribuffer_output)
);

task TEST_TRIBUFFER;
begin
	#5
    tribuffer_oe = 1;
    inputs = `INPUT_SIZE'b1010;
    #5
    if(tribuffer_output != `INPUT_SIZE'b1010)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    tribuffer_oe = 1;
    inputs = `INPUT_SIZE'b0101;
    #5
    if(tribuffer_output != `INPUT_SIZE'b0101)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
	#5
    tribuffer_oe = 0;
    inputs = `INPUT_SIZE'b10101;
    #5
    if(tribuffer_output != `INPUT_SIZE'bZ)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask





AND #(.WIDTH(`INPUT_SIZE)) and_gate
(
	.in(inputs),
	.out(and_output)
);

task TEST_AND;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(and_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(and_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(and_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

OR #(.WIDTH(`INPUT_SIZE)) or_gate
(
	.in(inputs),
	.out(or_output)
);

task TEST_OR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(or_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(or_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(or_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

XOR #(.WIDTH(`INPUT_SIZE)) xor_gate
(
	.in(inputs),
	.out(xor_output)
);

task TEST_XOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(xor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(xor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1110;
    #5
    if(xor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b0010;
    #5
    if(xor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask




NAND #(.WIDTH(`INPUT_SIZE)) nand_gate
(
	.in(inputs),
	.out(nand_output)
);

task TEST_NAND;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(nand_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(nand_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(nand_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

NOR #(.WIDTH(`INPUT_SIZE)) nor_gate
(
	.in(inputs),
	.out(nor_output)
);

task TEST_NOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(nor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(nor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1111;
    #5
    if(nor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

XNOR #(.WIDTH(`INPUT_SIZE)) xnor_gate
(
	.in(inputs),
	.out(xnor_output)
);

task TEST_XNOR;
begin
	#5
    inputs = `INPUT_SIZE'b0000;
    #5
    if(xnor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b1010;
    #5
    if(xnor_output != 1'b1)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end 

	#5
    inputs = `INPUT_SIZE'b1110;
    #5
    if(xnor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end

	#5
    inputs = `INPUT_SIZE'b0010;
    #5
    if(xnor_output != 1'b0)
    begin
        success_flag = 0;
        #10 $stop;
        $display("!!ERROR!! @ %d", $time);
    end
end
endtask

task RESET;
begin
    rst = 0;
    clk = 0;
    inputs = 0;
    tribuffer_oe = 0;
    success_flag = 1;
    #5
    rst = 1;
    #5
    rst = 0;
end
endtask;

task CLOCK;
	input [31:0] count;
	integer k;
begin
	for (k=0; k < count; k = k+1)
	begin
		#5
		clk = 1;
		#5
		clk = 0;
	end
end
endtask

initial begin
    #10
    #10
	RESET;
    TEST_NOT;
    TEST_TRIBUFFER;
    TEST_AND;
    TEST_OR;
    TEST_XOR;
    TEST_NAND;
    TEST_NOR;
    TEST_XNOR;
    CLOCK(10);

    if(success_flag == 1'b1)
    begin
        $display("Test Successful");
    end
    else
    begin
        $display("Test Failure");
    end

    #10 $stop;
    #5 $finish;
end

endmodule