uint8 vs. double in Simulink

조회 수: 12 (최근 30일)
Owen
Owen 2012년 8월 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