Skip to content

Commit

Permalink
Merge pull request #340 from riscv-boom/freelist-sel
Browse files Browse the repository at this point in the history
[util] N-wide priority selector QoR
  • Loading branch information
bkorpan committed Jul 25, 2019
2 parents 7796d9f + df669de commit 783be01
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/scala/util/util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,15 @@ object Transpose
object SelectFirstN
{
def apply(in: UInt, n: Int) = {
val counts = in.asBools.scanLeft(1.U(n.W))((cnt, elt) => Mux(elt, cnt << 1, cnt))
val sels = (0 until n).map(j => VecInit((0 until in.getWidth).map(i => counts(i)(j) & in(i))).asUInt)
VecInit(sels)
val sels = Wire(Vec(n, UInt(in.getWidth.W)))
var mask = in

for (i <- 0 until n) {
sels(i) := PriorityEncoderOH(mask)
mask = mask & ~sels(i)
}

sels
}
}

Expand Down

0 comments on commit 783be01

Please sign in to comment.