diff options
| -rw-r--r-- | src/main/scala/Chisel/testers/BasicTester.scala | 5 | ||||
| -rw-r--r-- | src/test/scala/chiselTests/TesterDriverSpec.scala | 32 |
2 files changed, 23 insertions, 14 deletions
diff --git a/src/main/scala/Chisel/testers/BasicTester.scala b/src/main/scala/Chisel/testers/BasicTester.scala index 98033486..8f4d60f4 100644 --- a/src/main/scala/Chisel/testers/BasicTester.scala +++ b/src/main/scala/Chisel/testers/BasicTester.scala @@ -25,5 +25,10 @@ class BasicTester extends Module { } } + /** Called this class or a subclass's constructor has finished giving + * developers of chisel testers a post construction hook. + * For example, a decoupled tester subclassing BasicTester could override finish in order to + * add flow control logic around loading the device under test's input io from a Vec of values + */ def finish(): Unit = {} } diff --git a/src/test/scala/chiselTests/TesterDriverSpec.scala b/src/test/scala/chiselTests/TesterDriverSpec.scala index 6271d382..bfe8602a 100644 --- a/src/test/scala/chiselTests/TesterDriverSpec.scala +++ b/src/test/scala/chiselTests/TesterDriverSpec.scala @@ -2,39 +2,43 @@ package chiselTests -/** - * Created by chick on 2/9/16. - */ import Chisel._ import Chisel.testers.BasicTester -/** - * Created by chick on 2/8/16. +/** Extends basic tester with a finish method. + * */ class FinishTester extends BasicTester { var finish_was_run = false override def finish(): Unit = { - finish_was_run = true + finish_was_run = true } } class TesterDriverSpec extends ChiselFlatSpec { class DummyCircuit extends Module { val io = new Bundle { - val in = Bool(INPUT) - val out = Bool(OUTPUT) + val in = UInt(INPUT, width = 1) + val out = UInt(OUTPUT, width = 1) } + + io.out := io.in } - runTester { - new FinishTester { - val dut = new DummyCircuit + class DummyTester extends FinishTester { + val dut = new DummyCircuit + + 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) - } + "Extending BasicTester" should "allow developer to have finish method run automatically" in { + assert(finish_was_run) } } + + runTester { + new DummyTester + } } |
