| |
package utils
import chisel3._
import chisel3.util._
object ParallelOperation {
def apply[T](xs: Seq[T], func: (T, T) => T): T = {
require(xs.nonEmpty)
xs match {
case Seq(a) => a
case Seq(a, b) => func(a, b)
case _ =>
apply(Seq(apply(xs take xs.size/2, func), apply(xs drop xs.size/2, func)), func)
}
}
}
object ParallelOR {
def apply[T <: Data](xs: Seq[T]): T = {
ParallelOperation(xs, (a: T, b: T) => (a.asUInt | b.asUInt).asTypeOf(xs.head))
}
}
object LowerMask {
def apply(a: UInt, len: Int): UInt = {
ParallelOR((0 until len).map(i => (a >> i).asUInt))
}
def apply(a: UInt): UInt = {
apply(a, a.getWidth)
}
}
val s2_allocatableSlots = VecInit(s2_resps.map(r => !r.valid && !r.bits.u)).asUInt & //5 bits
~(LowerMask(UIntToOH(s2_provider), ITTageNTables) & Fill(ITTageNTables, s2_provided.asUInt))