SLASH CMake Modules

July 14, 2026 · View on GitHub

Build-system support for HLS kernel compilation, FPGA vbin linking, and AMD tool discovery.

ModulePurpose
SlashTools.cmakeSLASH linker integration (add_vbin)
BuildHLS.cmakeHLS kernel compilation (build_hls, build_hls_dir, build_hls_clean)
FindVivado.cmakeLocate AMD Vivado installation
FindVitis.cmakeLocate AMD Vitis HLS installation
CheckSlashInstall.cmakeValidate SLASH hardware files are installed

Using the modules

Installed mode (after cmake --install):

find_package(SlashTools REQUIRED)

Modules are installed to <prefix>/lib/cmake/SlashTools/. find_package(SlashTools) automatically brings in BuildHLS, FindVivado, and FindVitis.

Source-tree mode (development against local repo):

list(APPEND CMAKE_MODULE_PATH "${SLASH_REPO_ROOT}/cmake")
include(SlashTools)

Module reference

SlashTools — add_vbin()

Links HLS kernel IP into a vbin file using the SLASH linker.

add_vbin(
    TARGET   <target-name>
    PLATFORM <hw|sim|emu>
    CFG      <path/to/config.cfg>
    KERNELS  <kernel1.xml> [kernel2.xml ...]
)
ParameterRequiredDescription
TARGETyesName of the CMake target to create
PLATFORMyesTarget platform: hw, sim, or emu
CFGyesPath to the linker configuration file
KERNELSyesList of kernel component.xml files to link

Output: ${CMAKE_CURRENT_BINARY_DIR}/<TARGET>.vbin

Linker detection (two modes, tried in order):

  1. Installed — finds slashkit on PATH
  2. Source tree — uses SLASH_REPO_ROOT (or auto-detects from ../linker/src/main.py relative to this directory). Requires Python 3.

Variables set after loading:

VariableDescription
SLASH_FOUNDTRUE when SlashTools is ready
SLASHKIT_EXECUTABLEPath to slashkit (installed mode)
SLASH_REPO_ROOTPath to SLASH repo root (source mode)
VIVADO_BINARYPath to vivado (from FindVivado)
VITIS_ROOT_DIRPath to Vitis root (from FindVitis)

BuildHLS — build_hls(), build_hls_dir(), build_hls_clean()

Compiles HLS kernels using v++ and vitis-run. Both executables must be on PATH.

build_hls() — single kernel

build_hls(
    TARGET  <target-name>
    CPP     <source.cpp>
    CFG     <config.cfg>
    DEVICE  <part-name>
    [OUT_DIR <output-directory>]
)
ParameterRequiredDescription
TARGETyesCMake target name
CPPyesHLS C++ source file
CFGyesVitis HLS configuration file
DEVICEyesFPGA part (e.g. xcv80-lsva4737-2MHP-e-S)
OUT_DIRnoOutput directory (default: CMAKE_CURRENT_BINARY_DIR)

Sets target properties HLS_BUILD_DIR and HLS_COMPONENT_XML, and parent-scope variables ${TARGET}_BUILD_DIR and ${TARGET}_COMPONENT_XML.

build_hls_dir() — batch build

build_hls_dir(
    TARGET   <target-name>
    ROOT     <source-directory>
    DEVICE   <part-name>
    KERNELS  <kernel1> [kernel2 ...]
    [OUT_DIR     <output-directory>]
    [OUT_IP_REPO <variable>]
    [OUT_KERNELS <variable>]
)

For each kernel name K, expects ROOT/K.cpp and ROOT/K.cfg. Creates individual build targets and a parent target that depends on all of them.

ParameterRequiredDescription
TARGETyesParent CMake target name
ROOTyesDirectory containing <kernel>.cpp and .cfg
DEVICEyesFPGA part name
KERNELSyesList of kernel names
OUT_DIRnoOutput directory
OUT_IP_REPOnoVariable to receive the IP repository path
OUT_KERNELSnoVariable to receive the list of component.xml files

build_hls_clean() — remove build artifacts

build_hls_clean(
    TARGET  <target-name>
    DEVICE  <part-name>
    [ROOT   <directory>]
    [EXTRA_GLOBS <pattern> ...]
)

Creates a target that removes build_*.DEVICE directories, log files, .Xil, and CMake cache artifacts.

FindVivado

Locates the AMD Vivado installation.

find_package(Vivado REQUIRED)

Search order:

  1. VIVADO_ROOT_DIR CMake variable
  2. XILINX_VIVADO environment variable
  3. System PATH
VariableDescription
VIVADO_FOUNDTRUE if Vivado was found
VIVADO_PATHDirectory containing vivado
VIVADO_ROOT_DIRVivado installation root
VIVADO_BINARYFull path to vivado executable

FindVitis

Locates the AMD Vitis HLS installation.

find_package(Vitis REQUIRED)

Search order:

  1. VITIS_ROOT_DIR CMake variable
  2. XILINX_VITIS environment variable
  3. VITIS_HOME environment variable
  4. VITIS environment variable
  5. System PATH
VariableDescription
VITIS_FOUNDTRUE if Vitis was found
VITIS_BINARYFull path to vitis executable
VITIS_ROOT_DIRVitis installation root
VITIS_INCLUDE_DIR${VITIS_ROOT_DIR}/include (validated)

CheckSlashInstall

Validates that SLASH hardware files are installed.

include(CheckSlashInstall)

Checks for five required files in INSTALL_DIR (default /opt/amd/slash):

  • static_shell_service_layer.dcp
  • static_shell_slash.dcp
  • amd_v80_gen5x8_25.1.pdi
  • amd_v80_gen5x8_25.1_nofpt.pdi
  • top_wrapper_routed_bb.dcp

Override the install path:

set(INSTALL_DIR "/custom/path")
include(CheckSlashInstall)

Typical integration

cmake_minimum_required(VERSION 3.20)
project(my_v80_project)

option(SLASH_USE_REPO "Build against local SLASH repo" OFF)

if(SLASH_USE_REPO)
    set(SLASH_REPO_ROOT "/path/to/SLASH")
    list(APPEND CMAKE_MODULE_PATH "${SLASH_REPO_ROOT}/cmake")
    include(SlashTools)
else()
    find_package(vrt REQUIRED CONFIG)
    find_package(SlashTools REQUIRED)
endif()

set(DEVICE "xcv80-lsva4737-2MHP-e-S")

# Build HLS kernels
build_hls_dir(
    TARGET  hls
    ROOT    "${CMAKE_CURRENT_SOURCE_DIR}/hls"
    DEVICE  "${DEVICE}"
    KERNELS increment accumulate
    OUT_KERNELS _KERNEL_XMLS
)

# Link into a vbin
add_vbin(
    TARGET   my_design_hw
    PLATFORM hw
    CFG      "${CMAKE_CURRENT_SOURCE_DIR}/config.cfg"
    KERNELS  ${_KERNEL_XMLS}
)

File listing

cmake/
  SlashTools.cmake              Linker integration (add_vbin)
  BuildHLS.cmake                HLS kernel build functions
  FindVivado.cmake              Vivado tool finder
  FindVitis.cmake               Vitis HLS tool finder
  CheckSlashInstall.cmake       Installation validator
  SlashToolsConfig.cmake.in     Package config template
  CMakeLists.txt                Module installation

License

MIT. See the license header in each .cmake file for the full text.