To test Chisel code, I launch a console sbt then scala in the directory of my project where is the file build.sbt. I can import chisel3 library :
$ cd myproject
$ sbt
sbt:myproject> console
scala> import chisel3._
import chisel3._
Then I can test some chisel code for data type for example :
scala> val plop = "b01010101".U(20.W)
plop: chisel3.UInt = UInt<20>(85)
But I can test Reg() or other Module() elements :
scala> val plopReg = RegInit(23.U(24.W))
java.lang.IllegalArgumentException: requirement failed: must be inside Builder context
at scala.Predef$.require(Predef.scala:281)
at chisel3.internal.Builder$.dynamicContext(Builder.scala:232)
at chisel3.internal.Builder$.currentClock(Builder.scala:308)
at chisel3.internal.Builder$.forcedClock(Builder.scala:318)
at chisel3.RegInit$.apply(Reg.scala:155)
at chisel3.RegInit$.apply(Reg.scala:173)
... 36 elided
Is there a tips to test these chisel element in console ? Or is it mandatory to write a file code source ?
Reg
,Wire
, etc) inside aModule
context. Similar thing is done in github.com/freechipsproject/chisel-bootcamp using anammonite
-compatible shell (almond+jupyter).