summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Laeufer2021-04-29 11:52:20 -0700
committerGitHub2021-04-29 18:52:20 +0000
commit4d8fed00225d15221cf32177ea9147b20d0b91f7 (patch)
treeb2696fe705f118865733bdd4e7e281a57208fae6
parent992a0a69e7a064abfeef737fcfff22cb96ec8b65 (diff)
verification: guard statements with module reset (#1891)
-rw-r--r--core/src/main/scala/chisel3/experimental/verification/package.scala24
-rw-r--r--src/test/scala/chiselTests/experimental/verification/VerificationSpec.scala11
2 files changed, 22 insertions, 13 deletions
diff --git a/core/src/main/scala/chisel3/experimental/verification/package.scala b/core/src/main/scala/chisel3/experimental/verification/package.scala
index 5c71bd5f..816299a3 100644
--- a/core/src/main/scala/chisel3/experimental/verification/package.scala
+++ b/core/src/main/scala/chisel3/experimental/verification/package.scala
@@ -2,9 +2,8 @@
package chisel3.experimental
-import chisel3.{Bool, CompileOptions}
+import chisel3._
import chisel3.internal.Builder
-import chisel3.internal.Builder.pushCommand
import chisel3.internal.firrtl.{Formal, Verification}
import chisel3.internal.sourceinfo.SourceInfo
@@ -13,9 +12,10 @@ package object verification {
def apply(predicate: Bool, msg: String = "")(
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions): Unit = {
- val clock = Builder.forcedClock
- pushCommand(Verification(Formal.Assert, sourceInfo, clock.ref,
- predicate.ref, msg))
+ when (!Module.reset.asBool) {
+ val clock = Module.clock
+ Builder.pushCommand(Verification(Formal.Assert, sourceInfo, clock.ref, predicate.ref, msg))
+ }
}
}
@@ -23,9 +23,10 @@ package object verification {
def apply(predicate: Bool, msg: String = "")(
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions): Unit = {
- val clock = Builder.forcedClock
- pushCommand(Verification(Formal.Assume, sourceInfo, clock.ref,
- predicate.ref, msg))
+ when (!Module.reset.asBool) {
+ val clock = Module.clock
+ Builder.pushCommand(Verification(Formal.Assume, sourceInfo, clock.ref, predicate.ref, msg))
+ }
}
}
@@ -33,9 +34,10 @@ package object verification {
def apply(predicate: Bool, msg: String = "")(
implicit sourceInfo: SourceInfo,
compileOptions: CompileOptions): Unit = {
- val clock = Builder.forcedClock
- pushCommand(Verification(Formal.Cover, sourceInfo, clock.ref,
- predicate.ref, msg))
+ val clock = Module.clock
+ when (!Module.reset.asBool) {
+ Builder.pushCommand(Verification(Formal.Cover, sourceInfo, clock.ref, predicate.ref, msg))
+ }
}
}
}
diff --git a/src/test/scala/chiselTests/experimental/verification/VerificationSpec.scala b/src/test/scala/chiselTests/experimental/verification/VerificationSpec.scala
index fe642156..86d6418c 100644
--- a/src/test/scala/chiselTests/experimental/verification/VerificationSpec.scala
+++ b/src/test/scala/chiselTests/experimental/verification/VerificationSpec.scala
@@ -30,8 +30,15 @@ class VerificationSpec extends ChiselPropSpec {
property("basic equality check should work") {
val fir = ChiselStage.emitChirrtl(new VerificationModule)
val lines = fir.split("\n").map(_.trim)
+
+ // reset guard around the verification statement
+ assertContains(lines, "when _T_2 : @[VerificationSpec.scala 16:15]")
assertContains(lines, "cover(clock, _T, UInt<1>(\"h1\"), \"\") @[VerificationSpec.scala 16:15]")
- assertContains(lines, "assume(clock, _T_2, UInt<1>(\"h1\"), \"\") @[VerificationSpec.scala 18:18]")
- assertContains(lines, "assert(clock, _T_3, UInt<1>(\"h1\"), \"\") @[VerificationSpec.scala 19:18]")
+
+ assertContains(lines, "when _T_6 : @[VerificationSpec.scala 18:18]")
+ assertContains(lines, "assume(clock, _T_4, UInt<1>(\"h1\"), \"\") @[VerificationSpec.scala 18:18]")
+
+ assertContains(lines, "when _T_9 : @[VerificationSpec.scala 19:18]")
+ assertContains(lines, "assert(clock, _T_7, UInt<1>(\"h1\"), \"\") @[VerificationSpec.scala 19:18]")
}
}