How can I add alignments to the structures generated from Simulink bus objects?

How can I add alignments to the structures generated from buses? I want my structure definition to look like below:
typedef __declspec(align(32))
struct {
int f1;
int f2;
} myStruct;

 Accepted Answer

To be able to add alignment to structure definitions you need to use the alignment property of the bus object along with the code replacement library
Step1: Set the desired alignment on the bus object
Step2: Use Code Replacement (CRL) Tool and generate a dummy table (for details of creating tables with CRL tool check Quick Start Code Replacement Library Development - Simulink)
Step3: Generate registry file and set alignment specifications, and the supported languages. Please note that in the alignment syntax %n refers to the alignment value specified in the bus object in Step1:
Step4: Run sl_refresh_customizations :
Step5: Choose the library (which is the registry name you set in Step3) from configuration settings of the model:
After following these steps, if you generate code for the model, it will add alignments to the structure definitions for buses that have set a value for the alignment property in the format you have specified in Step3:
Step6: Add "DATA_ALIGNMENT_GLOBAL_VAR" to the AlignmentType list in the alignment specification within the target file 

More Answers (0)

Categories

Products

Release

R2012b

Community Treasure Hunt

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

Start Hunting!