tilelink2: support attaching a DecoupledIO directly to a register
This commit is contained in:
parent
6a378e79e3
commit
81162a2dc9
@ -25,16 +25,12 @@ object RegReadFn
|
|||||||
val (ovalid, data) = x(oready)
|
val (ovalid, data) = x(oready)
|
||||||
(Bool(true), ovalid, data)
|
(Bool(true), ovalid, data)
|
||||||
})
|
})
|
||||||
|
// read from a DecoupledIO (only safe if there is a consistent source of data)
|
||||||
|
implicit def apply(x: DecoupledIO[UInt]):RegReadFn = RegReadFn(ready => { x.ready := ready; (x.valid, x.bits) })
|
||||||
// read from a register
|
// read from a register
|
||||||
implicit def apply(x: UInt) =
|
implicit def apply(x: UInt):RegReadFn = RegReadFn(ready => (Bool(true), x))
|
||||||
new RegReadFn(true, { case (_, _) =>
|
|
||||||
(Bool(true), Bool(true), x)
|
|
||||||
})
|
|
||||||
// noop
|
// noop
|
||||||
implicit def apply(x: Unit) =
|
implicit def apply(x: Unit):RegReadFn = RegReadFn(UInt(0))
|
||||||
new RegReadFn(true, { case (_, _) =>
|
|
||||||
(Bool(true), Bool(true), UInt(0))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case class RegWriteFn private(combinational: Boolean, fn: (Bool, Bool, UInt) => (Bool, Bool))
|
case class RegWriteFn private(combinational: Boolean, fn: (Bool, Bool, UInt) => (Bool, Bool))
|
||||||
@ -58,17 +54,12 @@ object RegWriteFn
|
|||||||
new RegWriteFn(true, { case (_, oready, data) =>
|
new RegWriteFn(true, { case (_, oready, data) =>
|
||||||
(Bool(true), x(oready, data))
|
(Bool(true), x(oready, data))
|
||||||
})
|
})
|
||||||
|
// write to a DecoupledIO (only safe if there is a consistent sink draining data)
|
||||||
|
implicit def apply(x: DecoupledIO[UInt]): RegWriteFn = RegWriteFn((valid, data) => { x.valid := valid; x.bits := data; x.ready })
|
||||||
// updates a register
|
// updates a register
|
||||||
implicit def apply(x: UInt) =
|
implicit def apply(x: UInt): RegWriteFn = RegWriteFn((valid, data) => { when (valid) { x := data }; Bool(true) })
|
||||||
new RegWriteFn(true, { case (_, oready, data) =>
|
|
||||||
when (oready) { x := data }
|
|
||||||
(Bool(true), Bool(true))
|
|
||||||
})
|
|
||||||
// noop
|
// noop
|
||||||
implicit def apply(x: Unit) =
|
implicit def apply(x: Unit): RegWriteFn = RegWriteFn((valid, data) => { Bool(true) })
|
||||||
new RegWriteFn(true, { case (_, _, _) =>
|
|
||||||
(Bool(true), Bool(true))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case class RegField(width: Int, read: RegReadFn, write: RegWriteFn)
|
case class RegField(width: Int, read: RegReadFn, write: RegWriteFn)
|
||||||
|
Loading…
Reference in New Issue
Block a user