Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add emitSystemVerilog method to ChiselStage #1534

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/main/scala/chisel3/stage/ChiselStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down