Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more information when probe types don't match #4269

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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.")
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 @@ -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 {
Expand Down