printf
Debugging
Use printf when you want to print during the simulation.
- Note: this will print at the end of the cycle so you’ll see the values on the wires after the cycle has passed.
- Use
printf(p"This is my text with a $var\n")
to print Chisel variables. Notice the “p” before the quote! - You can also put any Scala statement in the print statement (e.g.,
printf(p"Output: ${io.output})
). - Use
println
to print during compilation in the Chisel code or during test execution in the test code. This is mostly like Java’sprintln
. - If you want to use Scala variables in the print statement, prepend the statement with an ‘s’. For example,
println(s"This is my cool variable: $variable")
orprintln("Some math: 5 + 5 = ${5+5}")
. - print statements will be carried over to generated verilog as
$fwrite()