summaryrefslogtreecommitdiff
path: root/src/test/scala/cookbook/CookbookSpec.scala
blob: 6ecea446042d26c02e45f0faac3bd8215f365e52 (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(true.B, length)
  when (done) { stop() }
}

abstract class CookbookSpec extends ChiselFlatSpec