{"action":"created","comment":{"url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/comments/183459320","pull_request_review_id":114461744,"id":183459320,"diff_hunk":"@@ -2,22 +2,188 @@\n \n package freechips.rocketchip.regmapper\n \n-import org.json4s.JsonDSL._\n-import org.json4s.jackson.JsonMethods.{pretty, render}\n-\n-object RegMappingAnnotation {\n-  def serialize(base: BigInt, name: String, mapping: RegField.Map*): String = {\n-    val regDescs = mapping.flatMap { case (byte, seq) =>\n-      seq.map(_.width).scanLeft(0)(_ + _).zip(seq).map { case (bit, f) =>\n-        val anonName = s\"unnamedRegField${byte.toHexString}_${bit}\"\n-        (f.desc.map{ _.name}.getOrElse(anonName)) -> f.toJson(byte, bit)\n-      }\n+import chisel3.core.annotate\n+import chisel3.experimental.{ChiselAnnotation, RawModule, RunFirrtlTransform}\n+import firrtl.annotations._\n+import firrtl.{CircuitForm, CircuitState, LowForm, Transform}\n+\n+case class RegFieldDescAnnotation(\n+  target: ModuleName,\n+  desc: String) extends SingleTargetAnnotation[ModuleName] {\n+  def duplicate(n: ModuleName): RegFieldDescAnnotation = this.copy(n)\n+}\n+\n+\n+/** ********************************************************************************/\n+\n+case class RegFieldDescSer(\n+  byteOffset: String,\n+  bitOffset: Int,\n+  bitWidth: Int,\n+  name: String,\n+  resetValue: BigInt,\n+  accessType: String,\n+  wrType: String,\n+  rdAction: String,\n+  desc: String,\n+  group: String,\n+  groupDesc: String,\n+  volatile: Boolean = false,\n+  hasReset: Boolean = false,\n+  enumerations: Map[BigInt, (String, String)] = Map()\n+)\n+\n+case class RegFieldSer(\n+  regFieldName: String,\n+  desc: RegFieldDescSer\n+)\n+\n+case class RegistersSer(\n+  displayName: String,\n+  instanceCounter: Int,\n+  baseAddress: BigInt,\n+  regFields: Seq[RegFieldSer]\n+)\n+\n+/**\n+  * Firrtl annotation\n+  *\n+  * @param target\n+  * @param regMappingSer\n+  */\n+case class RegFieldDescMappingAnnotation(\n+  target: ModuleName,\n+  regMappingSer: RegistersSer) extends SingleTargetAnnotation[ModuleName] {\n+  def duplicate(n: ModuleName): RegFieldDescMappingAnnotation = this.copy(target = n)\n+}\n+\n+/**\n+  * Chisel Annotation\n+  *\n+  * This creates the firrtl annotation\n+  *\n+  * @param target\n+  * @param regMappingSer\n+  */\n+case class RegMappingChiselAnnotation(\n+  target: RawModule,\n+  regMappingSer: RegistersSer) extends ChiselAnnotation with RunFirrtlTransform {\n+  def toFirrtl: RegFieldDescMappingAnnotation = RegFieldDescMappingAnnotation(target.toNamed, regMappingSer)\n+\n+  def transformClass: Class[RegMappingDumpTransform] = classOf[RegMappingDumpTransform]\n+}\n+\n+class RegMappingDumpTransform extends Transform {\n+  def inputForm: CircuitForm = LowForm\n+\n+  def outputForm: CircuitForm = LowForm\n+\n+  def execute(state: CircuitState): CircuitState = {\n+    state.annotations.foreach {\n+      case RegFieldDescMappingAnnotation(t, desc) => println(desc)\n     }\n+    state\n+  }\n+}\n+\n+object GenRegDescsAnno {\n+  // Each class which has regmaps has instance counters\n+  private var instanceCounters = scala.collection.mutable.Map[String, Int]()","path":"src/main/scala/regmapper/Annotation.scala","position":100,"original_position":100,"commit_id":"ee795af295e4053b124f369fac7ad2840e1510b9","original_commit_id":"ee795af295e4053b124f369fac7ad2840e1510b9","user":{"login":"hcook","id":461938,"avatar_url":"https://avatars1.githubusercontent.com/u/461938?v=4","gravatar_id":"","url":"https://api.github.com/users/hcook","html_url":"https://github.com/hcook","followers_url":"https://api.github.com/users/hcook/followers","following_url":"https://api.github.com/users/hcook/following{/other_user}","gists_url":"https://api.github.com/users/hcook/gists{/gist_id}","starred_url":"https://api.github.com/users/hcook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hcook/subscriptions","organizations_url":"https://api.github.com/users/hcook/orgs","repos_url":"https://api.github.com/users/hcook/repos","events_url":"https://api.github.com/users/hcook/events{/privacy}","received_events_url":"https://api.github.com/users/hcook/received_events","type":"User","site_admin":false},"body":"I understand why you need this logic to match the behavior of `ElaborationAtrefacts`, but could you handle this on the `Transform` side instead? It only matters when you actually try to output some files, right?","created_at":"2018-04-23T16:33:58Z","updated_at":"2018-04-23T16:33:58Z","html_url":"https://github.com/freechipsproject/rocket-chip/pull/1369#discussion_r183459320","pull_request_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/comments/183459320"},"html":{"href":"https://github.com/freechipsproject/rocket-chip/pull/1369#discussion_r183459320"},"pull_request":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369"}}},"pull_request":{"url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369","id":183199199,"html_url":"https://github.com/freechipsproject/rocket-chip/pull/1369","diff_url":"https://github.com/freechipsproject/rocket-chip/pull/1369.diff","patch_url":"https://github.com/freechipsproject/rocket-chip/pull/1369.patch","issue_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/1369","number":1369,"state":"open","locked":false,"title":"Reg desc seq anno","user":{"login":"depappas-sifive","id":35471038,"avatar_url":"https://avatars0.githubusercontent.com/u/35471038?v=4","gravatar_id":"","url":"https://api.github.com/users/depappas-sifive","html_url":"https://github.com/depappas-sifive","followers_url":"https://api.github.com/users/depappas-sifive/followers","following_url":"https://api.github.com/users/depappas-sifive/following{/other_user}","gists_url":"https://api.github.com/users/depappas-sifive/gists{/gist_id}","starred_url":"https://api.github.com/users/depappas-sifive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/depappas-sifive/subscriptions","organizations_url":"https://api.github.com/users/depappas-sifive/orgs","repos_url":"https://api.github.com/users/depappas-sifive/repos","events_url":"https://api.github.com/users/depappas-sifive/events{/privacy}","received_events_url":"https://api.github.com/users/depappas-sifive/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-21T01:32:57Z","updated_at":"2018-04-23T16:33:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc9520c504288909eee6c10aa5a5f815836b3ef5","assignee":null,"assignees":[],"requested_reviewers":[{"login":"richardxia","id":1002748,"avatar_url":"https://avatars3.githubusercontent.com/u/1002748?v=4","gravatar_id":"","url":"https://api.github.com/users/richardxia","html_url":"https://github.com/richardxia","followers_url":"https://api.github.com/users/richardxia/followers","following_url":"https://api.github.com/users/richardxia/following{/other_user}","gists_url":"https://api.github.com/users/richardxia/gists{/gist_id}","starred_url":"https://api.github.com/users/richardxia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardxia/subscriptions","organizations_url":"https://api.github.com/users/richardxia/orgs","repos_url":"https://api.github.com/users/richardxia/repos","events_url":"https://api.github.com/users/richardxia/events{/privacy}","received_events_url":"https://api.github.com/users/richardxia/received_events","type":"User","site_admin":false},{"login":"jackkoenig","id":8584418,"avatar_url":"https://avatars3.githubusercontent.com/u/8584418?v=4","gravatar_id":"","url":"https://api.github.com/users/jackkoenig","html_url":"https://github.com/jackkoenig","followers_url":"https://api.github.com/users/jackkoenig/followers","following_url":"https://api.github.com/users/jackkoenig/following{/other_user}","gists_url":"https://api.github.com/users/jackkoenig/gists{/gist_id}","starred_url":"https://api.github.com/users/jackkoenig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackkoenig/subscriptions","organizations_url":"https://api.github.com/users/jackkoenig/orgs","repos_url":"https://api.github.com/users/jackkoenig/repos","events_url":"https://api.github.com/users/jackkoenig/events{/privacy}","received_events_url":"https://api.github.com/users/jackkoenig/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369/commits","review_comments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369/comments","review_comment_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/1369/comments","statuses_url":"https://api.github.com/repos/freechipsproject/rocket-chip/statuses/ee795af295e4053b124f369fac7ad2840e1510b9","head":{"label":"freechipsproject:reg-desc-seq-anno","ref":"reg-desc-seq-anno","sha":"ee795af295e4053b124f369fac7ad2840e1510b9","user":{"login":"freechipsproject","id":25232510,"avatar_url":"https://avatars2.githubusercontent.com/u/25232510?v=4","gravatar_id":"","url":"https://api.github.com/users/freechipsproject","html_url":"https://github.com/freechipsproject","followers_url":"https://api.github.com/users/freechipsproject/followers","following_url":"https://api.github.com/users/freechipsproject/following{/other_user}","gists_url":"https://api.github.com/users/freechipsproject/gists{/gist_id}","starred_url":"https://api.github.com/users/freechipsproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freechipsproject/subscriptions","organizations_url":"https://api.github.com/users/freechipsproject/orgs","repos_url":"https://api.github.com/users/freechipsproject/repos","events_url":"https://api.github.com/users/freechipsproject/events{/privacy}","received_events_url":"https://api.github.com/users/freechipsproject/received_events","type":"Organization","site_admin":false},"repo":{"id":23950406,"name":"rocket-chip","full_name":"freechipsproject/rocket-chip","owner":{"login":"freechipsproject","id":25232510,"avatar_url":"https://avatars2.githubusercontent.com/u/25232510?v=4","gravatar_id":"","url":"https://api.github.com/users/freechipsproject","html_url":"https://github.com/freechipsproject","followers_url":"https://api.github.com/users/freechipsproject/followers","following_url":"https://api.github.com/users/freechipsproject/following{/other_user}","gists_url":"https://api.github.com/users/freechipsproject/gists{/gist_id}","starred_url":"https://api.github.com/users/freechipsproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freechipsproject/subscriptions","organizations_url":"https://api.github.com/users/freechipsproject/orgs","repos_url":"https://api.github.com/users/freechipsproject/repos","events_url":"https://api.github.com/users/freechipsproject/events{/privacy}","received_events_url":"https://api.github.com/users/freechipsproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freechipsproject/rocket-chip","description":"Rocket Chip Generator","fork":false,"url":"https://api.github.com/repos/freechipsproject/rocket-chip","forks_url":"https://api.github.com/repos/freechipsproject/rocket-chip/forks","keys_url":"https://api.github.com/repos/freechipsproject/rocket-chip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freechipsproject/rocket-chip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freechipsproject/rocket-chip/teams","hooks_url":"https://api.github.com/repos/freechipsproject/rocket-chip/hooks","issue_events_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/events{/number}","events_url":"https://api.github.com/repos/freechipsproject/rocket-chip/events","assignees_url":"https://api.github.com/repos/freechipsproject/rocket-chip/assignees{/user}","branches_url":"https://api.github.com/repos/freechipsproject/rocket-chip/branches{/branch}","tags_url":"https://api.github.com/repos/freechipsproject/rocket-chip/tags","blobs_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/refs{/sha}","trees_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freechipsproject/rocket-chip/statuses/{sha}","languages_url":"https://api.github.com/repos/freechipsproject/rocket-chip/languages","stargazers_url":"https://api.github.com/repos/freechipsproject/rocket-chip/stargazers","contributors_url":"https://api.github.com/repos/freechipsproject/rocket-chip/contributors","subscribers_url":"https://api.github.com/repos/freechipsproject/rocket-chip/subscribers","subscription_url":"https://api.github.com/repos/freechipsproject/rocket-chip/subscription","commits_url":"https://api.github.com/repos/freechipsproject/rocket-chip/commits{/sha}","git_commits_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/commits{/sha}","comments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/comments{/number}","issue_comment_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/comments{/number}","contents_url":"https://api.github.com/repos/freechipsproject/rocket-chip/contents/{+path}","compare_url":"https://api.github.com/repos/freechipsproject/rocket-chip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freechipsproject/rocket-chip/merges","archive_url":"https://api.github.com/repos/freechipsproject/rocket-chip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freechipsproject/rocket-chip/downloads","issues_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues{/number}","pulls_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls{/number}","milestones_url":"https://api.github.com/repos/freechipsproject/rocket-chip/milestones{/number}","notifications_url":"https://api.github.com/repos/freechipsproject/rocket-chip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freechipsproject/rocket-chip/labels{/name}","releases_url":"https://api.github.com/repos/freechipsproject/rocket-chip/releases{/id}","deployments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/deployments","created_at":"2014-09-12T07:04:30Z","updated_at":"2018-04-23T14:35:22Z","pushed_at":"2018-04-23T16:19:14Z","git_url":"git://github.com/freechipsproject/rocket-chip.git","ssh_url":"git@github.com:freechipsproject/rocket-chip.git","clone_url":"https://github.com/freechipsproject/rocket-chip.git","svn_url":"https://github.com/freechipsproject/rocket-chip","homepage":null,"size":12814,"stargazers_count":568,"watchers_count":568,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":259,"mirror_url":null,"archived":false,"open_issues_count":83,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":259,"open_issues":83,"watchers":568,"default_branch":"master"}},"base":{"label":"freechipsproject:master","ref":"master","sha":"6d17b7c687fc3c790bf9ff20fbdefa0f873b2cf9","user":{"login":"freechipsproject","id":25232510,"avatar_url":"https://avatars2.githubusercontent.com/u/25232510?v=4","gravatar_id":"","url":"https://api.github.com/users/freechipsproject","html_url":"https://github.com/freechipsproject","followers_url":"https://api.github.com/users/freechipsproject/followers","following_url":"https://api.github.com/users/freechipsproject/following{/other_user}","gists_url":"https://api.github.com/users/freechipsproject/gists{/gist_id}","starred_url":"https://api.github.com/users/freechipsproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freechipsproject/subscriptions","organizations_url":"https://api.github.com/users/freechipsproject/orgs","repos_url":"https://api.github.com/users/freechipsproject/repos","events_url":"https://api.github.com/users/freechipsproject/events{/privacy}","received_events_url":"https://api.github.com/users/freechipsproject/received_events","type":"Organization","site_admin":false},"repo":{"id":23950406,"name":"rocket-chip","full_name":"freechipsproject/rocket-chip","owner":{"login":"freechipsproject","id":25232510,"avatar_url":"https://avatars2.githubusercontent.com/u/25232510?v=4","gravatar_id":"","url":"https://api.github.com/users/freechipsproject","html_url":"https://github.com/freechipsproject","followers_url":"https://api.github.com/users/freechipsproject/followers","following_url":"https://api.github.com/users/freechipsproject/following{/other_user}","gists_url":"https://api.github.com/users/freechipsproject/gists{/gist_id}","starred_url":"https://api.github.com/users/freechipsproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freechipsproject/subscriptions","organizations_url":"https://api.github.com/users/freechipsproject/orgs","repos_url":"https://api.github.com/users/freechipsproject/repos","events_url":"https://api.github.com/users/freechipsproject/events{/privacy}","received_events_url":"https://api.github.com/users/freechipsproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freechipsproject/rocket-chip","description":"Rocket Chip Generator","fork":false,"url":"https://api.github.com/repos/freechipsproject/rocket-chip","forks_url":"https://api.github.com/repos/freechipsproject/rocket-chip/forks","keys_url":"https://api.github.com/repos/freechipsproject/rocket-chip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freechipsproject/rocket-chip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freechipsproject/rocket-chip/teams","hooks_url":"https://api.github.com/repos/freechipsproject/rocket-chip/hooks","issue_events_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/events{/number}","events_url":"https://api.github.com/repos/freechipsproject/rocket-chip/events","assignees_url":"https://api.github.com/repos/freechipsproject/rocket-chip/assignees{/user}","branches_url":"https://api.github.com/repos/freechipsproject/rocket-chip/branches{/branch}","tags_url":"https://api.github.com/repos/freechipsproject/rocket-chip/tags","blobs_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/refs{/sha}","trees_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freechipsproject/rocket-chip/statuses/{sha}","languages_url":"https://api.github.com/repos/freechipsproject/rocket-chip/languages","stargazers_url":"https://api.github.com/repos/freechipsproject/rocket-chip/stargazers","contributors_url":"https://api.github.com/repos/freechipsproject/rocket-chip/contributors","subscribers_url":"https://api.github.com/repos/freechipsproject/rocket-chip/subscribers","subscription_url":"https://api.github.com/repos/freechipsproject/rocket-chip/subscription","commits_url":"https://api.github.com/repos/freechipsproject/rocket-chip/commits{/sha}","git_commits_url":"https://api.github.com/repos/freechipsproject/rocket-chip/git/commits{/sha}","comments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/comments{/number}","issue_comment_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/comments{/number}","contents_url":"https://api.github.com/repos/freechipsproject/rocket-chip/contents/{+path}","compare_url":"https://api.github.com/repos/freechipsproject/rocket-chip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freechipsproject/rocket-chip/merges","archive_url":"https://api.github.com/repos/freechipsproject/rocket-chip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freechipsproject/rocket-chip/downloads","issues_url":"https://api.github.com/repos/freechipsproject/rocket-chip/issues{/number}","pulls_url":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls{/number}","milestones_url":"https://api.github.com/repos/freechipsproject/rocket-chip/milestones{/number}","notifications_url":"https://api.github.com/repos/freechipsproject/rocket-chip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freechipsproject/rocket-chip/labels{/name}","releases_url":"https://api.github.com/repos/freechipsproject/rocket-chip/releases{/id}","deployments_url":"https://api.github.com/repos/freechipsproject/rocket-chip/deployments","created_at":"2014-09-12T07:04:30Z","updated_at":"2018-04-23T14:35:22Z","pushed_at":"2018-04-23T16:19:14Z","git_url":"git://github.com/freechipsproject/rocket-chip.git","ssh_url":"git@github.com:freechipsproject/rocket-chip.git","clone_url":"https://github.com/freechipsproject/rocket-chip.git","svn_url":"https://github.com/freechipsproject/rocket-chip","homepage":null,"size":12814,"stargazers_count":568,"watchers_count":568,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":259,"mirror_url":null,"archived":false,"open_issues_count":83,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":259,"open_issues":83,"watchers":568,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369"},"html":{"href":"https://github.com/freechipsproject/rocket-chip/pull/1369"},"issue":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/1369"},"comments":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/issues/1369/comments"},"review_comments":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369/comments"},"review_comment":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/pulls/1369/commits"},"statuses":{"href":"https://api.github.com/repos/freechipsproject/rocket-chip/statuses/ee795af295e4053b124f369fac7ad2840e1510b9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hcook"}}