summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Alcorn2020-07-30 19:29:49 -0700
committerGitHub2020-07-31 02:29:49 +0000
commit8990ca3d8d8434a6c979b0c5fc06b05a39fd31d4 (patch)
tree84926550bf0e7a671e55133b34b294220a86294f /src
parent3b206b5054bc36706f295b3f48f170da8775031f (diff)
Add emitSystemVerilog method to ChiselStage (#1534)
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/stage/ChiselStage.scala20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/scala/chisel3/stage/ChiselStage.scala b/src/main/scala/chisel3/stage/ChiselStage.scala
index 938f0250..ec53757f 100644
--- a/src/main/scala/chisel3/stage/ChiselStage.scala
+++ b/src/main/scala/chisel3/stage/ChiselStage.scala
@@ -73,7 +73,7 @@ class ChiselStage extends Stage with PreservesAll[Phase] {
* @param gen a call-by-name Chisel module
* @param args additional command line arguments to pass to Chisel
* param annotations additional annotations to pass to Chisel
- * @return a string containing the Verilog output
+ * @return a string containing the FIRRTL output
*/
final def emitFirrtl(
gen: => RawModule,
@@ -108,6 +108,24 @@ class ChiselStage extends Stage with PreservesAll[Phase] {
.value
}
+ /** Convert a Chisel module to SystemVerilog
+ * @param gen a call-by-name Chisel module
+ * @param args additional command line arguments to pass to Chisel
+ * param annotations additional annotations to pass to Chisel
+ * @return a string containing the SystemVerilog output
+ */
+ final def emitSystemVerilog(
+ gen: => RawModule,
+ args: Array[String] = Array.empty,
+ annotations: AnnotationSeq = Seq.empty): String = {
+
+ execute(Array("-X", "sverilog") ++ args, ChiselGeneratorAnnotation(() => gen) +: annotations)
+ .collectFirst {
+ case DeletedAnnotation(_, EmittedVerilogCircuitAnnotation(a)) => a
+ }
+ .get
+ .value
+ }
}
object ChiselMain extends StageMain(new ChiselStage)