From 029254ab49dec829a14cedac56c385b57059733f Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Wed, 10 Jul 2024 11:48:19 -0700 Subject: [PATCH] Add more information when probe types don't match (#4269) --- core/src/main/scala/chisel3/probe/package.scala | 10 ++++++++-- src/test/scala/chiselTests/ProbeSpec.scala | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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 {