Skip to content

[FIRRTL][Inliner] Public + Inline wrong output (some contexts lose annotation) #10684

@dtzSiFive

Description

@dtzSiFive

Consider:

firrtl.circuit "Parent" {
  hw.hierpath private @nla [@Grandchild::@ggc_sym, @GreatGrandchild::@target]

  firrtl.module @Parent() {
    firrtl.instance child sym @child_sym @Child()
  }

  firrtl.module @Child() attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} {
    firrtl.instance gc sym @gc_sym @Grandchild()
  }

  firrtl.module @Grandchild() attributes {annotations = [{class = "firrtl.passes.InlineAnnotation"}]} {
    firrtl.instance ggc sym @ggc_sym @GreatGrandchild()
  }

  firrtl.module @GreatGrandchild() {
    %w = firrtl.wire sym @target {annotations = [{circt.nonlocal = @nla, class = "test"}]} : !firrtl.uint<1>
  }
}

Notes:
All modules are public.
The NLA on the wire should apply in all instantiation contexts. Therefore in the output it should also apply in all contexts.

Presently we produce this with circt-opt --firrtl-inliner:

firrtl.circuit "Parent" {
  hw.hierpath private @nla [@Child::@ggc_sym, @GreatGrandchild::@target]
  firrtl.module @Parent() {
    %0 = dbg.scope "child", "Child"
    %1 = dbg.scope "gc", "Grandchild" scope %0
    firrtl.instance child_gc_ggc sym @ggc_sym @GreatGrandchild()
  }
  firrtl.module @Child() {
    firrtl.instance gc_ggc sym @ggc_sym @GreatGrandchild()
  }
  firrtl.module @Grandchild() {
    firrtl.instance ggc sym @ggc_sym @GreatGrandchild()
  }
  firrtl.module @GreatGrandchild() {
    %w = firrtl.wire sym @target {annotations = [{circt.nonlocal = @nla, class = "test"}]} : !firrtl.uint<1>
  }
}

Note that Parent, Child, and GrandChild all instantiate GreatGrandChild, and the wire should have NLA's including each of these.

It would not be valid to make the annotation local, as GreatGrandChild is public and the annotation should not apply to those instantiation contexts. This is similar to a variant of this where something else instantiates GreatGrandChild within the design, but not part of its NLA.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FIRRTLInvolving the `firrtl` dialectbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions