1
0

RegFieldDesc: simplify the output RegFieldDesc JSON to just a list of reg fields

This commit is contained in:
Megan Wachs 2018-02-12 08:32:52 -08:00
parent 7bf0121f07
commit de91672e9a

View File

@ -85,15 +85,15 @@ case class TLRegisterNode(
bundleIn.e.ready := Bool(true) bundleIn.e.ready := Bool(true)
// Dump out the register map for documentation purposes. // Dump out the register map for documentation purposes.
val regDescs = mapping.map { case (offset, seq) => val regDescs = mapping.flatMap { case (offset, seq) =>
var currentBitOffset = 0 var currentBitOffset = 0
(s"0x${offset.toHexString}" -> seq.zipWithIndex.map { case (f, i) => { seq.zipWithIndex.map { case (f, i) => {
val tmp = (f.desc.map{ _.name}.getOrElse(s"unnamedRegField${i}") -> ( val tmp = (f.desc.map{ _.name}.getOrElse(s"unnamedRegField${i}") -> (
("byteOffset" -> s"0x${offset.toHexString}") ~ ("byteOffset" -> s"0x${offset.toHexString}") ~
("bitOffset" -> currentBitOffset) ~ ("bitOffset" -> currentBitOffset) ~
("bitWidth" -> f.width) ~ ("bitWidth" -> f.width) ~
("name" -> f.desc.map(_.name) ("name" -> f.desc.map(_.name)) ~
("description" -> f.desc.map{if _.desc == "" None else Some(_.desc)}) ~ ("description" -> f.desc.map{ d=> if (d.desc == "") None else Some(d.desc)}) ~
("resetValue" -> f.desc.map{_.reset}) ~ ("resetValue" -> f.desc.map{_.reset}) ~
("group" -> f.desc.map{_.group}) ~ ("group" -> f.desc.map{_.group}) ~
("groupDesc" -> f.desc.map{_.groupDesc}) ~ ("groupDesc" -> f.desc.map{_.groupDesc}) ~
@ -101,7 +101,7 @@ case class TLRegisterNode(
)) ))
currentBitOffset = currentBitOffset + f.width currentBitOffset = currentBitOffset + f.width
tmp tmp
}}) }}
} }
//TODO: It would be better to name this other than "Device at ...." //TODO: It would be better to name this other than "Device at ...."