MATLAB: Sil – mil compare for simulink model

Embedded Codersil mil compare

Dear Sir or Madam, I would like to compare sil and mil trace on the same simulink model using Embedded Coder. So I want to simulate first the model with double precision and then with the fixed precision that I have choosen without update, at ever modification, two different modules. I have worked in Magneti Marelli where Target Link is used and this modality is possible. Can I do the same with Real Time Workshop? Best regards, Giuseppe

Best Answer

Hi Giuseppe,
Allowing the idealized floating point behavior to be compared with fixed-point behavior is a key feature of Fixed-Point Designer.
Fixed-Point Designer makes this easy using a feature called Data Type Override. Data Type Override allows all the data types under a model (or under a subsystem) to be changed to Doubles or Singles.
When Data Type Override is ON, ALL model actions will use the overridden types instead of the originally specified types. This allows the FULL capabilities of Model Based Design tools to be applied to the idealized (floating point doubles) version of the model. Data Type Override applies to all simulation modes including: Normal, Accelerator, ..., SIL, PIL, and external. Data Type Override also applies to code generation and to verification. The independence of Data Type Override from other actions on a model provides many capabilities. For example, Simulink Design Verifier can be used to analyze both the original fixed-point model and the idealized double model simply by switching Data Type Override off or on.
TargetLink has a different design where the data types used are tied to the simulation mode. Roughly speaking, in TargetLink, MIL mode means simulation with doubles while SIL mode or PIL mode means simulation in fixed-point.
If you are a former TargetLink user, it is good to clarify how the terms MIL, SIL, and PIL map to Simulink and Embedded Coder. The term MIL is not meaningful for Simulink or Embedded Coder. In Embedded Coder, SIL and PIL are designed to provide easy and efficient code verification. Embedded Coder does not tie data type selection to SIL and PIL. Simulink provides the flexibility to use fixed-point data types in any model action or overrride those types to double in any model action.
To turn Data Type Over on, use the command line or the Fixed-Point Tool. Command line set_param(bdroot,'DataTypeOverride','Double') % ON set_param(bdroot,'DataTypeOverride','UseLocalSettings') % OFF
Or for graphical interface
1) From you model's Analysis menu open Fixed-Point Tool (FPT)
2) In the tree on the left side of FPT, make sure the model node is selected.
3) In the right side of FPT in bounding box labelled 'Settings for selected system' set Data Type Override to Double for ON or Use local settings for off.
4) Click apply button.
5) Hint: look back at FPT's tree. If you see (dbl) next to the model's name, then Data Type Override is ON and set to Double.
The following video shows data type override used to improve the choice of fixed-point types.
Best Regards
Andy Bartlett
Related Question