Skip to content

Commit

Permalink
Add tests for #4388
Browse files Browse the repository at this point in the history
  • Loading branch information
mwachs5 committed Sep 10, 2024
1 parent cf42ac7 commit 64e27e0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/test/scala/chiselTests/ProbeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
}

0 comments on commit 64e27e0

Please sign in to comment.