blob: 1c2d390d7f6840c504dde2f81c78bda6b4bd2658 (
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
26
27
28
29
30
|
// See LICENSE for license details.
package chiselTests
import org.scalatest._
import chisel3._
import chisel3.testers.BasicTester
class StopTester() extends BasicTester {
stop()
}
class StopImmediatelyTester extends BasicTester {
val cycle = Reg(init = 0.asUInt(4.W))
cycle := cycle + 1.U
when (cycle === 4.U) {
stop()
}
assert(cycle =/= 5.U, "Simulation did not exit upon executing stop()")
}
class StopSpec extends ChiselFlatSpec {
"stop()" should "stop and succeed the testbench" in {
assertTesterPasses { new StopTester }
}
it should "end the simulation immediately" in {
assertTesterPasses { new StopImmediatelyTester }
}
}
|