1
0

allow fixed priority routing in Junctions arbiters

This commit is contained in:
Howard Mao 2016-09-03 20:42:47 -07:00
parent efe8670283
commit 66de89c4db

View File

@ -68,7 +68,7 @@ object HellaQueue {
/** A generalized locking RR arbiter that addresses the limitations of the /** A generalized locking RR arbiter that addresses the limitations of the
* version in the Chisel standard library */ * 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 { extends Module {
val io = new Bundle { 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 lockIdx = Reg(init = UInt(0, log2Up(arbN)))
val locked = Reg(init = Bool(false)) val locked = Reg(init = Bool(false))
val choice = PriorityMux( val choice = if (rr) {
PriorityMux(
rotateLeft(Vec(io.in.map(_.valid)), lockIdx + UInt(1)), rotateLeft(Vec(io.in.map(_.valid)), lockIdx + UInt(1)),
rotateLeft(Vec((0 until arbN).map(UInt(_))), 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) val chosen = Mux(locked, lockIdx, choice)
@ -105,8 +109,9 @@ abstract class JunctionsAbstractLockingArbiter[T <: Data](typ: T, arbN: Int)
class JunctionsPeekingArbiter[T <: Data]( class JunctionsPeekingArbiter[T <: Data](
typ: T, arbN: Int, typ: T, arbN: Int,
canUnlock: T => Bool, canUnlock: T => Bool,
needsLock: Option[T => Bool] = None) needsLock: Option[T => Bool] = None,
extends JunctionsAbstractLockingArbiter(typ, arbN) { rr: Boolean = false)
extends JunctionsAbstractLockingArbiter(typ, arbN, rr) {
def realNeedsLock(data: T): Bool = def realNeedsLock(data: T): Bool =
needsLock.map(_(data)).getOrElse(Bool(true)) needsLock.map(_(data)).getOrElse(Bool(true))
@ -126,8 +131,9 @@ class JunctionsPeekingArbiter[T <: Data](
/** This arbiter determines when it is safe to unlock by counting transactions */ /** This arbiter determines when it is safe to unlock by counting transactions */
class JunctionsCountingArbiter[T <: Data]( class JunctionsCountingArbiter[T <: Data](
typ: T, arbN: Int, count: Int, typ: T, arbN: Int, count: Int,
val needsLock: Option[T => Bool] = None) val needsLock: Option[T => Bool] = None,
extends JunctionsAbstractLockingArbiter(typ, arbN) { rr: Boolean = false)
extends JunctionsAbstractLockingArbiter(typ, arbN, rr) {
def realNeedsLock(data: T): Bool = def realNeedsLock(data: T): Bool =
needsLock.map(_(data)).getOrElse(Bool(true)) needsLock.map(_(data)).getOrElse(Bool(true))