Skip to content

sv: four-state and string actuals of class parameters #1964

Open

Description

@tignear

For a class value parameter without a declared type, such as class C #(parameter V = 0), the parameter takes the type of its actual (IEEE 1800-2023 6.20.2), and a specialization is identified by its values and types (8.25). The specialization key spells the actual as a literal of its width and signedness only, so C#(bit'(1)) and C#(logic'(1)) share one specialization although the two actuals have a two-state and a four-state type.

The analyzer's expression typing (ExprType) records width and signedness but not whether an expression is four-state, so the key cannot tell them apart yet.

Expected

Track the two-/four-state kind of constant expressions and include it in the key of an untyped value parameter.

Found in a review of #1796.

Also: named four-state and string constants as actuals

A literal four-state or string actual such as C#(2'bxx) is accepted, but a named one is rejected as "class parameter value that is not constant":

localparam logic [1:0] X = 2'bxx;
class C #(logic [1:0] N = 0); endclass
C#(X) h;   // rejected; C#(2'bxx) is accepted

The value is not an integer, and the scope's parameter literals that hold it are not part of the context a specialization's actuals are bound in. Pass the retained literals there and substitute them before deciding that an actual is not constant.

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