summaryrefslogtreecommitdiff
path: root/src/test/scala/cookbook/CookbookSpec.scala
blob: 7d6c9726fe1380952117985dd32a1a1b51ba655f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: Apache-2.0

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!")

  val (cycle, done) = Counter(true.B, length + 1) // + 1 cycle because done is actually wrap
  when(done) { stop() }
}

abstract class CookbookSpec extends ChiselFlatSpec