1
0

tilelink2 RegField: .bytes should update more than one byte!

This commit is contained in:
Wesley W. Terpstra 2016-09-16 13:45:05 -07:00 committed by Andrew Waterman
parent 6134384da4
commit 943c36954d

View File

@ -110,12 +110,12 @@ object RegField
// The bytes can be individually written, as they are one byte per field
def bytes(x: UInt, base: Int = 0, beatBytes: Int = 4): Seq[RegField.Map] = {
require (x.getWidth % 8 == 0)
val bytes = Seq.tabulate(x.getWidth/8) { i => x(8*(i+1)-1, 8*i) }
val wires = bytes.map { b => Wire(init = b) }
x := Cat(wires.reverse)
Seq.tabulate(x.getWidth/8) { i =>
RegField(8, x(8*(i+1)-1, 8*i), RegWriteFn { (valid, data) =>
when (valid) {
val mask = ~UInt(BigInt(0xff) << 8*i, width = x.getWidth)
x := (x & mask) | (data & UInt(0xff)) << 8*i
}
RegField(8, bytes(i), RegWriteFn { (valid, data) =>
when (valid) { wires(i) := data }
Bool(true)
})
}.grouped(beatBytes).toSeq.zipWithIndex.map { case (reg, i) =>