I'm trying to print some value when testing my chisel3 design with this testbench code :
package taptempo
import chisel3._
import chisel3.iotesters
import chisel3.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}
import scala.language.reflectiveCalls
class TapTempoUnitTester(t: TapTempo) extends PeekPokeTester(t) {
val tptmp = t
printf("Begin of test\n")
def pushbutton(button: Bool) {
poke(button, 0)
step(1)
print("Push \n")
poke(button, 1)
step(10)
poke(button, 0)
}
val tclk = tptmp.tclk_ns //ns
val tms = 10*tclk
val ts = 1000*tms
for(i <- 0 to 6) {
peek(tptmp.io.button)
pushbutton(tptmp.io.button)
step(1*tms)
}
printf("End of Test\n")
}
class TapTempoTester extends ChiselFlatSpec {
behavior of "TapTempoTester"
it should "launch a simple test" in {
chisel3.iotesters.Driver(() => new TapTempo(100000)) {
c => new TapTempoUnitTester(c)
} should be(true)
}
}
But I've got this error when launching testbench with command:
sbt 'test:runMain taptempo.TapTempoMain'
Error:
[info] Loading project definition from /usr/local/opt/TapTempoChisel/project
[info] Set current project to TapTempo (in build file:/usr/local/opt/TapTempoChisel/)
[info] Compiling 1 Scala source to /usr/local/opt/TapTempoChisel/target/scala-2.11/test-classes...
[info] Running taptempo.TapTempoMain
[info] [0,004] Elaborating design...
[info] [1,018] Done elaborating.
Total FIRRTL Compile Time: 2209,9 ms
Total FIRRTL Compile Time: 530,3 ms
End of dependency graph
Circuit state created
[info] [0,002] SEED 1523361961609
chisel3.internal.ChiselException: Error: No implicit clock and reset.
at chisel3.internal.throwException$.apply(Error.scala:13)
at chisel3.internal.Builder$.forcedClockAndReset(Builder.scala:209)
at chisel3.internal.Builder$.forcedReset(Builder.scala:212)
at chisel3.core.Module$.reset(Module.scala:75)
at chisel3.core.printf$$anonfun$apply$2.apply(Printf.scala:89)
at chisel3.core.printf$$anonfun$apply$2.apply(Printf.scala:89)
at chisel3.core.WhenContext$$anonfun$1.apply(When.scala:72)
at chisel3.core.WhenContext$$anonfun$1.apply(When.scala:72)
at scala.Option.foreach(Option.scala:257)
at chisel3.core.WhenContext.<init>(When.scala:72)
at chisel3.core.when$.apply(When.scala:32)
at chisel3.core.printf$.apply(Printf.scala:89)
at chisel3.core.printf$.apply(Printf.scala:73)
at taptempo.TapTempoUnitTester.<init>(TapTempoUnitTest.scala:12)
at taptempo.TapTempoMain$$anonfun$2.apply(TapTempoMain.scala:26)
at taptempo.TapTempoMain$$anonfun$2.apply(TapTempoMain.scala:26)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply$mcZ$sp(Driver.scala:62)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply(Driver.scala:61)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply(Driver.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply$mcZ$sp(Driver.scala:60)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(Driver.scala:38)
at logger.Logger$$anonfun$makeScope$1.apply(Logger.scala:129)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at logger.Logger$.makeScope(Logger.scala:127)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply$mcZ$sp(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:38)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.iotesters.Driver$.execute(Driver.scala:37)
at chisel3.iotesters.Driver$.execute(Driver.scala:94)
at taptempo.TapTempoMain$.delayedEndpoint$taptempo$TapTempoMain$1(TapTempoMain.scala:25)
at taptempo.TapTempoMain$delayedInit$body.apply(TapTempoMain.scala:24)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at taptempo.TapTempoMain$.main(TapTempoMain.scala:24)
at taptempo.TapTempoMain.main(TapTempoMain.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.Run.invokeMain(Run.scala:67)
at sbt.Run.run0(Run.scala:61)
at sbt.Run.sbt$Run$$execute$1(Run.scala:51)
at sbt.Run$$anonfun$run$1.apply$mcV$sp(Run.scala:55)
at sbt.Run$$anonfun$run$1.apply(Run.scala:55)
at sbt.Run$$anonfun$run$1.apply(Run.scala:55)
at sbt.Logger$$anon$4.apply(Logger.scala:84)
at sbt.TrapExit$App.run(TrapExit.scala:248)
at java.lang.Thread.run(Thread.java:748)
[error] (run-main-0) chisel3.internal.ChiselException: Error: No implicit clock and reset.
chisel3.internal.ChiselException: Error: No implicit clock and reset.
at chisel3.internal.throwException$.apply(Error.scala:13)
at chisel3.internal.Builder$.forcedClockAndReset(Builder.scala:209)
at chisel3.internal.Builder$.forcedReset(Builder.scala:212)
at chisel3.core.Module$.reset(Module.scala:75)
at chisel3.core.printf$$anonfun$apply$2.apply(Printf.scala:89)
at chisel3.core.printf$$anonfun$apply$2.apply(Printf.scala:89)
at chisel3.core.WhenContext$$anonfun$1.apply(When.scala:72)
at chisel3.core.WhenContext$$anonfun$1.apply(When.scala:72)
at scala.Option.foreach(Option.scala:257)
at chisel3.core.WhenContext.<init>(When.scala:72)
at chisel3.core.when$.apply(When.scala:32)
at chisel3.core.printf$.apply(Printf.scala:89)
at chisel3.core.printf$.apply(Printf.scala:73)
at taptempo.TapTempoUnitTester.<init>(TapTempoUnitTest.scala:12)
at taptempo.TapTempoMain$$anonfun$2.apply(TapTempoMain.scala:26)
at taptempo.TapTempoMain$$anonfun$2.apply(TapTempoMain.scala:26)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply$mcZ$sp(Driver.scala:62)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply(Driver.scala:61)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1$$anonfun$apply$mcZ$sp$2.apply(Driver.scala:61)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply$mcZ$sp(Driver.scala:60)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1$$anonfun$apply$mcZ$sp$1.apply(Driver.scala:38)
at logger.Logger$$anonfun$makeScope$1.apply(Logger.scala:129)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at logger.Logger$.makeScope(Logger.scala:127)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply$mcZ$sp(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:38)
at chisel3.iotesters.Driver$$anonfun$execute$1.apply(Driver.scala:38)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at chisel3.iotesters.Driver$.execute(Driver.scala:37)
at chisel3.iotesters.Driver$.execute(Driver.scala:94)
at taptempo.TapTempoMain$.delayedEndpoint$taptempo$TapTempoMain$1(TapTempoMain.scala:25)
at taptempo.TapTempoMain$delayedInit$body.apply(TapTempoMain.scala:24)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at taptempo.TapTempoMain$.main(TapTempoMain.scala:24)
at taptempo.TapTempoMain.main(TapTempoMain.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
[trace] Stack trace suppressed: run last test:runMain for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last test:runMain for the full output.
[error] (test:runMain) Nonzero exit code: 1
[error] Total time: 12 s, completed 10 avr. 2018 14:06:06
If I delete 'printf' lines, the testbench works.
Is it possible to print some text and value in testbench with chisel3 iotester ?
The full project is derivated from chisel template github and available on my github repository TapTempoChisel.
Ok, finally I found the problem. It's an import problem. In head of source file there is a :
import chisel3._
It sounds to be in conflict with printf. I need this import for Bool, then if we just import Bool as it :
import chisel3.Bool
And remove the chisel3._ import, that works well.