Search code examples
scalacoroutinehdlchisel

How to do parallel testing with peekpoketester in chisel3?


I want to write a bus monitor for my design in chisel3 (actually a mdio bus) and I wonder if it's possible to execute this monitor function in parallel to the "main" testbench. Like we do it in cocotb with cocotb.fork() coroutine ?


Solution

  • There is no support for parallel testing with chisel3.iotesters ("Chisel Testers"). However, there is support for parallel testing with the new testing framework: chisel3.testers ("Chisel Testers2").

    This adds support for fork, join, and parallel constructs. A concise example is testing a queue by forking both the enqueueing and dequeueing:

    it should "work with a combinational queue" in {
      test(new PassthroughQueue(UInt(8.W))) { c =>
        c.in.initSource()
        c.in.setSourceClock(c.clock)
        c.out.initSink()
        c.out.setSinkClock(c.clock)
    
        fork {
          c.in.enqueueSeq(Seq(42.U, 43.U, 44.U))
        }.fork {
          c.out.expectDequeueSeq(Seq(42.U, 43.U, 44.U))
        }.join()
      }
    }
    

    For an additional example, see the chisel-template file GcdTesters2.scala.