Skip to content

feat(sv): class-scoped types and randomization of module subclasses for package classes #1892

Open

Description

@tignear

Problem

Classes declared in packages and the compilation unit (#1850) are laid out and lowered in their own scope and exported as layouts. Two uses from an importing module still fail:

  1. Class-scoped types of an imported class. For package p; class C; typedef bit [7:0] word_t; endclass endpackage, a module with import p::C; C::word_t value; cannot resolve word_t: member types live in the declaring analysis's specialization registry, which the exported Class layout does not carry. This affects non-parameterized classes too.

  2. Randomization of module subclasses through a package-class handle. When a module declares D extends p::B and calls randomize() (or object-wide rand_mode) through a p::B handle holding a D, the call uses the package's p::B::randomize, whose dynamic-class cases were generated before D was visible, and fails with RandomizationClassMismatch. Virtual method dispatchers and $cast helpers are already rebuilt in the importing scope for its own classes; the built-in randomization dispatch is not.

  3. Class qualifiers imported inside a generate block. if (1) begin : g import p::C; initial value = C::f(); end reports an unknown package C: import resolution tells class qualifiers from package qualifiers only through the module's own imports, while generate-block imports stay in the generate scopes.

  4. Class qualifiers imported at compilation-unit scope. With import p::C; (or import p::*;) in the compilation unit before a module, C::f() inside the module reports an unknown package C: the module's ScopeImports does not include the compilation-unit imports visible before it, so the qualifier falls through to package lookup before unit.visibility.imports is consulted.

Expected

Export the resolved class-scoped types with the layouts and use them in member lookup; rebuild the imported randomization dispatch (and rand_mode) over the classes the importing scope sees; consult the enclosing generate imports and the compilation-unit imports when classifying C:: qualifiers.

Found in reviews of #1850.

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