When you generate HDL code from your MATLAB® design, you are converting an algorithm into an architecture that must meet hardware area and speed requirements.
Your MATLAB design has the following requirements:
MATLAB code within the design must be supported for HDL code generation.
Inputs and outputs must not be matrices or structures.
If you are generating code from the command line, verify your code readiness for code generation with the following command:
coder.screener('design_function_name')
For a MATLAB language support reference, including supported functions from the Fixed-Point Designer™, see Functions Supported for HDL Code Generation.
For better HDL code and faster code generation, design your MATLAB code according to the following best practices:
Serialize your input and output data. Parallel data processing structures require more hardware resources and a higher pin count.
Use add and subtract algorithms instead of algorithms that use functions like sine, divide, and modulo. Add and subtract operations use fewer hardware resources.
Avoid large arrays and matrices. Large arrays and matrices require more registers and RAM for storage.
Convert your code from floating-point to fixed-point. Floating-point data types are inefficient for hardware realization. HDL Coder™ provides an automated workflow for floating-point to fixed-point conversion.
Unroll loops to increase speed at the cost of higher area; unroll fewer loops and enable the loop streaming optimization to conserve area at the cost of lower throughput.