else_prec.sv 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
module top;

    integer i;

    task t;
        input a, b, c;
        begin

            $display("1 (%b, %b, %b)", a, b, c);
            if (a) begin
                if (b) begin
                    $display("FOO");
                end
            end else begin
                if (c) begin
                    $display("BAR");
                end
            end

            $display("2 (%b, %b, %b)", a, b, c);
            if (a) begin
                for (i = 0; i < 1; ++i)
                if (b) begin
                    $display("FOO");
                end
            end else begin
                if (c) begin
                    $display("BAR");
                end
            end

32 33 34 35 36 37 38 39 40 41 42 43
            $display("3 (%b, %b, %b)", a, b, c);
            if (a) begin
                #1
                if (b) begin
                    $display("FOO");
                end
            end else begin
                if (c) begin
                    $display("BAR");
                end
            end

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        end
    endtask

    initial begin
        t(0, 0, 0);
        t(0, 0, 1);
        t(0, 1, 0);
        t(0, 1, 1);
        t(1, 0, 0);
        t(1, 0, 1);
        t(1, 1, 0);
        t(1, 1, 1);
    end

endmodule