使用Autosar库的代码生成
If your model is configured for AUTOSAR code generation, you can use the AUTOSAR 4.0 code replacement library to produce code that more closely aligns with the AUTOSAR standard. The AUTOSAR 4.0 code replacement library is intended for use with AUTOSAR schema version 4.0 or later.
汽车代码替换库
AutoSar 4.0代码替换库为您提供了一种方法,可以自定义C/C ++代码生成器生成与AutoSar标准更加与Autosar标准紧密相符的代码。考虑使用库,如果以下方式:
您要使用库中提供的服务例程。
您的服务例程具有替换代码。
替换代码遵循AutoSar文件命名约定,该约定给定规范的例程在一个标头文件中(例如,
MFL.H
orMFX.H
)You have a build harness setup that can compile and link the AUTOSAR library with the generated code. For more information about building code for AUTOSAR, see汽车代码生成。
笔记
MATLAB®和Sim金宝appulink®lookup table indexing differs from AUTOSAR MAP indexing. MATLAB takes the linear algebra approach—row (U1
)和列(U2
)。AUTOSAR (and ASAM) takes the Cartesian coordinate approach—x-axis (U2
)和y轴(U1
), 在哪里U1
andU2
are input arguments to Simulink 2-D lookup table blocks. Due to the difference, the code replacement software transposes the input arguments for AUTOSAR MAP routines.
有关代码替换和代码的更多信息replacement libraries, seeWhat Is Code Replacement?and代码更换库。
金宝app支持的汽车库例程
要探索由AutoSar代码替换库支持的AutoSar库例程,请使用金宝app代码更换查看器。要打开观众,请输入CRViewer
在命令提示符下。
有关更多信息,请参阅Choose a Code Replacement Library。
Configure Code Generator to Use AUTOSAR Code Replacement Library
To configure the code generator to apply the AUTOSAR code replacement library, selectAUTOSAR 4.0
for the代码更换库模型配置参数。
有关代码替换和代码的更多信息replacement libraries, seeWhat Is Code Replacement?and代码更换库。
用与AutoSar IFL和IFX库例程兼容的函数替换代码
To replace code generated for Simulink lookup table blocks with functions that are compatible with AUTOSAR floating-point interpolation (IFL) and fixed-point interpolation (IFX) library routines:
在Simulin金宝appk模型中,使用PRELOOKUP,PRELOOKUP和N-D查找表使用Simulink查找表块插值。
例如:
For each lookup table block in the model, use information inIFL/IFX函数的必需算法属性设置并阻止映射配置块算法参数。给定这些参数设置,代码生成器会产生与相应的AutoSar IFX或IFL例程兼容的代码。
配置代码生成器的模型以使用AutoSar 4.0代码替换库。在“配置参数”对话框中,选择代码生成>界面>代码更换库>AUTOSAR 4.0。或者,从命令行或编程中,使用
set_param
设置CodeReplacementLibrary
参数为'Autosar 4.0'
。Optionally, configure the model for the code generator to produce a code generation report that summarizes which blocks trigger code replacements. In the Configuration Parameters dialog box, in the代码生成>报告窗格,选择选项总结哪些阻止触发代码更换。或者,从命令行或编程中,使用
set_param
设置GenerateCodeReplacementReport
参数为'上'
。生成代码。
查看预期代码更换的生成的代码。例如:
IFL/IFX函数的必需算法属性设置并阻止映射
IFL/IFX Function and Block Mapping | 算法属性参数 | Value |
---|---|---|
prolookup |
外推法
|
|
索引搜索方法
|
|
|
在上限或上限上使用最后一个断点作为输入
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
prolookup |
外推法
|
夹子 |
索引搜索方法
|
|
|
在上限或上限上使用最后一个断点作为输入
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
使用预插条插值 |
插值法
|
|
外推法
|
|
|
在生成的代码中删除针对范围内索引的保护
|
离开 |
|
整数圆形模式
|
|
|
有效的索引输入可能达到最后一个索引
|
On |
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
模型配置参数Optimization>Signals and Parameters>Default parameter behavior
|
|
|
Breakpoint data should match power 2 spacing. |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
模型配置参数Optimization>Signals and Parameters>Default parameter behavior
|
|
|
断点数据必须匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
断点数据不得匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
断点数据不得匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
模型配置参数Optimization>Signals and Parameters>Default parameter behavior
|
|
|
断点数据必须匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
模型配置参数Optimization>Signals and Parameters>Default parameter behavior
|
|
|
断点数据必须匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
模型配置参数Optimization>Signals and Parameters>Default parameter behavior
|
|
|
断点数据必须匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
断点数据不得匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
断点数据不得匹配功率2间距。 |
||
N-D查找表 |
插值法
|
|
外推法
|
|
|
索引搜索方法
|
|
|
Remove protection against out-of-range input in generated code
|
离开 |
|
整数圆形模式
|
|
|
在最后一个断点或以上的输入中使用最后一个表值
|
On |
|
断点数据不得匹配功率2间距。 |
代码更换检查AutoSar查找表功能
The following checks occur during the code replacement match process for AUTOSAR lookup table functions:
功能类型 | 匹配过程检查是否 |
---|---|
n-D lookup |
|
使用预插条插值 | 输出和表数据参数具有相同的数据类型。 |
prolookup | 输入和断点参数具有相同的数据类型。 |