From 5544820ba75dc9c4beb0be868fdb337323834f79 Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Wed, 21 Feb 2024 10:02:06 -0600 Subject: [PATCH] [FIRTOOL] More sane chisel interface directory handling (#6687) Deal with a few more situations when outputting chisel interfaces. --- lib/Firtool/Firtool.cpp | 9 ++++++--- test/firtool/chisel-interface.fir | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Firtool/Firtool.cpp b/lib/Firtool/Firtool.cpp index 47e5781d281..22b964e9e53 100644 --- a/lib/Firtool/Firtool.cpp +++ b/lib/Firtool/Firtool.cpp @@ -80,11 +80,14 @@ LogicalResult firtool::populateCHIRRTLToLowFIRRTL(mlir::PassManager &pm, pm.nest().addPass(firrtl::createInferResetsPass()); if (opt.shouldExportChiselInterface()) { - if (opt.getChiselInterfaceOutputDirectory().empty()) { + StringRef outdir = opt.getChiselInterfaceOutputDirectory(); + if (opt.isDefaultOutputFilename() && outdir.empty()) { pm.nest().addPass(createExportChiselInterfacePass()); } else { - pm.nest().addPass(createExportSplitChiselInterfacePass( - opt.getChiselInterfaceOutputDirectory())); + if (outdir.empty()) + outdir = opt.getOutputFilename(); + pm.nest().addPass( + createExportSplitChiselInterfacePass(outdir)); } } diff --git a/test/firtool/chisel-interface.fir b/test/firtool/chisel-interface.fir index c8acf68291d..d8f183844b4 100644 --- a/test/firtool/chisel-interface.fir +++ b/test/firtool/chisel-interface.fir @@ -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._