1
0

tilelink2: Narrower must be little-endian

This commit is contained in:
Wesley W. Terpstra 2016-09-05 20:42:16 -07:00
parent ded246fb95
commit 3167539331

View File

@ -59,20 +59,21 @@ class TLNarrower(innerBeatBytes: Int) extends LazyModule
def merge(in: HasTLData, fire: Bool): (Bool, UInt) = { def merge(in: HasTLData, fire: Bool): (Bool, UInt) = {
val count = RegInit(UInt(0, width = log2Ceil(ratio))) val count = RegInit(UInt(0, width = log2Ceil(ratio)))
val rdata = Reg(UInt(width = (ratio-1)*outerBeatBytes*8)) val rdata = Reg(UInt(width = (ratio-1)*outerBeatBytes*8))
val data = rdata << outerBeatBytes*8 | in.data() val data = Cat(in.data(), rdata)
val first = count === UInt(0) val first = count === UInt(0)
val limit = UIntToOH1(in.size(), log2Ceil(innerBeatBytes)) >> log2Ceil(outerBeatBytes) val limit = UIntToOH1(in.size(), log2Ceil(innerBeatBytes)) >> log2Ceil(outerBeatBytes)
val last = count === limit || !edge.hasData(in) val last = count === limit || !edge.hasData(in)
when (fire) { when (fire) {
rdata := data rdata := data >> outerBeatBytes*8
count := count + UInt(1) count := count + UInt(1)
when (last) { count := UInt(0) } when (last) { count := UInt(0) }
} }
val cases = Seq.tabulate(log2Ceil(ratio)+1) { i => val cases = Seq.tabulate(log2Ceil(ratio)+1) { i =>
val pow = 1 << i val high = innerBeatBytes*8
Fill(1 << (log2Ceil(ratio)-i), data(pow*outerBeatBytes*8-1, 0)) val take = (1 << i)*outerBeatBytes*8
Fill(1 << (log2Ceil(ratio)-i), data(high-1, high-take))
} }
val mux = Vec.tabulate(log2Ceil(edge.maxTransfer)+1) { lgSize => val mux = Vec.tabulate(log2Ceil(edge.maxTransfer)+1) { lgSize =>
cases(min(max(lgSize - log2Ceil(outerBeatBytes), 0), log2Ceil(ratio))) cases(min(max(lgSize - log2Ceil(outerBeatBytes), 0), log2Ceil(ratio)))