diff options
| author | Jack Koenig | 2017-01-10 17:18:09 -0800 |
|---|---|---|
| committer | GitHub | 2017-01-10 17:18:09 -0800 |
| commit | 06df5adfd78061aa5ae7567882fb8c42d7260a46 (patch) | |
| tree | 39b070505c95fd89e7a88eb64009d9b1468ef7a3 /src/test | |
| parent | 22b9beefd6ddc358f1573a305ed9b498634c6d23 (diff) | |
Make stop() immediately end simulation for Verilator tests (#434)
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/Harness.scala | 5 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/Stop.scala | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/Harness.scala b/src/test/scala/chiselTests/Harness.scala index 83f60391..8a12cd7b 100644 --- a/src/test/scala/chiselTests/Harness.scala +++ b/src/test/scala/chiselTests/Harness.scala @@ -43,6 +43,11 @@ int main(int argc, char **argv, char **env) { delete top; exit(0); } + +void vl_finish(const char* filename, int linenum, const char* hier) { + Verilated::flushCall(); + exit(0); +} """, ".cpp") _ /** Compiles a C++ emulator from Verilog and returns the path to the diff --git a/src/test/scala/chiselTests/Stop.scala b/src/test/scala/chiselTests/Stop.scala index 4afb077a..1c2d390d 100644 --- a/src/test/scala/chiselTests/Stop.scala +++ b/src/test/scala/chiselTests/Stop.scala @@ -10,8 +10,21 @@ 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 } + } } |
