High-Level Synthesis (HLS) has emerged as a powerful tool for bridging the gap between software development and hardware design, allowing developers to compile C-based code into Register-Transfer Level (RTL) for FPGAs. However, a significant "semantic gap" remains: while developers write sequential code, hardware executes in a massively parallel fashion. When bugs occur in-system, traditional hardware debugging tools provide waveforms—complex digital signals that are nearly impossible for software engineers to map back to their original source code.
Presented at the 2015 FSP Workshop, this research introduces HLS-Scope, a debug framework integrated into the LegUp HLS tool. It enables software developers to debug FPGA hardware using familiar paradigms like source-level stepping and variable inspection, effectively making hardware debugging feel like using gdb.
The Challenge of HLS Debugging
Debugging HLS-generated hardware is difficult because bugs manifest at different levels of abstraction. While kernel-level bugs can be caught on a workstation using standard debuggers, system-level bugs often only appear when the hardware is running on the physical FPGA. These bugs are frequently dependent on interaction timings and are notoriously hard to reproduce.
Traditional tools like SignalTap or ChipScope require users to interpret waveforms. Furthermore, HLS compilers often reorder or optimize code so heavily that the resulting hardware logic bears little resemblance to the original C source, leaving developers "blind" during in-system failures.
The HLS-Scope Framework
To address these issues, the authors developed a debug ecosystem that abstracts hardware complexity into software-centric visualizations. The core of the framework is a GUI that replaces traditional waveforms with Gantt charts.
Key Technical Components
- Gantt Chart Visualization: The tool displays a Gantt chart where the Y-axis represents lines of C code and the X-axis represents time (control steps). This allows developers to see exactly which lines of code are executing in parallel at any given moment.
- Live vs. Replay Modes:
- Live Mode allows users to pause the hardware state machine to inspect memory and variables directly from the FPGA.
- Replay Mode is the framework's core innovation. The hardware runs at full speed while on-chip "trace buffers" record control flow. The debugger then uses this data to allow the user to step forward and even backward through the execution trace.
- Intermediate Representation (IR) Exposure: To help users navigate complex compiler optimizations like loop unrolling, the tool provides a panel showing the underlying LLVM IR instructions associated with each C statement.
Key Insights: Debugging Optimized Code
A common pitfall in software debugging is disabling optimizations (-O0) to make the code easier to follow. The authors argue this is a mistake for HLS. Many hardware bugs are timing-related or interface-dependent; changing the optimization level changes the hardware timing entirely, which can hide the very bug being investigated. Consequently, HLS-Scope is designed to support debugging highly optimized (-O3) hardware, ensuring that the developer sees the exact logic that failed.
Results and Limitations
The framework was successfully integrated into the LegUp open-source HLS ecosystem. Using benchmarks like Quicksort and AES encryption, the authors demonstrated that their instrumentation is efficient, recording approximately 4,322 lines of C execution per 100Kb of on-chip memory.
Despite its success, the tool currently focuses on single-threaded software and instruction-level parallelism. Future work aims to support coarse-grained, thread-level parallelism (such as Pthreads or OpenMP) and to further reduce the resource overhead required by the on-chip trace buffers, which can impact the maximum operating frequency ($f_{max}$) of the design.
Summary updated