From c3b06d773f1fabd2519d6c705d68381d13f1c07f Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 23 Aug 2022 17:20:12 -0700 Subject: Backport .toTarget deprecation warning information (3.5.x) (#2697) --- src/test/scala/chiselTests/RecordSpec.scala | 2 +- src/test/scala/chiselTests/ToTargetSpec.scala | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/test/scala/chiselTests/RecordSpec.scala b/src/test/scala/chiselTests/RecordSpec.scala index 5aa872b0..718c1acb 100644 --- a/src/test/scala/chiselTests/RecordSpec.scala +++ b/src/test/scala/chiselTests/RecordSpec.scala @@ -228,7 +228,7 @@ class RecordSpec extends ChiselFlatSpec with RecordSpecUtils with Utils { var m: SingleElementRecordModule = null ChiselStage.elaborate { m = new SingleElementRecordModule; m } val (log, q) = grabLog(m.r.toTarget) - log should include(".toTarget of non-hardware Data is deprecated.") + log should include(".toTarget of non-hardware Data is deprecated") assert(q.toString == "~SingleElementRecordModule|SingleElementRecordModule>r") } diff --git a/src/test/scala/chiselTests/ToTargetSpec.scala b/src/test/scala/chiselTests/ToTargetSpec.scala index dc4ec448..de46cdcb 100644 --- a/src/test/scala/chiselTests/ToTargetSpec.scala +++ b/src/test/scala/chiselTests/ToTargetSpec.scala @@ -49,4 +49,21 @@ class ToTargetSpec extends ChiselFlatSpec with Utils { val q = m.q.toTarget.toString assert(q == s"~$mn|Queue") } + + it should "warn on non-hardware types and provide information" in { + class Example extends Module { + val tpe = UInt(8.W) + + val in = IO(Input(tpe)) + val out = IO(Output(tpe)) + out := in + } + + var e: Example = null + chisel3.stage.ChiselStage.elaborate { e = new Example; e } + val (log, foo) = grabLog(e.tpe.toTarget) + log should include( + "Accessing the .instanceName or .toTarget of non-hardware Data is deprecated: 'tpe', in module 'Example'" + ) + } } -- cgit v1.2.3