Because of the way that circt.stage.ChiselStage works it needs to take control of the output file options in order for things to not break. I haven’t found a good way of checking this other than throwing errors after parsing FirtoolOptions which seems pretty bad.
What I’d suggest is to use the ChiselStage object’s emitSystemVerilogFile method instead with the --target-dir and, optionally, --split-verilog option.
A full example is the following:
//> using scala "2.13.11"
//> using lib "org.chipsalliance::chisel::6.0.0-M3"
//> using plugin "org.chipsalliance:::chisel-plugin::6.0.0-M3"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"
import chisel3._
import circt.stage.ChiselStage
class Bar extends RawModule {
val a = IO(Input(Bool()))
val b = IO(Output(Bool()))
b :<>= a
}
class Foo extends Module {
val a = IO(Input(Bool()))
val b = IO(Output(Bool()))
val bar = Module(new Bar)
bar.a :<>= a
b :<>= bar.b
}
object Main extends App {
ChiselStage.emitSystemVerilogFile(new Foo, Array("--target-dir", "unified/"))
ChiselStage.emitSystemVerilogFile(
new Foo,
Array("--target-dir", "split/", "--split-verilog")
)
}