1
0

tilelink2: refactor firstlast helper method

This commit is contained in:
Wesley W. Terpstra
2016-10-07 20:15:31 -07:00
parent a404cd2abf
commit 683a2e6785
4 changed files with 61 additions and 92 deletions

View File

@ -4,6 +4,7 @@ package uncore.tilelink2
import Chisel._
import chisel3.internal.sourceinfo.SourceInfo
import chisel3.util.IrrevocableIO
import diplomacy._
class TLEdge(
@ -218,6 +219,20 @@ class TLEdge(
}
}
}
def firstlast(bits: TLChannel, fire: Bool): (Bool, Bool, UInt) = {
val beats1 = numBeats1(bits)
val counter = RegInit(UInt(0, width = log2Up(maxTransfer / manager.beatBytes)))
val counter1 = counter - UInt(1)
val first = counter === UInt(0)
val last = counter === UInt(1) || beats1 === UInt(0)
when (fire) {
counter := Mux(first, beats1, counter1)
}
(first, last, beats1 & ~counter1)
}
def firstlast(x: IrrevocableIO[TLChannel]): (Bool, Bool, UInt) = firstlast(x.bits, x.fire())
}
class TLEdgeOut(