1
0

RegField: remove RegField.bytes; it was dangerous

The implementation unconditionally drove the register.
This made it incompatible with drivers from the device itself.
Besides, writing only parts of a register at a time is ultra-shady.
This commit is contained in:
Wesley W. Terpstra 2016-09-22 17:51:33 -07:00
parent a421469754
commit 972ca06729

View File

@ -106,21 +106,6 @@ object RegField
Bool(true) Bool(true)
})) }))
// Split a large register into a sequence of byte fields
// The bytes can be individually written, as they are one byte per field
def bytes(x: UInt): Seq[RegField] = {
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, bytes(i), RegWriteFn { (valid, data) =>
when (valid) { wires(i) := data }
Bool(true)
})
}
}
// Divide a long sequence of RegFields into a maximum sized registers // Divide a long sequence of RegFields into a maximum sized registers
// Your input RegFields may not cross a beatBytes boundary! // Your input RegFields may not cross a beatBytes boundary!
def split(fields: Seq[RegField], base: Int, beatBytes: Int = 4): Seq[RegField.Map] = { def split(fields: Seq[RegField], base: Int, beatBytes: Int = 4): Seq[RegField.Map] = {