- 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?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Kiran Kintali
2025-3-14
编辑:Kiran Kintali
2025-3-24
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 User-Defined MATLAB Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!