tilelink2 RegField: .bytes should update more than one byte!
This commit is contained in:
parent
6134384da4
commit
943c36954d
@ -110,12 +110,12 @@ object RegField
|
|||||||
// The bytes can be individually written, as they are one byte per field
|
// 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] = {
|
def bytes(x: UInt, base: Int = 0, beatBytes: Int = 4): Seq[RegField.Map] = {
|
||||||
require (x.getWidth % 8 == 0)
|
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 =>
|
Seq.tabulate(x.getWidth/8) { i =>
|
||||||
RegField(8, x(8*(i+1)-1, 8*i), RegWriteFn { (valid, data) =>
|
RegField(8, bytes(i), RegWriteFn { (valid, data) =>
|
||||||
when (valid) {
|
when (valid) { wires(i) := data }
|
||||||
val mask = ~UInt(BigInt(0xff) << 8*i, width = x.getWidth)
|
|
||||||
x := (x & mask) | (data & UInt(0xff)) << 8*i
|
|
||||||
}
|
|
||||||
Bool(true)
|
Bool(true)
|
||||||
})
|
})
|
||||||
}.grouped(beatBytes).toSeq.zipWithIndex.map { case (reg, i) =>
|
}.grouped(beatBytes).toSeq.zipWithIndex.map { case (reg, i) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user