Algorithm Design for HLS
R2026bUse your MATLAB algorithm to generate High-Level Synthesis (HLS) code that you can efficiently deploy on hardware. It is important that you use hardware modeling best practices and that you use only the supported MATLAB syntax and functions.
The MATLAB functions and language syntax supported for High-Level Synthesis code generation are available on this page. If your MATLAB algorithm uses an unsupported function, you can generate code by replacing the function with a lookup table approximation. See Replace a Function with a Lookup Table from the Command Line.
You can write MATLAB code to model state machines and implement hardware elements such as counters and RAM for High-Level Synthesis (HLS) code generation. When authoring the code, follow for loop best practices and guidelines to write efficient MATLAB code to generate HLS code.
Topics
Supported MATLAB Functions and Data Types
- Functions Supported for HDL and HLS Code Generation
Built-in MATLAB and toolbox functions supported for HDL and High-Level Synthesis (HLS) code generation. - MATLAB Language Features Supported for HLS Code Generation
You can generate HLS code from MATLAB code using the HDL Coder™ Workflow Advisor. - Supported MATLAB Data Types, Operators, and Control Flow Statements
Supported data types, operators, and control flow statements for HDL and High-Level Synthesis (HLS) code generation. - Bitwise Operations in MATLAB for HDL and HLS Code Generation
HDL Coder supports bit shift, bit rotate, bit slice operations that mimic HDL-specific operators without saturation and rounding logic. - Support MATLAB Math Functions for Xilinx Vitis HLS (SoC Blockset)
Support mathematical functions with floating-point types for AMD® Vitis® HLS. (Since R2026a)
Best Practices
- Guidelines for Writing MATLAB Code to Generate Efficient HDL and HLS Code
Guidelines for writing efficient MATLAB code and design requirements for efficient HDL and High-Level Synthesis (HLS) code generation. - Handling Constants in HDL and HLS Code Generation
Usecoder.constandcoder.loadto handle constants during code generation. - Mapping of Different Rounding and Overflow Methods from MATLAB to HLS
Mapping rounding and overflow methods from MATLAB to High-Level Synthesis (HLS). - Replace Arithmetic Operation to Generate Efficient HDL and High-Level Synthesis Code
Best practices for using division operation in your MATLAB code for HDL and High-Level Synthesis (HLS) code generation.
Basic Hardware Modeling
- Model a Counter for HDL and High-Level Synthesis Code Generation
To write MATLAB code that models hardware and is suitable for HDL and High-Level Synthesis (HLS) code generation, use this design pattern. - Model a State Machine for HDL and High-Level Synthesis Code Generation
The following design pattern shows MATLAB examples of Mealy and Moore state machines which are suitable for HDL and High-Level Synthesis (HLS) code generation.