1
0

Merge pull request #1256 from freechipsproject/json_emit_enums

RegFieldDesc: Emit enumerations into JSON if they exist
This commit is contained in:
Megan Wachs 2018-02-28 11:32:14 -08:00 committed by GitHub
commit cdd2a9227f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -26,7 +26,7 @@ case class RegFieldDesc (
groupDesc: Option[String] = None,
access: RegFieldAccessType = RegFieldAccessType.RW,
reset: Option[BigInt] = None,
enumerations: Map[String, BigInt] = Map()
enumerations: Map[BigInt, (String, String)] = Map()
){
}

View File

@ -93,11 +93,17 @@ case class TLRegisterNode(
("bitOffset" -> currentBitOffset) ~
("bitWidth" -> f.width) ~
("name" -> f.desc.map(_.name)) ~
("description" -> f.desc.map{ d=> if (d.desc == "") None else Some(d.desc)}) ~
("description" -> f.desc.map{d => if (d.desc == "") None else Some(d.desc)}) ~
("resetValue" -> f.desc.map{_.reset}) ~
("group" -> f.desc.map{_.group}) ~
("groupDesc" -> f.desc.map{_.groupDesc}) ~
("accessType" -> f.desc.map {d => d.access.toString})
("accessType" -> f.desc.map {d => d.access.toString}) ~
("enumerations" -> f.desc.map {d =>
Option(d.enumerations.map { case (key, (name, desc)) =>
(("value" -> key) ~
("name" -> name) ~
("description" -> desc))
}).filter(_.nonEmpty)})
))
currentBitOffset = currentBitOffset + f.width
tmp