blob: 1634f776a499e39e08e69521c7d65d663214ece6 (
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
|
// SPDX-License-Identifier: Apache-2.0
package chiselTests
import chisel3._
import chisel3.testers.BasicTester
class StopTester() extends BasicTester {
stop()
}
class StopImmediatelyTester extends BasicTester {
val cycle = RegInit(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 }
}
}
|