circt icon indicating copy to clipboard operation
circt copied to clipboard

[FIRRTL] Layers and Analog

Open dtzSiFive opened this issue 1 year ago • 0 comments

Consider:

FIRRTL version 4.0.0

circuit Foo :
  layer L, bind :

  extmodule Bar :
    input a : Analog<1>
  public module Foo :
    input a : Analog<1>

    layerblock L:
      inst b of Bar
      attach(b.a, a)

Presently this fails in the verifier after LowerLayers:

// -----// IR Dump Before LowerLayers (firrtl-lower-layers) //----- //
firrtl.circuit "Foo" {
  firrtl.layer @L bind {
  }
  firrtl.extmodule private @Bar(in a: !firrtl.analog<1>) attributes {convention = #firrtl<convention scalarized>}
  firrtl.module @Foo(in %a: !firrtl.analog<1>) attributes {convention = #firrtl<convention scalarized>} {
    firrtl.layerblock @L {
      %b_a = firrtl.instance b @Bar(in a: !firrtl.analog<1>)
      firrtl.attach %b_a, %a : !firrtl.analog<1>, !firrtl.analog<1>
    }
  }
}

analog-layer.fir:13:7: error: analog types may not be connected
      attach(b.a, a)
      ^
analog-layer.fir:13:7: note: see current operation: "firrtl.matchingconnect"(%0, %arg0) : (!firrtl.analog<1>, !firrtl.analog<1>) -> ()

LowerLayers should diagnose this if unsupported, or learn to emit an appropriate connect operation (attach).

Since attach is bidirectional, it seems like it should not be allowed across layer boundaries for consistency with connect in that direction.

dtzSiFive avatar Sep 30 '24 13:09 dtzSiFive