summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Lawson2016-09-16 09:25:18 -0700
committerJim Lawson2016-09-16 09:25:18 -0700
commitba7f7efa043e9ad8e7f4acb171ca192282fc16c9 (patch)
tree37ecc67a512c58d6325ea95fd9b3cf3c9e830024 /src
parent6d8acee760c8c41fcae2ab252161bac96e6954dc (diff)
parentdda64c1dee16b5da15ac690bd3cd6759c3d5c032 (diff)
Merge branch 'master' into gsdt
o explain why this merge is necessary,
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/util/Decoupled.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala
index 7c377bfb..3c9da06a 100644
--- a/src/main/scala/chisel3/util/Decoupled.scala
+++ b/src/main/scala/chisel3/util/Decoupled.scala
@@ -110,6 +110,19 @@ class IrrevocableIO[+T <: Data](gen: T) extends ReadyValidIO[T](gen)
object Irrevocable
{
def apply[T <: Data](gen: T): IrrevocableIO[T] = new IrrevocableIO(gen)
+
+ /** Take a DecoupledIO and cast it to an IrrevocableIO.
+ * This cast is only safe to do in cases where the IrrevocableIO
+ * is being consumed as an input.
+ */
+ def apply[T <: Data](dec: DecoupledIO[T]): IrrevocableIO[T] = {
+ require(getFirrtlDirection(dec.bits) == INPUT, "Only safe to cast consumed Decoupled bits to Irrevocable.")
+ val i = Wire(new IrrevocableIO(dec.bits))
+ dec.bits := i.bits
+ dec.valid := i.valid
+ i.ready := dec.ready
+ i
+ }
}
object EnqIO {