Skip to content

-Wwidth-expand does not detect width mismatches in packed-variable assignments #1519

@jcurtiss8086

Description

@jcurtiss8086

While reviewing LINT errors from an industry tool, we found a real RTL width-mismatch bug that is not reported by Slang. I was expecting that -Wwidth-expand should flag an error for both the param and the logic-var assignments in the below example.

The LHS is 40 bits and the RHS is 30 bits for both the param and the logic-var. The RTL bug was that the 2nd packed dimension was changed from 5:0 to 7:0 without increasing the width from 6-bits to 8-bits in the concatenation values. This resulted in getting unintended values when directly accessing A[1], A[2], etc.

-Wpacked-array-conv also does not trigger.

module top;

    localparam bit [4:0][7:0] A = {
        6'd2,
        6'd4,
        6'd9,
        6'd24,
        6'd24
    };

    logic [4:0][7:0] b;

    always_comb begin
        b = {
            6'd2,
            6'd4,
            6'd9,
            6'd24,
            6'd24
        };

    end

endmodule

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions