Search code examples
scalaautomated-testschiselverilator

Dynamic test harness in chisel 3


We are implementing a processor in Chisel and have many very tricky test cases. For elements that have a lot of state, we want to generate long sequences of test vectors on the fly, and calculate the correct response on the fly as well. In Chisel 3 it appears that the only way to do this is to hack it, using Java introspection, to connect the scala code to a C++ test harness, and the generate the stimulus vectors and correct responses in the C++ code.

Not very clean. Is there any way to stay within the Scala framework and write dynamic tests in Scala code? So far the issue has been connecting the Scala to the C++ that is generated by Verilator. Is there a clean way to cause the Verilator generated C++ simulator to interact with Scala/Chisel test harness code that generates stimulus vectors and tests responses on the fly?

Thanks


Solution

  • Check out the Chisel Testers https://github.com/ucb-bar/chisel-testers. They provide a Verilator backend that will drive the Verilator C++ simulator for you from Scala. The Chisel Tutorials (https://github.com/ucb-bar/chisel-tutorial) use the Chisel Testers so can provide some simple examples.

    In particular, the AdvTester is the most powerful methodology in chisel-testers. You can see some uses in the tests for chisel-testers: https://github.com/ucb-bar/chisel-testers/blob/master/src/test/scala/examples/AdvTesterSpec.scala and https://github.com/ucb-bar/chisel-testers/blob/master/src/test/scala/examples/DecoupledAdvTester.scala