Is it possible to change Simulink MATLAB Function Block 1-indexing to 0-indexing?

5 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Kiran Kintali
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.

Più risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by