Guidelines for Efficient HDL Code

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.

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 sin, 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. 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.

Was this topic helpful?