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

feature request: constant folding for division and remainder #2410

Open
ekiwi opened this issue Nov 10, 2021 · 1 comment
Open

feature request: constant folding for division and remainder #2410

ekiwi opened this issue Nov 10, 2021 · 1 comment

Comments

@ekiwi
Copy link
Contributor

ekiwi commented Nov 10, 2021

Feature Description

If there is a division or a remainder operation where both arguments are constant, the firrtl compiler should replace it with a constant.

Type of Feature

  • better optimization
@seldridge
Copy link
Member

Agree.

Small example of this:

circuit Foo :
  module Foo :
    output out : UInt<32>

    node _out_T = div(UInt<6>("h21"), UInt<3>("h4"))
    out <= _out_T 

This produces the following Verliog:

module Foo(
  output [31:0] out
);
  wire [5:0] _out_T = 6'h21 / 3'h4;
  assign out = {{26'd0}, _out_T};

It should produce:

module Foo(
  output [31:0] out);

  assign out = 32'h8;
endmodule

This is a situation where CIRCT has the optimization, but Scala FIRRTL does not. (I used it to generate the bottom Verilog.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants