diff --git a/core/src/main/scala/chisel3/RawModule.scala b/core/src/main/scala/chisel3/RawModule.scala index 7af32391bbf..7795ae96024 100644 --- a/core/src/main/scala/chisel3/RawModule.scala +++ b/core/src/main/scala/chisel3/RawModule.scala @@ -10,6 +10,7 @@ import chisel3.experimental.hierarchy.{InstanceClone, ModuleClone} import chisel3.properties.{DynamicObject, Property, StaticObject} import chisel3.internal.Builder._ import chisel3.internal.firrtl.ir._ +import chisel3.reflect.DataMirror import _root_.firrtl.annotations.{IsModule, ModuleTarget} import scala.collection.immutable.VectorBuilder import scala.collection.mutable.ArrayBuffer @@ -217,6 +218,11 @@ abstract class RawModule extends BaseModule { // For non-probe, directly create Nodes for lhs, skipping visibility check to support BoringUtils.drive. (left, right) match { case (_: Property[_], _: Property[_]) => PropAssign(si, Node(left), Node(right)) + // Use `connect lhs, read(probe(rhs))` if lhs is passive version of rhs. + // This provides solution for this: https://github.com/chipsalliance/chisel/issues/3557 + case (_, _) if !DataMirror.checkAlignmentTypeEquivalence(left, right) && + DataMirror.checkAlignmentTypeEquivalence(left, Output(chiselTypeOf(right))) + => Connect(si, Node(left), ProbeRead(ProbeExpr(Node(right)))) case (_, _) => Connect(si, Node(left), Node(right)) } } diff --git a/src/test/scala/chiselTests/BoringUtilsTapSpec.scala b/src/test/scala/chiselTests/BoringUtilsTapSpec.scala index add2b7a5963..a7ebc01d804 100644 --- a/src/test/scala/chiselTests/BoringUtilsTapSpec.scala +++ b/src/test/scala/chiselTests/BoringUtilsTapSpec.scala @@ -470,13 +470,7 @@ class BoringUtilsTapSpec extends ChiselFlatSpec with ChiselRunners with Utils wi class Foo extends RawModule { val a = WireInit(DecoupledIO(Bool()), DontCare) - val dummyA = Wire(Output(chiselTypeOf(a))) - // FIXME we shouldn't need this intermediate wire - // https://github.com/chipsalliance/chisel/issues/3557 - dummyA :#= a - dontTouch(a) - - val bar = Module(new Bar(dummyA)) + val bar = Module(new Bar(a)) } val chirrtl = circt.stage.ChiselStage.emitCHIRRTL(new Foo, Array("--full-stacktrace")) @@ -486,9 +480,7 @@ class BoringUtilsTapSpec extends ChiselFlatSpec with ChiselRunners with Utils wi "input bore : { ready : UInt<1>, valid : UInt<1>, bits : UInt<1>}", "module Foo :", "wire a : { flip ready : UInt<1>, valid : UInt<1>, bits : UInt<1>}", - // FIXME shouldn't need intermediate wire - "wire dummyA : { ready : UInt<1>, valid : UInt<1>, bits : UInt<1>}", - "connect bar.bore, dummyA" + "connect bar.bore, read(probe(a))" )() // Check that firtool also passes