summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/Driver.scala
diff options
context:
space:
mode:
authorSchuyler Eldridge2018-08-24 13:39:08 -0400
committerSchuyler Eldridge2018-09-28 11:34:15 -0400
commit65fe4c331ff6bf7c2bad65d4e8ce08e0c397c739 (patch)
treee459212863c7f3a7d15e3707246fcc6629fd0b30 /src/main/scala/chisel3/Driver.scala
parentc316a0a27e908cc2da1b9423d4fdf72e37c79d9b (diff)
Add dumpAnnotations method to Driver
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Diffstat (limited to 'src/main/scala/chisel3/Driver.scala')
-rw-r--r--src/main/scala/chisel3/Driver.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/Driver.scala b/src/main/scala/chisel3/Driver.scala
index 9bc5cd0d..c0570662 100644
--- a/src/main/scala/chisel3/Driver.scala
+++ b/src/main/scala/chisel3/Driver.scala
@@ -127,6 +127,20 @@ object Driver extends BackendCompilationUtilities {
f
}
+ /**
+ * Emit the annotations of a circuit
+ *
+ * @param ir The circuit containing annotations to be emitted
+ * @param optName An optional filename (will use s"${ir.name}.json" otherwise)
+ */
+ def dumpAnnotations(ir: Circuit, optName: Option[File]): File = {
+ val f = optName.getOrElse(new File(ir.name + ".anno.json"))
+ val w = new FileWriter(f)
+ w.write(JsonProtocol.serialize(ir.annotations.map(_.toFirrtl)))
+ w.close()
+ f
+ }
+
/** Dumps the elaborated Circuit to ProtoBuf
*
* If no File is given as input, it will dump to a default filename based on the name of the