# Develop a Model That Complies with the IEC 61508 Standard

This example shows how to use the Model Advisor to check that a model complies with the IEC 61508 safety standard.

The IEC 61508 Model Advisor checks identify issues with a model that impede deployment in safety-related applications or limit traceability.

### Understanding the Model

Model `rtwdemo_iec61508` check whether the 1-norm distance between points `(x1,x2)` and `(y1,y2)` is less than or equal to a given threshold `thr`. For two points `(x1,x2)` and `(y1,y2)`, the 1-norm distance is given as:

`$\sum _{i=1}^{2}|{x}_{i}-{y}_{i}|$`

Open and review the model.

```model='rtwdemo_iec61508'; open_system(model) ```

### Run the IEC 61508 Modeling Standard Checks

To deploy the model in a safety-related software component that must comply with the IEC 61508 safety standard, check the model for issues that might impede deployment in such an environment or limit traceability between the model and generated source code.

1. To open the Model Advisor, in the Simulink® editor, click the Modeling tab and select Model Advisor. A System Selector - Model Advisor dialog box opens. Select the model or system that you want to review and click OK. Or enter `modeladvisor('rtwdemo_IEC61508')` at the MATLAB® command line.

2. In the left pane of the Model Advisor, expand By Task > Modeling Standards for IEC 61508. If the By Task folder is not displayed in the Model Advisor window, open Settings > Preferences and select Show By Task Folder.

3. Select the checks that you want to include in your model analysis.

4. Click on the folder that contains the checks and, on the right pane of the Model Advisor, select Show report after run to automatically generate and display the report in HTML format.

5. Click Run Selected Checks to execute the analysis.

### Review Check Results

The Model Advisor processes the IEC 61508 checks and displays the results.

1. After the analysis is complete, review the aggregate results in the right pane of the Model Advisor. You can see the total number of checks that passed, failed, were flagged as warnings, and did not execute.

2. To review the results for a specific check, in the By Task > Modeling Standards for IEC 61508 folder, select a check. For more information about the check and how to resolve reported issues, click Help.

3. Address the reported issues and rerun the checks.

4. To review the generated HTML report of the results, select the By Task > Modeling Standards for IEC 61508 folder and click the link in the Report box.

5. Print the generated HTML report. You can use the report as evidence in the IEC 61508 compliance process.

6. If desired, click the Generate Code Using Embedded Coder button in the model to inspect the generated code and the traceability report.