Add IntermediateBackend for generating verilog testbenches #138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a rough stab at getting the basic functionality to generate a (in my case verilog) testbench via the chisel testers API.
The thing I wanted to do was to run the jtag chisel tests I had written on the top level craft2-chip, which is not easy to do with the chisel testers API for many reasons (makefile-based build system doing some magic with external IP, wanting to use ncsim, and more). What I wanted was something like @shunshou's nice tester mixin that dumps a verilog version of the test you just ran, but it wasn't convenient to use because of the tests I was using from @ducky64 using a different testing API.
I ended up adding a backend that generates an intermediate representation of the test you just ran and then (in a separate repo) an application specific "compiler" (really just a handlebars template based on Angie's VerilogTbDump) for the IR to a verilog testbench appropriate for my application. The IR is really simple- poke, expect, step, and reset. I want to plant my flag on the names birrtl or tirrtl (behavioral or testing intermediate representation...) on the off chance that this becomes a thing
Do you guys think this idea has merit? It sure was handy for me. I was thinking of adding new backends that extend Verilator with Intermediate or VCS with Intermediate that runs the test and then adds the event to the queue (also, peeks would not throw an exception and would add expects to the event queue). I'm not necessarily a fan of the way I've written the code- maybe it would be better to have an option that every backend respects rather than new backends that work the same but add this new functionality. In that case I'd like to have a DoNothing backend for situations where for whatever reason it is hard to get a chisel testers backend running your circuit.
Sorry for writing a book!