Search code examples
hdlchisel

How to count time in chisel with iotesters?


Is there a way to get the step value in iotesters ? Currently I'm using a var counter but I'm sure there is a better way :

class MyTest (dut: MyModule) extends PeekPokeTester(dut) {
  var timeCounter = 0
  for(i <- 0 to 10) {
    step(1)
    timeCounter = timeCounter + 1
  }
  println("Step value is " + timeCounter)

Is there a getStepValue() like function to get that ?


Solution

  • You can get this using the (presently undocumented) method t.

    There's an internal var simTime that is tracking time. This is automatically incremented on a step (just like how you're doing it). The method t lets you query the query its value.