diff options
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Assert.scala | 14 | ||||
| -rw-r--r-- | src/main/scala/chisel3/compatibility.scala | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Assert.scala b/chiselFrontend/src/main/scala/chisel3/core/Assert.scala index c4727148..9111a334 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Assert.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Assert.scala @@ -71,3 +71,17 @@ object assert { // scalastyle:ignore object.name Predef.assert(cond, "") } } + +object stop { // scalastyle:ignore object.name + /** Terminate execution with a failure code. */ + def apply(code: Int)(implicit sourceInfo: SourceInfo): Unit = { + when (!Builder.dynamicContext.currentModule.get.reset) { + pushCommand(Stop(sourceInfo, Node(Builder.dynamicContext.currentModule.get.clock), code)) + } + } + + /** Terminate execution, indicating success. */ + def apply()(implicit sourceInfo: SourceInfo): Unit = { + stop(0) + } +} diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala index 139e9431..c0e933e0 100644 --- a/src/main/scala/chisel3/compatibility.scala +++ b/src/main/scala/chisel3/compatibility.scala @@ -22,6 +22,7 @@ package object Chisel { type Bundle = chisel3.core.Bundle val assert = chisel3.core.assert + val stop = chisel3.core.stop type Element = chisel3.core.Element type Bits = chisel3.core.Bits |
