From 64e27e0eeadc2f2fcee65c437a72a5a6d81db8f0 Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Mon, 9 Sep 2024 17:40:55 -0700 Subject: [PATCH] Add tests for https://github.com/chipsalliance/chisel/issues/4388 --- src/test/scala/chiselTests/ProbeSpec.scala | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/scala/chiselTests/ProbeSpec.scala b/src/test/scala/chiselTests/ProbeSpec.scala index a0f2763d99b..f30e18df4ab 100644 --- a/src/test/scala/chiselTests/ProbeSpec.scala +++ b/src/test/scala/chiselTests/ProbeSpec.scala @@ -743,4 +743,43 @@ class ProbeSpec extends ChiselFlatSpec with MatchesAndOmits with Utils { } ChiselStage.emitCHIRRTL(new TestMod) } + + "Probes of Bool()" should "fail to be driven with 0.U.asTypeOf(...)" in { + class TestMod extends RawModule { + val a = IO(Output(Probe(Bool()))) + a :#= 0.U.asTypeOf(a) + } + val exc = intercept[chisel3.ChiselException] { + ChiselStage.emitCHIRRTL(new TestMod, Array("--throw-on-first-error")) + } + exc.getMessage should include( + "Cannot create Const of a Probe." + ) // current message is: mismatched probe/non-probe types in TestMod.a") + } + "Probes of Aggregates" should "fail to be driven with 0.U.asTypeOf(...)" in { + class BundleWithABool extends Bundle { + val foo = Bool() + } + class TestMod extends RawModule { + val a = IO(Output(Probe(new BundleWithABool()))) + a :#= 0.U.asTypeOf(a) + } + val exc = intercept[chisel3.ChiselException] { + ChiselStage.emitCHIRRTL(new TestMod, Array("--throw-on-first-error")) + } + exc.getMessage should include("Cannot create Const of a Probe.") + } + "Bundles of Probes" should "fail to be driven with 0.U.asTypeOf(...)" in { + class BundleWithAProbe extends Bundle { + val tap = Probe(Bool()) + } + class TestMod extends RawModule { + val a = IO(Output(new BundleWithAProbe())) + a :#= 0.U.asTypeOf(a) + } + val exc = intercept[chisel3.ChiselException] { + ChiselStage.emitCHIRRTL(new TestMod, Array("--throw-on-first-error")) + } + exc.getMessage should include("Cannot create Const of a Probe.") // currently just succeeds! + } }