summaryrefslogtreecommitdiff
path: root/src/main/scala
diff options
context:
space:
mode:
authorchick2016-02-10 20:36:47 -0800
committerchick2016-02-10 20:36:47 -0800
commit7793f9fbcdeb2063961102672a36bc7ec2bda9af (patch)
tree52a76cab83deae1a43db59f5810e677cf289fbfe /src/main/scala
parentc85f9ff1c9ca9286d44a94f4a00aed67f4d916d3 (diff)
parenta9355ba3784e3c5ae611f096a48b4ee5c78464ad (diff)
Merge branch 'chisel_tester_support'
Diffstat (limited to 'src/main/scala')
-rw-r--r--src/main/scala/Chisel/testers/BasicTester.scala7
-rw-r--r--src/main/scala/Chisel/testers/TesterDriver.scala13
2 files changed, 19 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/testers/BasicTester.scala b/src/main/scala/Chisel/testers/BasicTester.scala
index 6807a30e..d3e9e7c8 100644
--- a/src/main/scala/Chisel/testers/BasicTester.scala
+++ b/src/main/scala/Chisel/testers/BasicTester.scala
@@ -24,4 +24,11 @@ class BasicTester extends Module {
pushCommand(Stop(Node(clock), 0))
}
}
+
+ /** The finish method provides a hook that subclasses of BasicTester can use to
+ * alter a circuit after their constructor has been called.
+ * For example, a specialized tester subclassing BasicTester could override finish in order to
+ * add flow control logic for a decoupled io port of a device under test
+ */
+ def finish(): Unit = {}
}
diff --git a/src/main/scala/Chisel/testers/TesterDriver.scala b/src/main/scala/Chisel/testers/TesterDriver.scala
index b25b160b..4547f48f 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,15 @@ object TesterDriver extends BackendCompilationUtilities {
false
}
}
+ /**
+ * Calls the finish method of an BasicTester or a class that extends it.
+ * The finish method is a hook for code that augments the circuit built in the constructor.
+ */
+ def finishWrapper(test: () => BasicTester): () => BasicTester = {
+ () => {
+ val tester = test()
+ tester.finish()
+ tester
+ }
+ }
}