hlslib: Software Engineering for Hardware Design

Johannes de Fine Licht, Torsten HoeflerarXiv 2019 · OpenReview

Abstract

High-level synthesis (HLS) tools have brought FPGA development into the mainstream, by allowing programmers to design architectures using familiar languages such as C, C++, and OpenCL. While the move to these languages has brought significant benefits, many aspects of traditional software engineering are still unsupported, or not exploited by developers in practice. Furthermore, designing reconfigurable architectures requires support for hardware constructs, such as FIFOs and shift registers, that are not native to CPU-oriented languages. To address this gap, we have developed hlslib, a collection of software tools, plug-in hardware modules, and code samples, designed to enhance the productivity of HLS developers. The goal of hlslib is two-fold: first, create a community-driven arena of bleeding edge development, which can move quicker, and provides more powerful abstractions than what is provided by vendors; and second, collect a wide range of example codes, both minimal proofs of concept, and larger, real-world applications, that can be reused directly or inspire other work. hlslib is offered as an open source library, containing CMake files, C++ headers, convenience scripts, and examples codes, and is receptive to any contribution that can benefit HLS developers, through general functionality or examples.

Introduction

High-Level Synthesis (HLS) has significantly lowered the barrier to entry for FPGA development by allowing the use of C++ and OpenCL. However, the development experience often remains "less-than-smooth" due to several critical gaps. First, there is a semantic gap: C++ is inherently sequential, while hardware is parallel, leading to potential deadlocks in hardware that are invisible in standard software simulations. Second, the tooling is often brittle, relying on vendor-specific Makefiles rather than modern standards like CMake. Finally, implementing common hardware patterns—such as vectorized data paths or balanced reduction trees—often requires error-prone manual bit-manipulation.

The hlslib Framework

To address these challenges, hlslib provides a collection of headers and tools that extend vendor-specific HLS environments (such as Xilinx Vivado HLS and Intel OpenCL). The library is designed to support the developer throughout the entire lifecycle of hardware design.

The hlslib development workflow and its supporting features across different stages of hardware design.

A core innovation of hlslib is its Thread-Safe Simulation environment. To catch deadlocks early, the library provides macros that launch HLS functions as separate C++ threads. This forces the software simulation to behave like parallel hardware, allowing developers to debug synchronization issues in seconds rather than waiting for day-long hardware compilations. Additionally, hlslib offers robust CMake Integration to handle complex environment variables and compiler flags, enabling portable, out-of-source builds.

Hardware-Centric Abstractions

Rather than hoping an HLS compiler will correctly infer hardware structures from sequential code, hlslib advocates for explicit, templated abstractions. This approach gives developers more control and makes the hardware intent of the code explicit.

Example of a shift register abstraction used for sliding window operations in a compute pipeline.

Key hardware-centric classes include:

  • DataPack: A templated class for wide data buses that supports native indexing and element-wise operations, replacing messy bit-vector casting.
  • ShiftRegister: An explicit abstraction for sliding window buffers (common in image processing and stencils) that allows for compile-time constant offset access.
  • TreeReduce: Uses variadic templates to automatically generate balanced binary reduction trees, ensuring optimal latency and resource usage for operations like floating-point addition.

Adoption and Key Insights

hlslib has been validated through its use in large-scale research projects, including the Data-Centric Parallel Programming (DaCe) framework and the Streaming Message Interface (SMI). The library's primary insight is that simulation should be a "first-class citizen"; by making software simulation stricter (e.g., using bounded, thread-safe streams), developers can identify architectural flaws that standard simulators might overlook.

Furthermore, the library provides a unified OpenCL wrapper that hides subtle differences between Xilinx and Intel platforms, significantly improving the portability of host-side code.

Conclusion

While hlslib cannot solve the fundamental "black box" nature of vendor-specific placement and routing, it significantly improves the productivity of the design and simulation phases. By bringing modern software engineering practices to HLS, it allows developers to focus on architecture rather than tooling overhead. Future work involves expanding the library with more community-driven examples and bleeding-edge abstractions.

Summary updated

BibTeX
@misc{licht2019hlslib,
  author = {Johannes de Fine Licht and Torsten Hoefler},
  title = {{hlslib: Software Engineering for Hardware Design}},
  year = {2019},
  eprint = {1910.04436},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1910.04436},
}
Figure