From 6767faaf02b0973ab34b315d2f5376966d015df1 Mon Sep 17 00:00:00 2001 From: ShuyunJia Date: Sun, 1 Dec 2019 07:46:25 +0800 Subject: [PATCH] support enqueue/dequeue of IrrevocableIO (#90) * support enqueue/dequeue of IrrevocableIO Signed-off-by: shuyun * fix per commit Signed-off-by: shuyun --- .../chisel3/tester/DecoupledDriver.scala | 2 +- src/main/scala/chisel3/tester/package.scala | 2 +- src/test/scala/chisel3/tests/QueueTest.scala | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/scala/chisel3/tester/DecoupledDriver.scala b/src/main/scala/chisel3/tester/DecoupledDriver.scala index b19f2b0f9..afa94af21 100644 --- a/src/main/scala/chisel3/tester/DecoupledDriver.scala +++ b/src/main/scala/chisel3/tester/DecoupledDriver.scala @@ -6,7 +6,7 @@ import chisel3._ import chisel3.util._ // implicit class, cannot maintain state -class DecoupledDriver[T <: Data](x: DecoupledIO[T]) { +class DecoupledDriver[T <: Data](x: ReadyValidIO[T]) { // Source (enqueue) functions // def initSource(): this.type = { diff --git a/src/main/scala/chisel3/tester/package.scala b/src/main/scala/chisel3/tester/package.scala index 5c500bda5..d36b9afe1 100644 --- a/src/main/scala/chisel3/tester/package.scala +++ b/src/main/scala/chisel3/tester/package.scala @@ -171,7 +171,7 @@ package object tester { } } - implicit def decoupledToDriver[T <: Data](x: DecoupledIO[T]) = new DecoupledDriver(x) + implicit def decoupledToDriver[T <: Data](x: ReadyValidIO[T]) = new DecoupledDriver(x) implicit def validToDriver[T <: Data](x: ValidIO[T]) = new ValidDriver(x) } diff --git a/src/test/scala/chisel3/tests/QueueTest.scala b/src/test/scala/chisel3/tests/QueueTest.scala index b483c3b4d..9905814d9 100644 --- a/src/test/scala/chisel3/tests/QueueTest.scala +++ b/src/test/scala/chisel3/tests/QueueTest.scala @@ -4,6 +4,8 @@ import org.scalatest._ import chisel3._ import chisel3.tester._ +import chisel3.util._ + class QueueTest extends FlatSpec with ChiselScalatestTester { behavior of "Testers2 with Queue" @@ -57,4 +59,22 @@ class QueueTest extends FlatSpec with ChiselScalatestTester { }.join() } } + + it should "work with IrrevocableIO" in{ + test(new Module{ + val io = IO(new Bundle{ + val in = Flipped(Irrevocable(UInt(8.W))) + val out = Irrevocable(UInt(8.W)) + }) + io.out <> Queue(io.in) + }){c => + c.io.in.initSource().setSourceClock(c.clock) + c.io.out.initSink().setSinkClock(c.clock) + parallel( + c.io.in.enqueueSeq(Seq(5.U, 2.U)), + c.io.out.expectDequeueSeq(Seq(5.U, 2.U)) + ) + } + } + }