wrap TestHarness latency pipe in module
This commit is contained in:
parent
f5db83a72f
commit
f363f5f709
@ -176,10 +176,22 @@ class JTAGVPI(implicit val p: Parameters) extends BlackBox {
|
||||
}
|
||||
}
|
||||
|
||||
object LatencyPipe {
|
||||
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))
|
||||
|
||||
def apply[T <: Data](in: DecoupledIO[T], latency: Int): DecoupledIO[T] =
|
||||
doN(latency, (last: DecoupledIO[T]) => Queue(last, 1, pipe=true), in)
|
||||
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