主要内容

为嵌入式应用指定单精度的数据类型

当你想要的代码只使用单一的精度,如当你瞄准一个单精度处理器、您可以使用模型配置参数和防止引入块参数在模型中。

设计和验证一个单精度模型、明白了验证一个浮点嵌入模型。如果你有定点设计师™,您可以使用单精度转换器应用(见单精度转换器(定点设计师))。

使用数据类型默认为未指定类型

这个例子展示了如何避免引入双精度的数据类型为单精度的硬件生成目标代码。

如果你指定一个继承了数据类型的信号,但数据类型传播规则不能确定数据类型的信号,信号数据类型默认。您可以使用一个模型配置参数指定默认数据类型

探索模型示例

打开示例模型rtwdemo_underspecified_datatype并配置它来显示生成的块的名字。

模型=“rtwdemo_underspecified_datatype”;load_system(模型)set_param(模型,“HideAutomaticNames”,“关闭”)open_system(模型);

根港口In2,In3,In4指定继承:汽车数据类型块参数。下游块也使用继承的数据类型。

生成代码与为默认数据类型

模型首先配置参数系统目标文件设置为ert.tlc,这就需要嵌入式程序员®。集系统目标文件grt.tlc代替。

set_param(模型,“SystemTargetFile”,“grt.tlc”)

从模型中生成代码。

slbuild(模型)
# # #开始构建过程:rtwdemo_underspecified_datatype # # #成功完成构建过程:rtwdemo_underspecified_datatype模型建立目标:总结构建模型重建行动的原因= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = rtwdemo_underspecified_datatype代码生成和编译。代码生成信息文件不存在。1 1模型的建立(0模型已经更新)构建持续时间:0 h 0米12.279秒

在代码生成报告,查看文件rtwdemo_underspecified_datatype.h。使用的代码数据类型定义变量In2,In3,In4因为尺寸数据类型是在模型中遗漏。

用= fullfile (“rtwdemo_underspecified_datatype_grt_rtw”,“rtwdemo_underspecified_datatype.h”);rtwdemodbtype(用/ *外部输入(根尺寸信号用默认存储)* /”,/ *外部输出(根外港美联储通过信号用默认存储)* /”,1,0);
/ *外部输入(根尺寸信号与默认存储)* / typedef struct {int8_T三机一体;/ * < Root > / In1”* / real_T In2;/ * < Root > / In2”* / real_T In3;/ * < Root > / In3”* / real_T In4;/ * < Root > / In4”* /} ExtU_rtwdemo_underspecified_d_T;

生成代码与为默认数据类型

打开配置参数对话框。在数学和数据类型窗格中,选择默认为未指定数据类型下拉列表。

另外,启用优化在命令提示符。

set_param(模型,“DefaultUnderspecifiedDataType”,“单一”);

从模型中生成代码。

slbuild(模型)
# # #开始构建过程:rtwdemo_underspecified_datatype # # #成功完成构建过程:rtwdemo_underspecified_datatype模型建立目标:总结构建模型重建行动的原因= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = rtwdemo_underspecified_datatype代码生成和编译。生成的代码是过时了。1 1模型的建立(0模型已经更新)构建持续时间:0 h 0米9.4335秒

在代码生成报告,查看文件rtwdemo_underspecified_datatype.h。使用的代码数据类型定义变量In2,In3,In4

rtwdemodbtype(用/ *外部输入(根尺寸信号用默认存储)* /”,/ *外部输出(根外港美联储通过信号用默认存储)* /”,1,0);
/ *外部输入(根尺寸信号与默认存储)* / typedef struct {int8_T三机一体;/ * < Root > / In1”* / real32_T In2;/ * < Root > / In2”* / real32_T In3;/ * < Root > / In3”* / real32_T In4;/ * < Root > / In4”* /} ExtU_rtwdemo_underspecified_d_T;

相关的话题