Skip to content

Commit

Permalink
Add dumpAnnotations method to Driver
Browse files Browse the repository at this point in the history
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
  • Loading branch information
seldridge committed Sep 28, 2018
1 parent c316a0a commit 65fe4c3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/scala/chisel3/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 65fe4c3

Please sign in to comment.