diff options
| author | chick | 2016-02-10 20:36:47 -0800 |
|---|---|---|
| committer | chick | 2016-02-10 20:36:47 -0800 |
| commit | 7793f9fbcdeb2063961102672a36bc7ec2bda9af (patch) | |
| tree | 52a76cab83deae1a43db59f5810e677cf289fbfe /src/test/scala/chiselTests | |
| parent | c85f9ff1c9ca9286d44a94f4a00aed67f4d916d3 (diff) | |
| parent | a9355ba3784e3c5ae611f096a48b4ee5c78464ad (diff) | |
Merge branch 'chisel_tester_support'
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/TesterDriverSpec.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/TesterDriverSpec.scala b/src/test/scala/chiselTests/TesterDriverSpec.scala new file mode 100644 index 00000000..dfdd07cc --- /dev/null +++ b/src/test/scala/chiselTests/TesterDriverSpec.scala @@ -0,0 +1,44 @@ +// See LICENSE for license details. + +package chiselTests + +import Chisel._ +import Chisel.testers.BasicTester + +/** Extend BasicTester with a simple circuit and finish method. TesterDriver will call the + * finish method after the FinishTester's constructor has completed, which will alter the + * circuit after the constructor has finished. + */ +class FinishTester extends BasicTester { + val test_wire_width = 2 + val test_wire_override_value = 3 + + val counter = Counter(1) + + when(counter.inc()) { + stop() + } + + val test_wire = Wire(UInt(1, width = test_wire_width)) + + // though we just set test_wire to 1, the assert below will pass because + // the finish will change it's value + assert(test_wire === UInt(test_wire_override_value)) + + /** In finish we use last connect semantics to alter the test_wire in the circuit + * with a new value + */ + override def finish(): Unit = { + test_wire := UInt(test_wire_override_value) + } +} + +class TesterDriverSpec extends ChiselFlatSpec { + "TesterDriver calls BasicTester's finish method which" should + "allow modifications of test circuit after the tester's constructor is done" in { + assertTesterPasses { + new FinishTester + } + } +} + |
