In Simulink®, you can implement standard axis (STD_AXIS) and common axis (COM_AXIS) lookup tables for AUTOSAR applications. AUTOSAR applications can use lookup tables in either or both of two ways:
Implement fast search operations.
Support tuning of the application with measurement and calibration tools.
To model lookup tables for automotive application tuning, use the classes Simulink.LookupTable
and Simulink.Breakpoint
. By creating Simulink.LookupTable
and Simulink.Breakpoint
objects in the model workspace, you can store and share
lookup table and breakpoint data and configure the data for AUTOSAR code generation.
Configure STD_AXIS Lookup Tables by Using Lookup Table Objects
Configure COM_AXIS Lookup Tables by Using Lookup Table and Breakpoint Objects
This example shows how to create STD_AXIS lookup tables in Simulink, using Simulink.LookupTable
objects, and
configure the lookup tables for AUTOSAR code generation. The example uses the model
.
To access the model, copy it from
matlabroot
/help/toolbox/autosar/examples/mAutosarLutObjs.slx
(matlabroot
/help/toolbox/autosar/examplescd
to folder) to a working folder.
Model an AUTOSAR lookup table in a STD_AXIS configuration.
In a mapped AUTOSAR software component model, add an AUTOSAR Blockset Curve or Map block. This example adds a Curve block.
Open the Curve block and configure it to generate a routine from the AUTOSAR 4.0 code replacement library (CRL). As you modify block settings, the block dialog box updates the name of the targeted AUTOSAR routine.
In the block dialog box, make these selections:
To generate a floating-point routine, select IFL (floating-point).
In the Table Specification tab, to
specify table data using a lookup table object, set
Data Specification to
Lookup table object
.
In the model workspace, create a Simulink.LookupTable
object and configure it to store the
lookup table data.
In the Curve block dialog box, Table
Specification tab, enter the Simulink.LookupTable
object name in the
Name field.
In the block dialog box, Algorithm tab, set
Integer Rounding Method to
Zero
. Leave Interpolation
Method set to Linear
point-slope
and Index Search
Method set to Linear
search
.
Table data appears in generated AUTOSAR C code as fields of a single structure. To control the characteristics of the structure type, such as its name, use the properties of the object.
Connect the Curve or Map block.
Add AUTOSAR operating points to the lookup tables. Connect a root-level inport to the Curve or Map block. Alternatively, configure an input signal to the Curve or Map block with static global memory.
Connect an outport to the Curve or Map block.
In the AUTOSAR code perspective, use the Code Mappings editor to map Simulink.LookupTable
objects to AUTOSAR internal
calibration parameters. In the Parameters tab, select each
Simulink.LookupTable
object that you
created. Map each object to AUTOSAR parameter type
ConstantMemory
,
SharedParameter
, or
Auto
. To accept software mapping defaults,
specify Auto
.
In this example, STD_AXIS lookup table object L_4_single
is
mapped to AUTOSAR ConstantMemory
.
For each parameter, if you select a parameter type other than
Auto
, use the Property Inspector to view or
modify other code and calibration attributes. For more information on parameter
properties, see Map Model Workspace Parameters to AUTOSAR Component Parameters.
Configure the model to generate C code based on the AUTOSAR 4.0 library. Open
the Configuration Parameters dialog box and select Code Generation > Interface. Set the Code replacement library parameter
to AUTOSAR 4.0
. For more information, see Code Generation with AUTOSAR Code Replacement Library.
Build the model. The generated C code contains the expected
Ifl
and Ifx
lookup function calls and
Rte
data access function calls. For example, you can
search the HTML code generation report for the Ifl
or
Ifx
routine prefix.
The generated ARXML files contain data types of category CURVE (1-D table data) and MAP (2-D table data). The data types have the data calibration properties that you configured.
This example shows how to create COM_AXIS lookup tables in Simulink, using Simulink.LookupTable
and Simulink.Breakpoint
objects, and configure the lookup
tables for AUTOSAR code generation. The example uses the model
.
To access the model, copy it from
matlabroot
/help/toolbox/autosar/examples/mAutosarLutObjs.slx
(matlabroot
/help/toolbox/autosar/examplescd
to folder) to a working folder.
In this example, to model an AUTOSAR lookup table in a COM_AXIS configuration, you pair AUTOSAR Blockset Prelookup blocks with Curve Using Prelookup or Map Using Prelookup blocks.
Configure Prelookup blocks.
In a mapped AUTOSAR software component model, add one or more AUTOSAR Blockset Prelookup blocks. This example adds one Prelookup block.
Open each block and configure it to generate a routine from the AUTOSAR 4.0 code replacement library (CRL). As you modify block settings, the block updates the name of the targeted AUTOSAR routine.
In the block dialog box, make these selections:
To generate a floating-point routine, select IFL (floating-point).
In the Table Specification tab, to
specify breakpoint data using a breakpoint object, set
Breakpoints specification to
Breakpoint object
.
For each breakpoint vector, in the model workspace, create and
configure a Simulink.Breakpoint
object.
In the Prelookup block dialog box, Table
Specification tab, enter the Simulink.Breakpoint
object name in the
Name field. You can reduce memory consumption
by sharing breakpoint data between lookup tables.
In the block dialog box, Algorithm tab, set
Integer Rounding Method to
Zero
. Leave Index Search
Method set to Linear
search
.
Configure Curve Using Prelookup and Map Using Prelookup blocks.
In the model, add one or more AUTOSAR Blockset Curve Using Prelookup or Map Using Prelookup blocks. Each block immediately follows a Prelookup block with which it is paired. This example adds one Curve Using Prelookup block.
Open each Curve Using Prelookup or Map Using Prelookup block and configure it to generate a routine from the AUTOSAR 4.0 code replacement library (CRL). As you modify block settings, the block dialog box updates the name of the targeted AUTOSAR routine.
In the block dialog box, make these selections:
To generate a floating-point routine, select IFL (floating-point).
In the Table Specification tab, to
specify table data using a lookup table object, set
Data Specification to
Lookup table object
.
For each set of table data, in the model workspace, create and
configure a Simulink.LookupTable
object.
In each Curve Using Prelookup or Map Using
Prelookup block dialog box, Table
Specification tab, enter a Simulink.LookupTable
object name in the
Name field.
In the block dialog box, Algorithm tab, set
Integer Rounding Method to
Zero
. Leave Interpolation
Method set to Linear
point-slope
.
Each set of table data appears in the generated C code as a separate array variable. If the table size is tunable, each breakpoint vector appears as a structure. The structure contains a field to store the breakpoint data and, optionally, a field to store the length of the vector. The second field enables you to tune the effective size of the table. If the table size is not tunable, each breakpoint vector appears as an array.
Connect the Prelookup, Curve Using Prelookup, and Map Using Prelookup blocks.
Add AUTOSAR operating points to the lookup tables. Connect root-level inports to the Prelookup blocks. Alternatively, configure input signals to the Prelookup blocks with static global memory.
Connect outports to the Curve Using Prelookup and Map Using Prelookup blocks.
Connect each Prelookup block to its matched Curve Using Prelookup or Map Using Prelookup block.
In the AUTOSAR code perspective, use the Code Mappings editor to map Simulink.LookupTable
and Simulink.Breakpoint
objects to AUTOSAR internal calibration
parameters. In the Parameters tab, select each Simulink.LookupTable
and Simulink.Breakpoint
object that you created. Map each object to
AUTOSAR parameter type ConstantMemory
,
SharedParameter
, or
Auto
. To accept software mapping defaults,
specify Auto
.
In this example, COM_AXIS breakpoint object Bp_4_single
and
lookup table object Lcom_4_single
are mapped to AUTOSAR
SharedParameter
s.
All instances of the AUTOSAR software component
share the COM_AXIS parameters.
For each parameter, if you select a parameter type other than
Auto
, use the Property Inspector to view or
modify other code and calibration attributes. For more information on parameter
properties, see Map Model Workspace Parameters to AUTOSAR Component Parameters.
Configure the model to generate C code based on the AUTOSAR 4.0 library. Open
the Configuration Parameters dialog box and select Code Generation > Interface. Set the Code replacement library parameter
to AUTOSAR 4.0
. For more information, see Code Generation with AUTOSAR Code Replacement Library.
Build the model. The generated C code contains the expected
Ifl
and Ifx
lookup function calls and
Rte
data access function calls. For example, you can
search the HTML code generation report for the Ifl
or
Ifx
routine prefix.
The generated ARXML files contain data types of category CURVE (1-D table data), MAP (2-D table data), and COM_AXIS (axis data). The data types have the data calibration properties that you configured.
Curve | Curve Using
Prelookup | getParameter
| Map | Map Using
Prelookup | mapParameter
| Prelookup | Simulink.Breakpoint
| Simulink.LookupTable