diff options
| author | chick | 2016-02-10 13:49:13 -0800 |
|---|---|---|
| committer | chick | 2016-02-10 13:49:13 -0800 |
| commit | c9d9a313b39fa1d43f794c85ec31d8deb847dc9c (patch) | |
| tree | 99283b42ee9b7f13a1680b6ce8861b504e245e9f /src/test | |
| parent | 82da362037a227a1c16eb56ead69f3f73cea6c4f (diff) | |
The TesterDriverSpec has been made stronger by altering circuit in finish method
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/TesterDriverSpec.scala | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/src/test/scala/chiselTests/TesterDriverSpec.scala b/src/test/scala/chiselTests/TesterDriverSpec.scala index bfe8602a..d7cb0305 100644 --- a/src/test/scala/chiselTests/TesterDriverSpec.scala +++ b/src/test/scala/chiselTests/TesterDriverSpec.scala @@ -5,40 +5,52 @@ package chiselTests import Chisel._ import Chisel.testers.BasicTester -/** Extends basic tester with a finish method. - * +/** Extend basic tester with a finish method. TesterDriver will call the + * finish method after the Tester's constructor has completed + * - + * In this example we use last connect semantics to alter the circuit after + * the constructor has completed */ class FinishTester extends BasicTester { - var finish_was_run = false + val test_wire_width = 2 + val test_wire_override_value = 3 + + val test_wire = Wire(UInt(1, width = test_wire_width)) + + test_wire := UInt(1, width = test_wire_width) + // though we just test_wire to 1, the assert below will be true because + // the finish will override it + assert(test_wire === UInt(test_wire_override_value)) override def finish(): Unit = { - finish_was_run = true + test_wire := UInt(test_wire_override_value, width = test_wire_width) } } -class TesterDriverSpec extends ChiselFlatSpec { - class DummyCircuit extends Module { - val io = new Bundle { - val in = UInt(INPUT, width = 1) - val out = UInt(OUTPUT, width = 1) - } - - io.out := io.in +class DummyCircuit extends Module { + val io = new Bundle { + val in = UInt(INPUT, width = 1) + val out = UInt(OUTPUT, width = 1) } - class DummyTester extends FinishTester { - val dut = new DummyCircuit + io.out := io.in +} + +class DummyTester extends FinishTester { + val dut = Module(new DummyCircuit) - dut.io.in := UInt(1) - Chisel.assert(dut.io.out === UInt(1)) + dut.io.in := UInt(1) + Chisel.assert(dut.io.out === UInt(1)) - "Extending BasicTester" should "allow developer to have finish method run automatically" in { - assert(finish_was_run) - } - } + stop() +} - runTester { - new DummyTester +class TesterDriverSpec extends ChiselFlatSpec { + "TesterDriver calls a BasicTester subclass's finish method which" should + "allow modifications of test circuit after tester constructor is done" in { + assertTesterPasses { + new DummyTester + } } } |
