Running Chiseltests
This is a brief guide on how to run Chiseltests found on some Chisel projects.
Structure
Chiseltests are located in a fixed location:
src/test/scala.The file name ends with
Spec.scalaand test class name withSpec
Running the test
Chiseltests are run with sbt. For example, to run DataCacheSpec under acorechip, you should navigate to Entities/acorechip/chisel and run:
sbt 'testOnly acorechip.DataCacheSpec'
Debugging
In a Chiseltest, you can print with println. However, this is not very helpful for debugging.
Best way to debug is to check waveforms. They don’t get generated by default. You need to add .withAnnotations(Seq(WriteVcdAnnotation)) after the test wrapper. For example:
test(new DataCache(memory_map, config)).withAnnotations(Seq(WriteVcdAnnotation)) { c =>
...
After running the test, it will generate a <className>.vcd file under test_run_dir/test_name/. You can open it with GTKWave:
gtkwave test_run_dir/test_name/className.vcd
You can add traces to the waveform window from the panel on the left.