Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Commit

Permalink
support enqueue/dequeue of IrrevocableIO (#90)
Browse files Browse the repository at this point in the history
* support enqueue/dequeue of IrrevocableIO

Signed-off-by: shuyun <shuyunjia@outlook.com>

* fix per commit

Signed-off-by: shuyun <shuyunjia@outlook.com>
  • Loading branch information
ShuyunJia authored and ducky64 committed Nov 30, 2019
1 parent ea5e81f commit 6767faa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/chisel3/tester/DecoupledDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/chisel3/tester/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
20 changes: 20 additions & 0 deletions src/test/scala/chisel3/tests/QueueTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
)
}
}

}

0 comments on commit 6767faa

Please sign in to comment.