From 66de89c4db183621bcec0cfaa9ab6a912c7c0a84 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Sat, 3 Sep 2016 20:42:47 -0700 Subject: [PATCH] allow fixed priority routing in Junctions arbiters --- src/main/scala/junctions/util.scala | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/scala/junctions/util.scala b/src/main/scala/junctions/util.scala index cce346cd..afb10803 100644 --- a/src/main/scala/junctions/util.scala +++ b/src/main/scala/junctions/util.scala @@ -68,7 +68,7 @@ object HellaQueue { /** A generalized locking RR arbiter that addresses the limitations of the * version in the Chisel standard library */ -abstract class JunctionsAbstractLockingArbiter[T <: Data](typ: T, arbN: Int) +abstract class JunctionsAbstractLockingArbiter[T <: Data](typ: T, arbN: Int, rr: Boolean = false) extends Module { val io = new Bundle { @@ -86,9 +86,13 @@ abstract class JunctionsAbstractLockingArbiter[T <: Data](typ: T, arbN: Int) val lockIdx = Reg(init = UInt(0, log2Up(arbN))) val locked = Reg(init = Bool(false)) - val choice = PriorityMux( - rotateLeft(Vec(io.in.map(_.valid)), lockIdx + UInt(1)), - rotateLeft(Vec((0 until arbN).map(UInt(_))), lockIdx + UInt(1))) + val choice = if (rr) { + PriorityMux( + rotateLeft(Vec(io.in.map(_.valid)), lockIdx + UInt(1)), + rotateLeft(Vec((0 until arbN).map(UInt(_))), lockIdx + UInt(1))) + } else { + PriorityEncoder(io.in.map(_.valid)) + } val chosen = Mux(locked, lockIdx, choice) @@ -103,10 +107,11 @@ abstract class JunctionsAbstractLockingArbiter[T <: Data](typ: T, arbN: Int) /** This locking arbiter determines when it is safe to unlock * by peeking at the data */ class JunctionsPeekingArbiter[T <: Data]( - typ: T, arbN: Int, - canUnlock: T => Bool, - needsLock: Option[T => Bool] = None) - extends JunctionsAbstractLockingArbiter(typ, arbN) { + typ: T, arbN: Int, + canUnlock: T => Bool, + needsLock: Option[T => Bool] = None, + rr: Boolean = false) + extends JunctionsAbstractLockingArbiter(typ, arbN, rr) { def realNeedsLock(data: T): Bool = needsLock.map(_(data)).getOrElse(Bool(true)) @@ -125,9 +130,10 @@ class JunctionsPeekingArbiter[T <: Data]( /** This arbiter determines when it is safe to unlock by counting transactions */ class JunctionsCountingArbiter[T <: Data]( - typ: T, arbN: Int, count: Int, - val needsLock: Option[T => Bool] = None) - extends JunctionsAbstractLockingArbiter(typ, arbN) { + typ: T, arbN: Int, count: Int, + val needsLock: Option[T => Bool] = None, + rr: Boolean = false) + extends JunctionsAbstractLockingArbiter(typ, arbN, rr) { def realNeedsLock(data: T): Bool = needsLock.map(_(data)).getOrElse(Bool(true))