HDL coder generate code from Matlab vs Simulink

20 views (last 30 days)
Xiaotong
Xiaotong on 13 Oct 2025 at 5:38
Answered: Umar on 13 Oct 2025 at 12:34
Hi, I am working on a wireless project right now, and i finished some matlab function. Should I transform them into verilog files using HDL Coder directly from matlab function, or should I model them on Simulink with block design and using simulink HDL Coder?
Thanks for your answers!

Accepted Answer

Umar
Umar on 13 Oct 2025 at 12:34

Hi @Xiaotong,

Both workflows are valid, but the right choice depends on how complex your project is and what stage you’re in.

If your MATLAB functions are already algorithmically complete and written using fixed-point or integer types that are compatible with HDL Coder, you can generate Verilog directly from MATLAB using the MATLAB to HDL workflow. It’s quick for isolated algorithm blocks and doesn’t require extra Simulink setup.

However, if your design will be part of a larger system, for example, with multiple data paths, control logic, or timing requirements, it’s better to model it in Simulink first. Using MATLAB Function blocks or supported Simulink blocks gives you more control over sample times, interfaces, and verification. It also makes it easier to simulate the whole system before generating HDL.

In short:

*Simple, standalone functions -> generate HDL directly from MATLAB.*

*System-level or multi-block designs -> use Simulink with HDL Coder.*

Either way, make sure your code uses discrete logic and fixed-point data types for synthesizable HDL.

Hope this helps.

More Answers (0)

Categories

Find more on Code Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!