diff options
| author | Adam Izraelevitz | 2017-09-06 13:24:20 -0700 |
|---|---|---|
| committer | GitHub | 2017-09-06 13:24:20 -0700 |
| commit | a97fbfca90ba1a2604c89d3595a49d5260bd5f91 (patch) | |
| tree | 8655572083aaf26200e95d9982ef26b6b78dde55 | |
| parent | 1be90a1e04383675f5b6d967872904ee3dd55faf (diff) | |
Added API to get Verilog from Chisel (#676)
* Added API to get Verilog from Chisel
* Removed second emitVerilog implementation, added scaladoc
| -rw-r--r-- | src/main/scala/chisel3/Driver.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/Driver.scala b/src/main/scala/chisel3/Driver.scala index f3ba6534..d138bf1f 100644 --- a/src/main/scala/chisel3/Driver.scala +++ b/src/main/scala/chisel3/Driver.scala @@ -95,6 +95,18 @@ object Driver extends BackendCompilationUtilities { def emit[T <: RawModule](ir: Circuit): String = Emitter.emit(ir) + /** Elaborates the Module specified in the gen function into Verilog + * + * @param gen a function that creates a Module hierarchy + * @return the resulting String containing the design in Verilog + */ + def emitVerilog[T <: RawModule](gen: => T): String = { + execute(Array[String](), { () => gen }) match { + case ChiselExecutionSuccess(_, _, Some(firrtl.FirrtlExecutionSuccess(_, verilog))) => verilog + case _ => sys.error("Cannot get Verilog!") + } + } + def dumpFirrtl(ir: Circuit, optName: Option[File]): File = { val f = optName.getOrElse(new File(ir.name + ".fir")) val w = new FileWriter(f) |
