summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel
diff options
context:
space:
mode:
authorchick2016-02-09 11:24:08 -0800
committerchick2016-02-09 11:24:08 -0800
commitd1611f81badf54aaf460ba37f01dc98c4005d82a (patch)
tree19249e3bb9f006b5bb334fff3b8a3fd90e72fe83 /src/main/scala/Chisel
parentc2db03d0a752e084c1ca452ee477c88d930d0bc6 (diff)
Added support for finish method of BasicTester to be overridden in a subclass which allows tester to have clean up and other construction code executed after a user code executed during constructor of that subclass
Diffstat (limited to 'src/main/scala/Chisel')
-rw-r--r--src/main/scala/Chisel/testers/BasicTester.scala2
-rw-r--r--src/main/scala/Chisel/testers/TesterDriver.scala15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/testers/BasicTester.scala b/src/main/scala/Chisel/testers/BasicTester.scala
index 6807a30e..98033486 100644
--- a/src/main/scala/Chisel/testers/BasicTester.scala
+++ b/src/main/scala/Chisel/testers/BasicTester.scala
@@ -24,4 +24,6 @@ class BasicTester extends Module {
pushCommand(Stop(Node(clock), 0))
}
}
+
+ def finish(): Unit = {}
}
diff --git a/src/main/scala/Chisel/testers/TesterDriver.scala b/src/main/scala/Chisel/testers/TesterDriver.scala
index b25b160b..2b7019c9 100644
--- a/src/main/scala/Chisel/testers/TesterDriver.scala
+++ b/src/main/scala/Chisel/testers/TesterDriver.scala
@@ -23,7 +23,7 @@ object TesterDriver extends BackendCompilationUtilities {
* frontend, and which can be turned into executables with assertions. */
def execute(t: () => BasicTester, additionalVResources: Seq[String] = Seq()): Boolean = {
// Invoke the chisel compiler to get the circuit's IR
- val circuit = Driver.elaborate(t)
+ val circuit = Driver.elaborate(finishWrapper(t))
// Set up a bunch of file handlers based on a random temp filename,
// plus the quirks of Verilator's naming conventions
@@ -55,4 +55,17 @@ object TesterDriver extends BackendCompilationUtilities {
false
}
}
+ /*
+ * provides a hook for testers to implement necessary control logic for tests after the
+ * implementation of the users test definition has been completed.
+ * typically the finish method will inspect the users circuit and connect the tester
+ * to the device under test
+ */
+ def finishWrapper(test: () => BasicTester): () => BasicTester = {
+ () => {
+ val tester = test()
+ tester.finish()
+ tester
+ }
+ }
}