summaryrefslogtreecommitdiff
path: root/src/test/scala/cookbook/CookbookSpec.scala
diff options
context:
space:
mode:
authorjackkoenig2016-09-20 16:12:59 -0700
committerjackkoenig2016-09-21 20:18:06 -0700
commit7e5aef460e089b3dfd53ddd181f9384cc25145d7 (patch)
treed4642495686b50476d6569ebbc522d2d10923a9e /src/test/scala/cookbook/CookbookSpec.scala
parentb18e98ba2d058c7dd24f96f005486b70c856aeca (diff)
Add Cookbook tests
These tests are intended to be the examples in the Chisel3 Wiki Cookbook.
Diffstat (limited to 'src/test/scala/cookbook/CookbookSpec.scala')
-rw-r--r--src/test/scala/cookbook/CookbookSpec.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/scala/cookbook/CookbookSpec.scala b/src/test/scala/cookbook/CookbookSpec.scala
new file mode 100644
index 00000000..b244f3cf
--- /dev/null
+++ b/src/test/scala/cookbook/CookbookSpec.scala
@@ -0,0 +1,25 @@
+// See LICENSE for license details.
+
+package cookbook
+
+import chisel3._
+import chisel3.util._
+import chisel3.testers.BasicTester
+
+import chiselTests.ChiselFlatSpec
+
+/** Tester for concise cookbook tests
+ *
+ * Provides a length of test after which the test will pass
+ */
+abstract class CookbookTester(length: Int) extends BasicTester {
+ require(length >= 0, "Simulation length must be non-negative!")
+
+ // No IO allowed, cookbook tests must be self-contained
+ override final val io = new Bundle { }
+
+ val (cycle, done) = Counter(Bool(true), length)
+ when (done) { stop() }
+}
+
+abstract class CookbookSpec extends ChiselFlatSpec