Abstract
This paper explores the use of the Julia language as a front-end for High-Level Synthesis (HLS), aiming to bridge the gap between high-level algorithmic research and low-level FPGA hardware implementation. By leveraging Julia's native compiler infrastructure, specifically its typed intermediate representation and multiple dispatch capabilities, the authors present a prototype tool that translates high-level Julia code into synthesizable VHDL. While the prototype currently shows an optimization gap compared to mature C++ tools, it demonstrates the potential for a unified language approach to hardware-software co-design.
Introduction
Field-Programmable Gate Arrays (FPGAs) offer significant performance and energy efficiency for specialized tasks like machine learning and real-time control. However, they suffer from a persistent "two-language problem." Researchers typically prototype algorithms in high-level, math-friendly languages like Python or MATLAB, while hardware engineers must manually translate these algorithms into low-level Hardware Description Languages (HDLs) like VHDL or Verilog, or use C++-based HLS tools that still require hardware-specific expertise.
Julia is uniquely positioned to solve this problem. Designed to combine the ease of Python with the performance of C, Julia’s architecture allows the same code used for research to be compiled directly to hardware, potentially unifying the development workflow.
Methods
The authors developed a prototype HLS toolflow integrated directly into the Julia ecosystem. Unlike traditional HLS tools that require custom parsers, this tool hooks into the existing Julia compiler at the Typed Intermediate Representation (IR) stage, where data types for every variable have already been inferred.
The process involves several key steps:
- Compiler Hooking: Extracting the Typed IR from the Julia compiler.
- Graph Construction: Converting the IR into a Control Data-Flow Graph (CDFG) using the
SSATools.jlpackage. - Dynamic Scheduling: Utilizing "elastic components" (based on the Dynamatics tool) to allow for data-driven execution.
- VHDL Generation: Translating the graph into synthesizable VHDL via the
DynamicScheduling.jlpackage.
This flow leverages Julia's Multiple Dispatch to automatically replace standard CPU operators with hardware-optimized versions without requiring changes to the user's source code.
Key Insights and Ideas
- The "Pure Julia" Advantage: Many Julia libraries are written in Julia itself rather than wrapping C++ code. This allows the HLS tool to recurse into standard libraries and generate hardware automatically.
- Type Stability: Julia’s built-in data-flow type inference ensures types are known at compile-time, which is essential for defining bit-widths and circuitry in hardware synthesis.
- Metaprogramming: Julia’s macro system allows the tool to manipulate the Abstract Syntax Tree (AST) for hardware-specific optimizations like loop unrolling or pipeline balancing.
Key Results
The prototype was evaluated using three programmatic test cases: if_else (conditional branching), power (loop-based exponentiation), and newton_raphson (complex root-finding). These were compared against a baseline generated from C++ using the Dynamatics tool.
While the tool successfully generated synthesizable VHDL for all cases, the Julia-to-hardware path is currently less efficient than the C++ path. In the complex Newton-Raphson test, the Julia tool produced significantly more "Basic Blocks" and "Components." This discrepancy is attributed to the lack of mature optimization passes in the Julia prototype compared to those found in established LLVM-based C++ compilers.
Limitations and Future Work
The current prototype faces several challenges that define future research directions:
- Optimization Gap: Implementing sophisticated optimization passes for the Julia IR to consolidate code blocks.
- Memory Integration: Adding support for data memory (RAM) to handle large arrays and complex structures.
- Scheduling: Moving from purely dynamic scheduling to static scheduling for more resource-efficient and deterministic designs.
- Ecosystem Integration: Ensuring compatibility with open-source synthesis tools like Yosys and libraries like FloPoCo.
Summary updated