diff options
| author | Richard Lin | 2016-02-22 12:54:40 -0800 |
|---|---|---|
| committer | Richard Lin | 2016-02-22 12:54:40 -0800 |
| commit | 9bf707687777cc952287219c86e817e0f6a698ae (patch) | |
| tree | 39d48f546293a02f79bd54234c673b4f830913eb /src/main | |
| parent | c85f9ff1c9ca9286d44a94f4a00aed67f4d916d3 (diff) | |
| parent | d87db04ff7a5cb12443529861558f1850448170b (diff) | |
Merge pull request #99 from ucb-bar/chisel_tester_support
Chisel tester support
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/Chisel/testers/BasicTester.scala | 7 | ||||
| -rw-r--r-- | src/main/scala/Chisel/testers/TesterDriver.scala | 13 |
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 + } + } } |
