I took chisel-template
and tried using its infrastructure to run the basic example of the BlackBox, both the Chisel dummy part and the Verilog module part taken from here and here.
I've copied over the existing folder/file structure and went into those files and replaced GCD
and gcd
by TryBlackBox
and tryblackbox
. I've also added the line: import chisel3.util.HasBlackBoxResource
. Finally, I've positioned the TryBlackBox.v
file into src/main/resources/tryblackbox/
path.
When I try test:runMain tryblackbox.TryBlackBoxMain
from within sbt
I get 16 errors, all of them complaining about type mismatch, something like:
[error] /home/apaj/TryBlackBox/src/test/scala/tryblackbox/TryBlackBoxUnitTest.scala:79:60: type mismatch;
[error] found : () => tryblackbox.TryBlackBox
[error] required: () => T
[error] iotesters.Driver.execute(Array("--fint-write-vcd"), () => new TryBlackBox) {
I've uploaded my project to this repo:
https://github.com/apaj/TryBlackBox.git
I would appreciate any possible help in troubleshooting...
Thank you.
You are on the right track but there are several things biting you right now.
A black box cannot be the top circuit, it must be referenced as an instance in a regular chisel module. The error you are getting is because TryBlackBox is a BlackBox
and not a sub-class of a regular chisel Module.
Eliminate the object TryBlackBoxRepl
the repl is part of the firrtl interpreter and while it does have a black box capability of it's own, it requires a Scala implementation of the black box instead of verilog. I'd recommend taking this on later. There are examples of Scala black boxes in dsptools, firrtl-interpreter and treadle when you are ready.
You must use verilator backend (or other verilog based backend), instead of the interpreter. You must specifically invoke using verilator manually by setting the args like
object TryBlackBoxMain extends App {
iotesters.Driver.execute(
Array("--backend-name", "verilator"),
() => new TryBlackBoxTop
) {
c => new TryBlackBoxUnitTester(c)
}
}
Note, in the code above I created a separate top module
TryBlackBoxTop
which is where you would instantiateTryBlackBox
setResource("/tryblackbox/tryMe.v")
the file name of your resource should be resource/tryblackbox/tryMe.v
. Probably a good idea to rename some of this a little bit also, using TryBlackBox too many places is probably going to get you in trouble.