Skip to content

Commit

Permalink
[FIRTOOL] More sane chisel interface directory handling (#6687)
Browse files Browse the repository at this point in the history
Deal with a few more situations when outputting chisel interfaces.
  • Loading branch information
darthscsi committed Feb 21, 2024
1 parent e8f4f34 commit 5544820
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Firtool/Firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ LogicalResult firtool::populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm,
pm.nest<firrtl::CircuitOp>().addPass(firrtl::createInferResetsPass());

if (opt.shouldExportChiselInterface()) {
if (opt.getChiselInterfaceOutputDirectory().empty()) {
StringRef outdir = opt.getChiselInterfaceOutputDirectory();
if (opt.isDefaultOutputFilename() && outdir.empty()) {
pm.nest<firrtl::CircuitOp>().addPass(createExportChiselInterfacePass());
} else {
pm.nest<firrtl::CircuitOp>().addPass(createExportSplitChiselInterfacePass(
opt.getChiselInterfaceOutputDirectory()));
if (outdir.empty())
outdir = opt.getOutputFilename();
pm.nest<firrtl::CircuitOp>().addPass(
createExportSplitChiselInterfacePass(outdir));
}
}

Expand Down
4 changes: 4 additions & 0 deletions test/firtool/chisel-interface.fir
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
; RUN: firtool %s --disable-output --export-chisel-interface --chisel-interface-out-dir %t
; RUN: FileCheck %s -input-file=%t/Foo.scala

; Test exporting a Chisel interface to the default directory.
; RUN: firtool %s --split-verilog --export-chisel-interface -o %t
; RUN: FileCheck %s -input-file=%t/Foo.scala

; CHECK-LABEL: // Generated by CIRCT
; CHECK-LABEL: package shelf.foo
; CHECK-LABEL: import chisel3._
Expand Down

0 comments on commit 5544820

Please sign in to comment.