Chisel 队列模块测试结果与我的预期不符

Chisel queue module test results don't match what i expected

我试图在 chisel3.util 中使用队列 class。

我用凿子测试仪测试了我的源。

但是,终端上的结果与我执行的结果不符

我的源代码如下所示。

class QueueingExample extends Module {
  val io = IO(new Bundle {
    val QueInput = Input((SInt(32.W))) 
    val QueOutput = Output(SInt(32.W))

    val Valid = Input(Bool())
    val Ready = Input(Bool())
  })
  
  val q = Module(new Queue(SInt(), 5))
  q.io.enq.bits := io.QueInput
  q.io.enq.valid := io.Valid

  io.QueOutput := q.io.deq.bits
  q.io.deq.ready := io.Ready

}

而且,我的测试代码如下所示。

      test (new QueueingExample) { c=>

        c.io.Valid.poke(true.B)
        c.io.Ready.poke(false.B)
        c.io.QueInput.poke(1.S)

        c.clock.step(1)
        c.io.QueInput.poke(2.S)        

        c.clock.step(1)
        c.io.QueInput.poke(3.S)                

        c.clock.step(1)
        c.io.Ready.poke(true.B)
        c.io.QueOutput.expect(1.S)

        c.clock.step(1)
        c.io.Ready.poke(true.B)
        c.io.QueOutput.expect(2.S)

        c.clock.step(1)
        c.io.Ready.poke(false.B)
        c.io.QueOutput.expect(3.S)               
                
      }

我想,最后一步测试结果应该是失败了。

因为根据ready/valid握手协议,如果ready信号为false,则不会有输出。

但是,终端说所有测试都通过了。

谁能告诉我我误解了什么?

您应该poke(false.B)在最后一步之前发出c.io.Ready信号。

      test (new QueueingExample) { c=>

        c.io.Valid.poke(true.B)
        c.io.Ready.poke(false.B)
        c.io.QueInput.poke(1.S)

        c.clock.step(1)
        c.io.QueInput.poke(2.S)        

        c.clock.step(1)
        c.io.QueInput.poke(3.S)                

        c.clock.step(1)
        c.io.Ready.poke(true.B)
        c.io.QueOutput.expect(1.S)

        c.clock.step(1)

        c.io.QueOutput.expect(2.S)

        c.io.Ready.poke(false.B) // set value here

        // c.io.Ready value is still true.B here

        c.clock.step(1)

        // c.io.Ready value is now false.B

        c.io.QueOutput.expect(3.S)     
      }