[util] move LatencyPipe into util
This commit is contained in:
parent
a70d8c9821
commit
245f8ab76b
@ -5,6 +5,7 @@ package rocketchip
|
|||||||
import Chisel._
|
import Chisel._
|
||||||
import cde.{Parameters, Field}
|
import cde.{Parameters, Field}
|
||||||
import rocket.Util._
|
import rocket.Util._
|
||||||
|
import util.LatencyPipe
|
||||||
import junctions._
|
import junctions._
|
||||||
import junctions.NastiConstants._
|
import junctions.NastiConstants._
|
||||||
|
|
||||||
@ -175,23 +176,3 @@ class JTAGVPI(implicit val p: Parameters) extends BlackBox {
|
|||||||
tbsuccess := Bool(false)
|
tbsuccess := Bool(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LatencyPipe[T <: Data](typ: T, latency: Int) extends Module {
|
|
||||||
val io = new Bundle {
|
|
||||||
val in = Decoupled(typ).flip
|
|
||||||
val out = Decoupled(typ)
|
|
||||||
}
|
|
||||||
|
|
||||||
def doN[T](n: Int, func: T => T, in: T): T =
|
|
||||||
(0 until n).foldLeft(in)((last, _) => func(last))
|
|
||||||
|
|
||||||
io.out <> doN(latency, (last: DecoupledIO[T]) => Queue(last, 1, pipe=true), io.in)
|
|
||||||
}
|
|
||||||
|
|
||||||
object LatencyPipe {
|
|
||||||
def apply[T <: Data](in: DecoupledIO[T], latency: Int): DecoupledIO[T] = {
|
|
||||||
val pipe = Module(new LatencyPipe(in.bits, latency))
|
|
||||||
pipe.io.in <> in
|
|
||||||
pipe.io.out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
25
src/main/scala/util/LatencyPipe.scala
Normal file
25
src/main/scala/util/LatencyPipe.scala
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// See LICENSE for license details.
|
||||||
|
|
||||||
|
package util
|
||||||
|
|
||||||
|
import Chisel._
|
||||||
|
|
||||||
|
class LatencyPipe[T <: Data](typ: T, latency: Int) extends Module {
|
||||||
|
val io = new Bundle {
|
||||||
|
val in = Decoupled(typ).flip
|
||||||
|
val out = Decoupled(typ)
|
||||||
|
}
|
||||||
|
|
||||||
|
def doN[T](n: Int, func: T => T, in: T): T =
|
||||||
|
(0 until n).foldLeft(in)((last, _) => func(last))
|
||||||
|
|
||||||
|
io.out <> doN(latency, (last: DecoupledIO[T]) => Queue(last, 1, pipe=true), io.in)
|
||||||
|
}
|
||||||
|
|
||||||
|
object LatencyPipe {
|
||||||
|
def apply[T <: Data](in: DecoupledIO[T], latency: Int): DecoupledIO[T] = {
|
||||||
|
val pipe = Module(new LatencyPipe(in.bits, latency))
|
||||||
|
pipe.io.in <> in
|
||||||
|
pipe.io.out
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user