diff options
| author | Jim Lawson | 2016-09-16 09:25:18 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-09-16 09:25:18 -0700 |
| commit | ba7f7efa043e9ad8e7f4acb171ca192282fc16c9 (patch) | |
| tree | 37ecc67a512c58d6325ea95fd9b3cf3c9e830024 /src | |
| parent | 6d8acee760c8c41fcae2ab252161bac96e6954dc (diff) | |
| parent | dda64c1dee16b5da15ac690bd3cd6759c3d5c032 (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.scala | 13 |
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 { |
