circt icon indicating copy to clipboard operation
circt copied to clipboard

[FIRRTL] Inliner: names beginning with `_` should keep the leading underscore leading when mangled

Open youngar opened this issue 1 year ago • 0 comments

The following FIRRTL,

FIRRTL version 4.0.0
circuit Foo :%[[
  {
    "class":"firrtl.passes.InlineAnnotation",
    "target":"Foo.Child"
  },
  {
    "class":"firrtl.transforms.DontTouchAnnotation",
    "target":"~Foo|Child>_sum"
  }
]]
  module Child :
    input in : UInt<8>
    output out : UInt<8>

    node _sum_T = add(in, UInt<1>(0h1))
    node _sum = tail(_sum_T, 1)
    connect out, _sum

  public module Foo :
    input in : UInt<8>
    output out : UInt<8>

    inst c of Child
    connect c.in, in
    connect out, c.out

when compiled with firtool, gives:

// Generated by CIRCT firtool-1.78.1
module Foo(
  input  [7:0] in,
  output [7:0] out
);

  wire [7:0] c__sum = in + 8'h1;
  assign out = c__sum;
endmodule

_sum when inlined is mangled to be prefixed with the instance name, c, and so becomes c__sum. It would be better if it was mangled to _c_sum.

youngar avatar Jul 26 '24 06:07 youngar