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

[Verilog][FIRRTL] Improve $signed Elision #7935

Open
seldridge opened this issue Dec 2, 2024 · 0 comments
Open

[Verilog][FIRRTL] Improve $signed Elision #7935

seldridge opened this issue Dec 2, 2024 · 0 comments
Labels
FIRRTL Involving the `firrtl` dialect Verilog Quality

Comments

@seldridge
Copy link
Member

seldridge commented Dec 2, 2024

For certain operations, the Verilog emission can include extra $signed casts. This is a lint warning in some tools and it would be good to avoid this.

Consider:

FIRRTL version 4.0.0
circuit Foo:
  public module Foo:
    input a: UInt<1>
    output c: SInt<4>

    connect c, dshr(SInt<4>(3), a)

When compiled to Verilog this produces:

// Generated by CIRCT firtool-1.95.1-52-g94a562c5e
module Foo(
  input        a,
  output [3:0] c
);

  assign c = $signed(4'sh3 >>> a);
endmodule

The extra $signed here should be unnecessary.

Care should be taken to not make mistakes that things incorrectly become unsigned and break simulation.

@seldridge seldridge added FIRRTL Involving the `firrtl` dialect Verilog Quality labels Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect Verilog Quality
Projects
None yet
Development

No branches or pull requests

1 participant