From 65fe4c331ff6bf7c2bad65d4e8ce08e0c397c739 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Fri, 24 Aug 2018 13:39:08 -0400 Subject: Add dumpAnnotations method to Driver Signed-off-by: Schuyler Eldridge --- src/main/scala/chisel3/Driver.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') 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 -- cgit v1.2.3