- 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?
4 ビュー (過去 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!