- https://www.mathworks.com/help/releases/R2025a/hdlcoder/ug/resolving-index-out-of-bounds-errors-during-simulation.html
- https://www.mathworks.com/help/releases/R2025a/hdlcoder/ug/indexing-best-practices-for-hdl-code-generation.html
Is it possible to change Simulink MATLAB Function Block 1-indexing to 0-indexing?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Is it possible to change Simulink MATLAB Function Block 1-indexing to 0-indexing? When using a MATLAB function block in a Simulink model (intended for HDL coder), I always have to do a +1 if I use an input to the function block that indexes into anything inside the function block. This feels like wasted logic in the HDL Coder output and causes confusion during design.
Is it possible to make a MATLAB function block accept 0-indexed values?
Does the +1 I add (either inside of out outside of) the MATLAB block actualy generate additional hardware during synthesis or is HDL coder smart enough to get rid of the +1 and 0 index everything?
0 Commenti
Risposta accettata
Kiran Kintali
il 14 Mar 2025
Modificato: Kiran Kintali
il 24 Mar 2025
If possible can you share your model and the version of MATLAB you are using?
There are few tricks in MATLAB coding and design patterns that help you avoid unnecessary +1/-1 correction due to MATLAB being 1-based and HDL being 0-based indexing.
These two pages touch up on this topic briefly.
Do not hesitate to reach out to tech support for additional help. HDL Coder works to avoid any unnecessary logic and treats such logic generation as a bug. A reproduction model would greatly help in reducing the occurance of such logic.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su User-Defined MATLAB Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!