summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/scala/Chisel/testers/BasicTester.scala10
-rw-r--r--src/test/scala/chiselTests/Stop.scala18
2 files changed, 28 insertions, 0 deletions
diff --git a/src/main/scala/Chisel/testers/BasicTester.scala b/src/main/scala/Chisel/testers/BasicTester.scala
index 398e49e7..fecbe2a9 100644
--- a/src/main/scala/Chisel/testers/BasicTester.scala
+++ b/src/main/scala/Chisel/testers/BasicTester.scala
@@ -3,6 +3,10 @@
package Chisel.testers
import Chisel._
+import internal._
+import internal.Builder.pushCommand
+import firrtl._
+
class BasicTester extends Module {
val io = new Bundle {
val done = Bool()
@@ -12,4 +16,10 @@ class BasicTester extends Module {
io.error := UInt(0)
def popCount(n: Long): Int = n.toBinaryString.count(_=='1')
+
+ /** Ends the test, reporting success.
+ */
+ def stop() {
+ pushCommand(Stop(Node(clock), 0))
+ }
}
diff --git a/src/test/scala/chiselTests/Stop.scala b/src/test/scala/chiselTests/Stop.scala
new file mode 100644
index 00000000..7ce9461b
--- /dev/null
+++ b/src/test/scala/chiselTests/Stop.scala
@@ -0,0 +1,18 @@
+// See LICENSE for license details.
+
+package chiselTests
+
+import org.scalatest._
+import Chisel._
+import Chisel.testers.BasicTester
+
+class StopTester() extends BasicTester {
+ io.done := Bool(false)
+ stop()
+}
+
+class StopSpec extends ChiselFlatSpec {
+ "stop()" should "stop and succeed the testbench" in {
+ assert(execute{ new StopTester })
+ }
+}