unnamed_genblk.sv 1.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// This test was adapted from Section 27.6 of IEEE 1800-2017

module mod;
    initial $dumpvars(0, mod);

    parameter genblk2 = 0;
    genvar i;

    // The following generate block is implicitly named genblk1

11 12
    if (genblk2) logic a; // mod.genblk1.a
    else logic b; // mod.genblk1.b
13 14 15 16

    // The following generate block is implicitly named genblk02
    // as genblk2 is already a declared identifier

17 18
    if (genblk2) logic a; // mod.genblk02.a
    else logic b; // mod.genblk02.b
19 20 21 22 23 24 25

    // The following generate block would have been named genblk3
    // but is explicitly named g1

    for (i = 0; i < 1; i = i + 1) begin : g1 // block name
        // The following generate block is implicitly named genblk1
        // as the first nested scope inside g1
26
        if (1) logic a; // mod.g1[0].genblk1.a
27 28 29 30 31 32 33
    end

    // The following generate block is implicitly named genblk4 since
    // it belongs to the fourth generate construct in scope "mod".
    // The previous generate block would have been
    // named genblk3 if it had not been explicitly named g1

34
    for (i = 0; i < 1; i = i + 1)
35 36
        // The following generate block is implicitly named genblk1
        // as the first nested generate block in genblk4
37
        if (1) logic a; // mod.genblk4[0].genblk1.a
38 39

    // The following generate block is implicitly named genblk5
40
    if (1) logic a; // mod.genblk5.a
41 42 43 44 45 46
endmodule

module top;
    mod #(0) m0();
    mod #(1) m1();
endmodule