フィルターのクリア

Preferred approach for code generation with MATLAB embedded coder

10 ビュー (過去 30 日間)
Nitin Skandan
Nitin Skandan 2024 年 2 月 20 日
コメント済み: Nitin Skandan 2024 年 2 月 28 日
We are using MATLAB Embedded coder to generate production intent code from our m - scripts. Unlike in the SIMULINK world where people rarely check how the autocode looks like, with code generated from M scripts it is essential to review the code as it might be possible to easily identify changes that could potentially made in M-script to get a more optimal C code. I believe this probably because of the interpreted nature of M-scripts. We usually generate code as batch with a script which generates code for all the M-scripts. However, with this approach the entire C Code needs to be regenerated even for a minor change in just one of the m-files. This makes review of the generated C code tedious. Is this the right approach? Or should each M-script be individually generated, tested and maintained in isolation so that only the m file which has changed need to be regenerated. Is this second approach possible itself ? Even if possible will there be complexities like common files , shared data etc which are usually managed with Data dictionary in SIMULINK world .

採用された回答

Mark McBroom
Mark McBroom 2024 年 2 月 28 日
Why are you manually reviewing the generated C code? Many workflows require review of the MATLAB code and then test cases that test both the MATLAB code and the generated C code ( i.e. SIL testing). This approach confirms that the M code and C code are functionally equivalent and therefore review of the C code is not needed. If manual review is required, you can use coder.inline('never') to force each MATLAB function to be generated as a corresponding C function. This will isloate changes in C code only to those M Functions that changed.
  1 件のコメント
Nitin Skandan
Nitin Skandan 2024 年 2 月 28 日
Hi Mark,
Thank you for the reply.
The manual review is done to ensure that C code is optimal.
i.e. example an unnecessary local variable might introduce a memcpy in the C code and if the local variable is eliminated then C code could be improved. We have Hardware constraints so it is necessary to ensure that C code is as optimised as possible.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEmbedded Coder についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by