MATLAB Answers

Sil - mil compare for simulink model

44 views (last 30 days)
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

Accepted Answer

Andy Bartlett
Andy Bartlett on 2 Apr 2015
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
  1 Comment
Phani Teja
Phani Teja on 30 Apr 2019
Thank you for your answer Andy :)
I would like to add one more point to your answer to get the same behaviour of simulink with respect to the Targetlink debugging method.
In Targetlink we have Sink block to store the MIL and SIL results for different simulations , Similar to that we can use Simulink data inspector with Data type override feature(Fixed point tool) to store the simulations , Comparisons for effective debugging process.

Sign in to comment.

More Answers (3)

Jason Moore
Jason Moore on 6 Feb 2015
Yes, it is a common workflow in Simulink to compare simulation runs in MIL against a SIL run. To accomplish this one of the best methods is to use Simulink Data Inspector . One method to do this is use a model reference with a test harness and then switch the simulation mode for the model reference into Software in the Loop mode. Then when you run the simulation, code will be built into an executable file and run. The results will show up in Simulink Data Inspector and you can then compare the various simulation runs.

Giuseppe Rocca
Giuseppe Rocca on 16 Feb 2015
Hi Jason, thank you for your answer, but my question was if it were possible to simulate the same model in floating point (double precision) and then comparing with the SIL, without having two differents models, one for double simulation (that perhaps I have wrongly called MIL) and one in fixed point for SIL simulation, as is shown in Encoder documentation. Thanks, Giuseppe

Giuseppe Rocca
Giuseppe Rocca on 3 Apr 2015
Hello Andy Thanks a lot. In the last days I've tried Fixed Point Toolbox and also the command line set_param(bdroot,'DataTypeOverride','Double'). The only problem is that they don't work for Custom Class Parameter and for Convert block (with Storage Integer option) before S-Function. I think that a possible solution is a Matlab script that replaces in advance these kind of blocks (often user custom blocks as S-Function) and then calls set_param... Yours Sincerely, Giuseppe

Community Treasure Hunt

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

Start Hunting!