Tuesday, April 18, 2017

PeekPokeTester and LazyModule

In Chisel, it appears that PeekPokeTester doesn't play well with LazyModule.  If ChiselTop is a LazyModule (not Module), the following will not work.

  class ChiselTopTester(c: ChiselTop) extends PeekPokeTester(c) { }

Adding a wrapper class around the LazyModule instance solves the problem.

class ChiselTopTest extends ChiselFlatSpec {

  class ChiselTopTester(c: ChiselTopWrapper) extends PeekPokeTester(c) {
    println("Hello World!")

  // hint from: https://github.com/ucb-bar/rocket-chip/issues/359
  class ChiselTopWrapper(p: Parameters) extends Module {
    val top = Module(LazyModule(new ChiselTop()(p)).module)
    val io = top.io.cloneType
    io <> top.io

  implicit val p: Parameters = new BlankConfig
  chisel3.iotesters.Driver(() => new ChiselTopWrapper(p)) { c => new ChiselTopTester(c) }

In other news, my Scala skills are improving...

No comments:

Post a Comment