From 395dec62d1669daa1b3a3608e4fcd6221ddcc17a Mon Sep 17 00:00:00 2001 From: John Demme Date: Fri, 15 Nov 2024 18:58:36 -0500 Subject: [PATCH] [hlstool] Add option to use the DC lowering flow (#7819) Adds a `--dc` flag to use HandshakeToDC (and the DC lowering flow) instead of HandshakeToHW. --- tools/hlstool/CMakeLists.txt | 4 ++++ tools/hlstool/hlstool.cpp | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/hlstool/CMakeLists.txt b/tools/hlstool/CMakeLists.txt index 7821c15c7439..0a11c8fb0b9e 100644 --- a/tools/hlstool/CMakeLists.txt +++ b/tools/hlstool/CMakeLists.txt @@ -9,10 +9,14 @@ llvm_update_compile_flags(hlstool) target_link_libraries(hlstool PRIVATE + CIRCTDC + CIRCTDCTransforms + CIRCTDCToHW CIRCTESI CIRCTExportChiselInterface CIRCTExportVerilog CIRCTHandshake + CIRCTHandshakeToDC CIRCTHandshakeToHW CIRCTHandshakeTransforms CIRCTHW diff --git a/tools/hlstool/hlstool.cpp b/tools/hlstool/hlstool.cpp index 9d7f0a14e1c6..1605d2686c4c 100644 --- a/tools/hlstool/hlstool.cpp +++ b/tools/hlstool/hlstool.cpp @@ -46,6 +46,7 @@ #include "circt/Conversion/SCFToCalyx.h" #include "circt/Dialect/Calyx/CalyxDialect.h" #include "circt/Dialect/Calyx/CalyxPasses.h" +#include "circt/Dialect/DC/DCPasses.h" #include "circt/Dialect/ESI/ESIDialect.h" #include "circt/Dialect/ESI/ESIPasses.h" #include "circt/Dialect/SV/SVDialect.h" @@ -218,6 +219,9 @@ static cl::opt withESI("with-esi", cl::desc("Create ESI compatible modules"), cl::init(false), cl::cat(mainCategory)); +static cl::opt withDC("dc", cl::desc("Use the DC flow"), cl::init(false), + cl::cat(mainCategory)); + static LoweringOptionsOption loweringOptions(mainCategory); // -------------------------------------------------------------------------- @@ -332,7 +336,14 @@ static LogicalResult doHLSFlowDynamic( addIRLevel(IRLevel::RTL, [&]() { pm.nest().addPass(createSimpleCanonicalizerPass()); - pm.addPass(circt::createHandshakeToHWPass()); + if (withDC) { + pm.addPass(circt::createHandshakeToDCPass()); + pm.addPass(circt::dc::createDCMaterializeForksSinksPass()); + pm.addPass(createSimpleCanonicalizerPass()); + pm.addPass(circt::createDCToHWPass()); + } else { + pm.addPass(circt::createHandshakeToHWPass()); + } pm.addPass(createSimpleCanonicalizerPass()); loadESILoweringPipeline(pm); });