Skip to content

Commit

Permalink
Add more information when probe types don't match (#4269)
Browse files Browse the repository at this point in the history
(cherry picked from commit 029254a)
  • Loading branch information
mwachs5 authored and mergify[bot] committed Jul 10, 2024
1 parent 52746eb commit 9dc1471
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/src/main/scala/chisel3/probe/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,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.")
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/chiselTests/ProbeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ class ProbeSpec extends ChiselFlatSpec 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 {
Expand Down

0 comments on commit 9dc1471

Please sign in to comment.