I was trying to use queue class in chisel3.util.
I tested my source with chisel tester.
However, the results on the terminal don't match what i exepcted
My source code looks like below.
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
}
And, my test code looks below.
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)
}
I think, last step of test results should be failed.
Because, from the ready/valid handshaking protocol, if ready signal is false, No output can come out.
But, the terminal says that all tested passed.
Could anyone tell me what i misunderstood?
You should poke(false.B)
the c.io.Ready
signal before the last step.
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)
}