Elixir HLS makes FPGA circuits from functions written in Elixir
Elixir HLS introduces a fascinating paradigm for FPGA development, allowing Elixir functions to be synthesized directly into hardware circuits. This innovative approach lets developers leverage Elixir's elegance for hardware design, abstracting away low-level RTL complexities. It appeals to HN's interest in novel programming paradigms, functional programming in new domains, and bridging software with hardware.
The Lowdown
Elixir HLS is an ambitious new project that brings High-Level Synthesis (HLS) to the Elixir ecosystem, enabling developers to define FPGA circuits using standard Elixir functions. This tool aims to simplify hardware development by allowing engineers to write "what to compute" in a high-level language, letting the synthesis tool handle the intricate details of register transfer logic.
- High-Level Synthesis (HLS): Instead of writing hardware description languages like Verilog or VHDL at the Register Transfer Level (RTL), Elixir HLS generates RTL from Elixir code, abstracting away clock cycles and register management.
- Dual-Purpose Functions: Functions defined with
defhlsare ordinary Elixir functions that run on the CPU, but they can also be compiled into FPGA circuits. The Elixir function serves as the specification, and the tool verifies the circuit's behavior against it. - Current Status & Capabilities: The project is in its early 0.1.0 release, supporting integer functions, state, tables, memories, and fixed loops. It targets the Sipeed Tang Primer 25K with AtomVM, demonstrated with an FM radio demodulator. Limitations include lack of support for division, floats, recursion, and certain Elixir stream operations.
- Elixir Integration: The tool provides specific types (e.g.,
u32for unsigned 32-bit integers) to define hardware bit widths. It integrates with Elixir's syntax for operators, control flow (if,case,forloops), and a subset ofStreamfunctions (likemap,filter). - Hardware Interaction:
definstanceallows placing Elixir functions as circuits. It supports calling these instances from the CPU, using CPU-set values in circuits, defining execution location (:cpuor:fpga), and direct interaction with hardware pins and devices (buttons, LEDs, audio, USB) without CPU intervention. - Tooling:
mix ehls.compilegenerates SystemVerilog and simulates the circuit against its Elixir function for correctness. It leverages CIRCT (LLVM's compiler infrastructure for circuits) and Icarus Verilog.
Elixir HLS represents a significant step towards making FPGA programming more accessible and aligned with modern software development practices. By leveraging Elixir's functional paradigm and a robust HLS approach, it offers a compelling vision for future hardware-software co-design, even in its early stages.