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

Dedup causes extra instances to be inlined #2498

Open
3 of 5 tasks
youngar opened this issue Mar 18, 2022 · 0 comments
Open
3 of 5 tasks

Dedup causes extra instances to be inlined #2498

youngar opened this issue Mar 18, 2022 · 0 comments

Comments

@youngar
Copy link

youngar commented Mar 18, 2022

Checklist

  • Did you specify the current behavior?
  • Did you specify the expected behavior?
  • Did you provide a code example showing the problem?
  • Did you describe your environment?
  • Did you specify relevant external information?

What is the current behavior?

Deduplicating two modules where one has InlineAnnotation causes both modules to be inlined. I think this is a pretty well known issue with "sticky annotations". I opened a similar issue for the CIRCT FIRRTL compiler here: llvm/circt#2790

~/wsp/firrtl/utils/bin/firrtl --inline Top.Bar -i inline.fir -o inline

circuit Top:
  module Foo:
    input i : UInt<8>
    output o : UInt<8>
    wire f : UInt<8>
    f <= i
    o <= f

  module Bar:
    input i : UInt<8>
    output o : UInt<8>
    wire b : UInt<8>
    b <= i
    o <= b

  module Top:
    input i : UInt<8>
    output o : UInt<8>
    inst foo of Foo
    foo.i <= i
    inst bar of Bar
    bar.i <= i
    o <= xor(foo.o, bar.o)

Creates:

module Top(
 input  [7:0] i,
 output [7:0] o
);
 wire [7:0] foo_i;
 wire [7:0] foo_o;
 wire [7:0] bar_i;
 wire [7:0] bar_o;
 assign foo_o = foo_i;
 assign bar_o = bar_i;
 assign o = foo_o ^ bar_o;
 assign foo_i = i;
 assign bar_i = i;
endmodule

Running with --log-level=trace you can see dedup does not create a non-local annotation:

  {
    "class":"firrtl.passes.InlineAnnotation",
    "target":"Top.Bar"
  },

======== Starting firrtl.transforms.DedupModules ========
[Dedup] Top -> Top
[Dedup] Foo -> Foo
[Dedup] Bar -> Foo

  {
    "class":"firrtl.passes.InlineAnnotation",
    "target":"Top.Foo"
  },

Disabling Dedup with --no-dedup works well

module Foo(
  input  [7:0] i,
  output [7:0] o
);
  assign o = i;
endmodule
module Top(
  input  [7:0] i,
  output [7:0] o
);
  wire [7:0] foo_i;
  wire [7:0] foo_o;
  wire [7:0] bar_i;
  wire [7:0] bar_o;
  Foo foo (
    .i(foo_i),
    .o(foo_o)
  );
  assign bar_o = bar_i;
  assign o = foo_o ^ bar_o;
  assign foo_i = i;
  assign bar_i = i;
endmodule

What is the expected behavior?

I would expect only some instances to be inlined.

Steps to Reproduce

Your environment

  • Chisel Verions:
  • OS:
  • Verilator version:

External Information

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

1 participant