Main Content

Configure Dimension Variants for AUTOSAR Array Sizes

AUTOSAR software components can flexibly specify the dimensions of an AUTOSAR element, such as a port, by using a symbolic reference to a system constant. The system constant defines the array size of the port data type. To model AUTOSAR elements with variant array sizes in Simulink®:

  • Create blocks that represent AUTOSAR elements.

  • To represent array size values, add AUTOSAR.Parameter data objects with storage class SystemConstant.

  • To specify an array size for an AUTOSAR element, reference an AUTOSAR.Parameter data object.

With variant array sizes, you can modify array size values in system constants between model simulations, without regenerating code for simulation. When you build the model, the generated C and ARXML code contains symbols corresponding to variant array sizes.

Suppose that you create a Simulink inport In1 to represent an AUTOSAR receiver port with a variant array size.

To model the AUTOSAR system constant that specifies the dimensions of In1, create an AUTOSAR.Parameter data object, SymDimA, with storage class SystemConstant. The data type must be a signed 32-bit integer type.

SymDimA = AUTOSAR.Parameter;
SymDimA.CoderInfo.StorageClass = 'custom';
SymDimA.CoderInfo.CustomStorageClass = 'SystemConstant';
SymDimA.DataType = 'int32';
SymDimA.Min = 1;
SymDimA.Max = 100;
SymDimA.Value = 5;

In the dialog box for inport block In1, Signal Attributes tab, Port dimensions field, enter the parameter name, SymDimA.

To allow symbolic dimensions to propagate throughout the model, you must select the model configuration option Allow symbolic dimension specification.

When you generate code for the model, the name of the system constant, SymDimA, appears in C and ARXML code to represent the variant array size. Here is a sample of the generated C code:

/* SignalConversion generated from: '<Root>/Vector Concatenate' */
for (i = 0; i < Rte_SysCon_SymDimA; i++) {
  rtb_VectorConcatenate[i] = tmpIRead[i];

Here is a sample of the exported ARXML descriptions:

<MAX-NUMBER-OF-ELEMENTS BINDING-TIME="PRE-COMPILE-TIME">
  <SYSC-REF DEST="SW-SYSTEMCONST">/varDim_pkg/dt/SystemConstants/SymDimA</SYSC-REF>
</MAX-NUMBER-OF-ELEMENTS>

See Also

|

Related Examples

More About