文档

使用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.HorMFX.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), 在哪里U1andU2are 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.0for 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:

  1. 在Simulin金宝appk模型中,使用PRELOOKUP,PRELOOKUP和N-D查找表使用Simulink查找表块插值。

    例如:

  2. For each lookup table block in the model, use information inIFL/IFX函数的必需算法属性设置并阻止映射配置块算法参数。给定这些参数设置,代码生成器会产生与相应的AutoSar IFX或IFL例程兼容的代码。

  3. 配置代码生成器的模型以使用AutoSar 4.0代码替换库。在“配置参数”对话框中,选择代码生成>界面>代码更换库>AUTOSAR 4.0。或者,从命令行或编程中,使用set_param设置CodeReplacementLibrary参数为'Autosar 4.0'

  4. 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参数为'上'

  5. 生成代码。

  6. 查看预期代码更换的生成的代码。例如:

IFL/IFX函数的必需算法属性设置并阻止映射

IFL/IFX Function and Block Mapping 算法属性参数 Value

ifl_dpsearch

prolookup

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在上限或上限上使用最后一个断点作为输入

UselastBreakpoint

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

ifl_ipocur

使用预插条插值

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

IFL_IPOMAP

使用预插条插值

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

ifl_intipocur

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

ifl_intipomap

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

Ifx_DPSearch

prolookup

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在上限或上限上使用最后一个断点作为输入

UselastBreakpoint

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

IFX_IPOCUR

使用预插条插值

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

IFX_LKUPCUR

使用预插条插值

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

IFX_IPOMAP

使用预插条插值

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

IFX_LKUPMAP

使用预插条插值

插值法

InterpMethod

最近

外推法

ExtrapMethod

夹子

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

IFX_LKUPBASEMAP

使用预插条插值

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

在生成的代码中删除针对范围内索引的保护

删除PrototectionIndex

离开

整数圆形模式

rndmeth

Roundor

有效的索引输入可能达到最后一个索引

ValidIndexMayReachLast

On

Ifx_IntIpoCur

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

ifx_intlkupcur

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

ifx_intipofixcur

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

模型配置参数Optimization>Signals and Parameters>Default parameter behavior

DefaultParameterBehavior

Inlined

Breakpoint data should match power 2 spacing.

Ifx_IntLkUpFixCur

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

模型配置参数Optimization>Signals and Parameters>Default parameter behavior

DefaultParameterBehavior

Inlined

断点数据必须匹配功率2间距。

ifx_intipofixicur

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

断点数据不得匹配功率2间距。

ifx_intlkupfixicur

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

断点数据不得匹配功率2间距。

ifx_intipomap

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

ifx_intlkupmap

N-D查找表

插值法

InterpMethod

最近

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Ifx_IntLkUpBaseMap

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

线性搜索or二进制搜索

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

ifx_intipofixmap

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

模型配置参数Optimization>Signals and Parameters>Default parameter behavior

DefaultParameterBehavior

Inlined

断点数据必须匹配功率2间距。

ifx_intlkupfixmap

N-D查找表

插值法

InterpMethod

最近

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

模型配置参数Optimization>Signals and Parameters>Default parameter behavior

DefaultParameterBehavior

Inlined

断点数据必须匹配功率2间距。

ifx_intlkupfixbasemap

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

模型配置参数Optimization>Signals and Parameters>Default parameter behavior

DefaultParameterBehavior

Inlined

断点数据必须匹配功率2间距。

ifx_intipofiximap

N-D查找表

插值法

InterpMethod

线性

外推法

ExtrapMethod

线性

索引搜索方法

IndexSearchMethod

Evenly spaced points

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

断点数据不得匹配功率2间距。

Ifx_IntLkUpFixIMap

N-D查找表

插值法

InterpMethod

最近

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

断点数据不得匹配功率2间距。

Ifx_IntLkUpFixIBaseMap

N-D查找表

插值法

InterpMethod

Flat

外推法

ExtrapMethod

夹子

索引搜索方法

IndexSearchMethod

Evenly spaced points

Remove protection against out-of-range input in generated code

RemoveProtectionInput

离开

整数圆形模式

rndmeth

Roundor

在最后一个断点或以上的输入中使用最后一个表值

UseLastTableValue

On

断点数据不得匹配功率2间距。

代码更换检查AutoSar查找表功能

The following checks occur during the code replacement match process for AUTOSAR lookup table functions:

功能类型 匹配过程检查是否
n-D lookup
  • 输入和相应的断点参数具有相同的数据类型。

  • 输出和表数据参数具有相同的数据类型。

使用预插条插值 输出和表数据参数具有相同的数据类型。
prolookup 输入和断点参数具有相同的数据类型。
Was this topic helpful?