How to create custom data type acronyms in code generation

12 次查看(过去 30 天)
Hello,
I am generating code from a Simulink model using Simulink Coder and Embedded Coder, and I need my own data type names. For example, for the Simulink data type double, I need FLOAT64. I solved this by using Replacement names and creating a data dictionary with the replacement names assigned to the Simulink names. However, this created a problem because now when I want to use the data type acronym ($A) in the "Identifiers" tab, it doesn’t work. Instead of r64_ for double, it puts the whole replacement name FLOAT64_. Is there a way to fix this?
In addition to my question I would like to ask if it is possible to change what the $A generates. Let’s say I want for double types to generate the acronym f64_ instead of r64_. Is there a way to change this? The only thing I found out is the "type limit identifier replacement header file" option in the data type replacement tab. I haven’t experimented much with it yet, and there isn’t much information about what this option does on MATLAB help. But from what I have read I feel like this option is only for the minimum and maximum data limits. The only other option that comes to my mind is to change it directly in the file that ensure the generation of the acronym. But I am not even sure if I have the rights to do that or if it is some kind of .P file.

采纳的回答

Akshat Dalal
Akshat Dalal 2024-8-17,5:23
编辑:Akshat Dalal 2024-8-17,5:25
Hi Marek,
Unfortunately, Simulink Coder does not provide a direct way to customize the $A acronym for data types when using replacement names. The $A identifier uses the full data type name as specified in the replacement list.
I would suggest you to create a MATLAB script to post-process the generated code files. This script can replace occurrences of FLOAT64_ with f64_ in the generated files. Although this requires manual intervention or automation, it provides flexibility. Creating post-build hooks is a well-documented infrastructure: www.mathworks.com/help/releases/R2023b/rtw/ug/customizing-post-code-generation-build-processing.html
I don't think it would be possible to modify the .p internal files but you could contact their technical support to find if there is a workaround.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by