diff --git a/core/src/main/scala/chisel3/probe/package.scala b/core/src/main/scala/chisel3/probe/package.scala index fc097969623..1f23c886103 100644 --- a/core/src/main/scala/chisel3/probe/package.scala +++ b/core/src/main/scala/chisel3/probe/package.scala @@ -34,8 +34,14 @@ package object probe extends SourceInfoDoc { * @param probeExpr value to initialize the sink to */ def define[T <: Data](sink: T, probeExpr: T)(implicit sourceInfo: SourceInfo): Unit = { - if (!sink.typeEquivalent(probeExpr, false /* we will check more more detailed probe info below */ )) { - Builder.error("Cannot define a probe on a non-equivalent type.") + val typeCheckResult = sink.findFirstTypeMismatch( + probeExpr, + strictTypes = true, + strictWidths = true, + strictProbeInfo = false /* we will check more more detailed probe info below */ + ) + typeCheckResult.foreach { msg => + Builder.error(s"Cannot define a probe on a non-equivalent type.\n$msg") } requireHasProbeTypeModifier(sink, "Expected sink to be a probe.") requireNotChildOfProbe(sink, "Expected sink to be the root of a probe.") diff --git a/src/test/scala/chiselTests/ProbeSpec.scala b/src/test/scala/chiselTests/ProbeSpec.scala index d9aca214a82..fc8bd476632 100644 --- a/src/test/scala/chiselTests/ProbeSpec.scala +++ b/src/test/scala/chiselTests/ProbeSpec.scala @@ -382,6 +382,10 @@ class ProbeSpec extends ChiselFlatSpec with MatchesAndOmits with Utils { ) } exc.getMessage should include("Cannot define a probe on a non-equivalent type.") + exc.getMessage should include( + "Left (ProbeSpec_Anon.p: IO[UInt<4>]) and Right (ProbeSpec_Anon.Node(ProbeSpec_Anon.w: Wire[Bool]): OpResult[Bool]) have different types" + ) + } "Probe of a probe type" should "fail" in {