uint8 vs. double in Simulink

13 次查看(过去 30 天)
Hi,
Some blocks in Simulink supports several output formats. Is it better to set it as unit8 for byte based data rather than double? I remember such way is recommended for VHDL programming.
Thanks Senmeis

采纳的回答

Mariano Lizarraga
Mariano Lizarraga 2012-8-30
Hello Owen, Your question is somewhat generic. For instance, if you are using a source, say a constant, and you expect it to be a uint8 then that would be fine. But if you are doing an operation, say an addition, with two double signals then I would strongly advise you against having the add block output anything other than the input signal types. It can lead to hard to find bugs and also the MISRA Autocode Design Guidelines for Simulink and Stateflow http://www.misra.org.uk/Publications/tabid/57/Default.aspx#label-ac-slsf Rule ID 003 requires you not to do that, literally it reads:
"Only the DATA TYPE CONVERSION block must be used where signal data type conversion is required, i.e. data type conversion must not be performed by any other Simulink block, e.g. gain, product, divide, sum, inport, outport."
Hope this helps.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by