.. _program_listing_file_lib_Target_EmitHLSToHLSBuildScript_EmitHLSToHLSBuildScript.cpp: Program Listing for File EmitHLSToHLSBuildScript.cpp ==================================================== |exhale_lsh| :ref:`Return to documentation for file ` (``lib/Target/EmitHLSToHLSBuildScript/EmitHLSToHLSBuildScript.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Implementation of translation EmitHLSToHLSBuildScript // // @file // @author Jiahong Bi (jiahong.bi@tu-dresden.de) #include "laksa-mlir/Target/EmitHLSToHLSBuildScript/HLSBuildScriptEmitter.h" #include "laksa-mlir/Target/LaksaCommon/BufferInfo.h" #include "llvm/Support/CommandLine.h" using namespace mlir; using namespace mlir::emithls; namespace { llvm::cl::opt clHLSBuildHLSTcl( "hls-build-hls-tcl", llvm::cl::desc( "Vitis HLS script the generated shell script runs, as produced by the " "emithls-to-hls-tcl translation"), llvm::cl::init("run_hls.tcl")); llvm::cl::opt clHLSBuildVivadoTcl( "hls-build-vivado-tcl", llvm::cl::desc( "Vivado script the generated shell script runs, as produced by the " "emithls-to-vivado-tcl translation"), llvm::cl::init("run_vivado.tcl")); } // namespace //===----------------------------------------------------------------------===// // Translation entry point //===----------------------------------------------------------------------===// LogicalResult emithls::translateEmitHLSToHLSBuildScript(ModuleOp op, raw_ostream &os) { FailureOr topFunc = findLaksaTopFunc(op); if (failed(topFunc)) return failure(); StringRef designName = topFunc->getSymName(); os << "#!/bin/sh\n" "\n" "# Generated by ladle -t emithls-to-hls-build-script.\n" "# Assumes the Vitis and Vivado environment is already sourced.\n" "\n" "set -eu\n" "\n" "cd \"$(dirname \"$0\")\"\n" "\n" "echo \"INFO: Running Vitis HLS through " << clHLSBuildHLSTcl << "...\"\n" "vitis-run --mode hls --tcl " << clHLSBuildHLSTcl << "\n" "\n" "echo \"INFO: Running Vivado through " << clHLSBuildVivadoTcl << "...\"\n" "vivado -mode batch -source " << clHLSBuildVivadoTcl << "\n" "\n" "echo \"INFO: Extracting the bitstream from the exported XSA...\"\n" "unzip -p vivado_project/" << designName << "_bd.xsa " << designName << "_bd.bit > " << designName << ".bit\n" "\n" "echo \"INFO: Done, copy " << designName << ".bit next to app.c on the board\"\n"; return success(); }