diff options
Diffstat (limited to 'core/src/main/scala/chisel3/experimental/verification')
| -rw-r--r-- | core/src/main/scala/chisel3/experimental/verification/package.scala | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/core/src/main/scala/chisel3/experimental/verification/package.scala b/core/src/main/scala/chisel3/experimental/verification/package.scala index 816299a3..ca15a5c4 100644 --- a/core/src/main/scala/chisel3/experimental/verification/package.scala +++ b/core/src/main/scala/chisel3/experimental/verification/package.scala @@ -8,36 +8,52 @@ import chisel3.internal.firrtl.{Formal, Verification} import chisel3.internal.sourceinfo.SourceInfo package object verification { + + /** Named class for assertions. */ + final class Assert(val predicate: Bool) extends BaseSim + + /** Named class for assumes. */ + final class Assume(val predicate: Bool) extends BaseSim + + /** Named class for covers. */ + final class Cover(val predicate: Bool) extends BaseSim + object assert { def apply(predicate: Bool, msg: String = "")( implicit sourceInfo: SourceInfo, - compileOptions: CompileOptions): Unit = { + compileOptions: CompileOptions): Assert = { + val a = new Assert(predicate) when (!Module.reset.asBool) { val clock = Module.clock - Builder.pushCommand(Verification(Formal.Assert, sourceInfo, clock.ref, predicate.ref, msg)) + Builder.pushCommand(Verification(a, Formal.Assert, sourceInfo, clock.ref, predicate.ref, msg)) } + a } } object assume { def apply(predicate: Bool, msg: String = "")( implicit sourceInfo: SourceInfo, - compileOptions: CompileOptions): Unit = { + compileOptions: CompileOptions): Assume = { + val a = new Assume(predicate) when (!Module.reset.asBool) { val clock = Module.clock - Builder.pushCommand(Verification(Formal.Assume, sourceInfo, clock.ref, predicate.ref, msg)) + Builder.pushCommand(Verification(a, Formal.Assume, sourceInfo, clock.ref, predicate.ref, msg)) } + a } } object cover { def apply(predicate: Bool, msg: String = "")( implicit sourceInfo: SourceInfo, - compileOptions: CompileOptions): Unit = { + compileOptions: CompileOptions): Cover = { val clock = Module.clock + val c = new Cover(predicate) when (!Module.reset.asBool) { - Builder.pushCommand(Verification(Formal.Cover, sourceInfo, clock.ref, predicate.ref, msg)) + Builder.pushCommand(Verification(c, Formal.Cover, sourceInfo, clock.ref, predicate.ref, msg)) } + c } } } |
