tilelink2 Arbiter: there is only one winner
This commit is contained in:
parent
b6e9b0c558
commit
b42cfdc9dd
@ -31,24 +31,24 @@ object TLArbiter
|
|||||||
// Arbitrate amongst the requests
|
// Arbitrate amongst the requests
|
||||||
val readys = Vec(policy(valids, latch))
|
val readys = Vec(policy(valids, latch))
|
||||||
// Which request wins arbitration?
|
// Which request wins arbitration?
|
||||||
val winners = Vec((readys zip valids) map { case (r,v) => r&&v })
|
val winner = Vec((readys zip valids) map { case (r,v) => r&&v })
|
||||||
|
|
||||||
// Confirm the policy works properly
|
// Confirm the policy works properly
|
||||||
require (readys.size == valids.size)
|
require (readys.size == valids.size)
|
||||||
// Never two winners
|
// Never two winner
|
||||||
val prefixOR = winners.scanLeft(Bool(false))(_||_).init
|
val prefixOR = winner.scanLeft(Bool(false))(_||_).init
|
||||||
assert((prefixOR zip winners) map { case (p,w) => !p || !w } reduce {_ && _})
|
assert((prefixOR zip winner) map { case (p,w) => !p || !w } reduce {_ && _})
|
||||||
// If there was any request, there is a winner
|
// If there was any request, there is a winner
|
||||||
assert (!valids.reduce(_||_) || winners.reduce(_||_))
|
assert (!valids.reduce(_||_) || winner.reduce(_||_))
|
||||||
|
|
||||||
// Track remaining beats
|
// Track remaining beats
|
||||||
val maskedBeats = (winners zip beatsIn) map { case (w,b) => Mux(w, b, UInt(0)) }
|
val maskedBeats = (winner zip beatsIn) map { case (w,b) => Mux(w, b, UInt(0)) }
|
||||||
val initBeats = maskedBeats.reduce(_ | _) // no winner => 0 beats
|
val initBeats = maskedBeats.reduce(_ | _) // no winner => 0 beats
|
||||||
beatsLeft := Mux(latch, initBeats, beatsLeft - sink.fire())
|
beatsLeft := Mux(latch, initBeats, beatsLeft - sink.fire())
|
||||||
|
|
||||||
// The one-hot source granted access in the previous cycle
|
// The one-hot source granted access in the previous cycle
|
||||||
val state = RegInit(Vec.fill(sources.size)(Bool(false)))
|
val state = RegInit(Vec.fill(sources.size)(Bool(false)))
|
||||||
val muxState = Mux(idle, winners, state)
|
val muxState = Mux(idle, winner, state)
|
||||||
state := muxState
|
state := muxState
|
||||||
|
|
||||||
if (sources.size > 1) {
|
if (sources.size > 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user