Skip to content

sv: classes declared in loop generate blocks #2064

Open

Description

@tignear

A class declared in a loop generate block is a class of its own in each elaborated iteration, with that iteration's constants (IEEE 1800-2023 27.4):

for (genvar i = 0; i < 2; i++) begin : g
    localparam int K = i + 1;
    class C #(int N = K); endclass
    initial $display("%0d", C#()::N);   // 1 in g[0], 2 in g[1]
end

The analyzer keys class declarations, their declaration scopes and specializations by the class name and source range, so all iterations would share one declaration and one iteration's constants. Since #1796 such classes are rejected ("class C declared in a loop generate block") instead of being silently merged.

Expected

Give each elaborated generate instance its own class identity (declaration scope, specializations, static properties) and lift the rejection.

Found in a review of #1796.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions