summaryrefslogtreecommitdiff
path: root/src/test/scala/cookbook/CookbookSpec.scala
blob: b244f3cf95472ecf942b7c11320da37b07e1817d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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