Skip to content

[FIRRTL] Expand Whens Doesn't Check firrtl.wire initialization of domain type #10248

@seldridge

Description

@seldridge

The following should error, but it doesn't:

module {
  firrtl.circuit "UndrivenWireSubfield" {
    firrtl.domain @ClockDomain [#firrtl.domain.field<"source", !firrtl.string>]
    firrtl.module @UndrivenWireSubfield() {
      %0 = firrtl.string ""
      %wire = firrtl.wire : !firrtl.domain<@ClockDomain(source: !firrtl.string)>
      %1 = firrtl.domain.subfield %wire[source] : !firrtl.domain<@ClockDomain(source: !firrtl.string)>
      %2 = firrtl.prop.eq %0, %1 : !firrtl.string
      firrtl.property_assert %2, "hello" : !firrtl.bool
    }
  }
}

Currently, this will error out in LowerClasses if passed direclty.

# circt-opt Foo.mlir -pass-pipeline='builtin.module(firrtl.circuit(any(firrtl-expand-whens)))'
module {
  firrtl.circuit "UndrivenWireSubfield" {
    firrtl.domain @ClockDomain [#firrtl.domain.field<"source", !firrtl.string>]
    firrtl.module @UndrivenWireSubfield() {
      %0 = firrtl.string ""
      %wire = firrtl.wire : !firrtl.domain<@ClockDomain(source: !firrtl.string)>
      %1 = firrtl.domain.subfield %wire[source] : !firrtl.domain<@ClockDomain(source: !firrtl.string)>
      %2 = firrtl.prop.eq %0, %1 : !firrtl.string
      firrtl.property_assert %2, "hello" : !firrtl.bool
    }
  }
}
# circt-opt Foo.mlir -pass-pipeline='builtin.module(firrtl.circuit(firrtl-lower-domains,firrtl-lower-classes))'
Foo.mlir:12:13: error: uninitialized input port "source_in"
    %wire = firrtl.wire : !firrtl.domain<@ClockDomain(source: !firrtl.string)>
            ^

I had originally thought that LowerDomains should unknown-initialize this. However, that doesn't make sense as there should be a precondition that everything is driven.

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