Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint errors for self-determined bit length for concat operands #1704

Open
mikex-oss opened this issue Nov 8, 2024 · 0 comments
Open

Lint errors for self-determined bit length for concat operands #1704

mikex-oss opened this issue Nov 8, 2024 · 0 comments
Labels
bug Something isn't working or is incorrect codegen Related to emitting (System)Verilog.

Comments

@mikex-oss
Copy link
Collaborator

mikex-oss commented Nov 8, 2024

Describe the bug

I'm not exactly sure how to repro in a minimal DSLX example since when an expression is inlined is a bit of a mystery to me, but in certain circumstances, codegen will emit a bit concatenation with under-specified operand sizes, e.g. something like:

  reg [32:0] concat;
  assign concat = {x[0], p1_y >= 32'h0000_0020 ? 32'h0000_0000 : p1_x << p1_y};

In Verilog, per Table 11-21, all the operands in a concat are self-determined. This means that if p1_x << p1_y is under-/over-sized, the concatenation could be as well and then padded/truncated to achieve the assignment.

In other cases, XLS will codegen a function as the operand (e.g. shra, priority_select), and the bitwidth is no longer self-determined (dictated by the function return bitwidth).

To Reproduce

I played around with it but couldn't generate this with a small minimal test case. However, the above pattern is generated from valid DSLX code.

To repro, I manually modified pipeline stage 2 generated by:

%%dslx --top=shll --pipeline_stages=2

fn shll(x:u32, y:u32) -> u32 {
  x << y
}

Expected behavior
All operands in the concatenation should be explicitly sized, either locally or by factoring out the operand in a function or separate reg.

@mikex-oss mikex-oss added bug Something isn't working or is incorrect codegen Related to emitting (System)Verilog. labels Nov 8, 2024
@mikex-oss mikex-oss changed the title Lint errors self-determined bit length for concat operands Lint errors for self-determined bit length for concat operands Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or is incorrect codegen Related to emitting (System)Verilog.
Projects
None yet
Development

No branches or pull requests

1 participant