Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants