Model Quality Objectives for Simulink
Model Quality Objectives for Simulink
Contents
1 Introduction 4
1.1 Abstract 4
1.2 Intended audience 4
1.3 Scope 4
1.4 Purpose 4
1.5 Background and motivation 5
1.6 References 6
1.7 Terminology 7
1.8 Abbreviations 7
1.9 Template 8
1.10 Authors 8
2 Software development with design models 9
2.1 Overview 9
2.2 Software planning phase 10
2.2.1 Scope definition 10
2.2.2 Tools definition 10
2.2.3 Standards definition 11
2.2.4 MQR identification and allocation 11
2.2.5 Strategy to achieve MQO 11
2.2.6 MQR conformance demonstration 11
2.3 Software requirements phase 11
2.3.1 Roles of the functional model 11
2.3.2 Main characteristics of the functional model 12
2.4 Software architectural design phase 12
2.4.1 Role of the architecture model 12
2.4.2 Main characteristics of the architecture model 12
2.5 Software component design and testing phase 13
2.5.1 Role of the component design model 13
2.5.2 Main characteristics of the component design model 13
2.6 Software component implementation and testing phase 14
2.6.1 Role of the component implementation model 14
2.6.2 Characteristics of the component implementation model 14
2.7 Relationship between design models 15
2
Model Quality Objectives | Version 1.0
3
Model Quality Objectives | Version 1.0
1 Introduction
1.1 Abstract
This document, named Model Quality Objectives (MQO), presents quality objectives for models developed with
Simulink® at different phases of the software development lifecycle. It has been defined by a group of leading actors
from the automotive industry and MathWorks, the company that develops the MATLAB®, Simulink, and Polyspace®
products. Its purpose is to clarify and ease the collaboration when sharing Simulink models, e.g. between OEM and
suppliers, in the context of embedded software development to drive the production of higher quality and integrity
software.
1.3 Scope
The use of design models developed with the Simulink® software and its toolboxes in the context of embedded soft-
ware development with Model-Based Design.
1.4 Purpose
This document clarifies how Simulink design models contribute to accelerate development and verification activities
from software requirements specification to software implementation. Four types of design models with specific
purposes are introduced, each with a specific quality objective to control their proper usage. Each quality objective is
a set of measurable metrics with quantified satisfaction criteria to facilitate and standardize model quality
assessment.
The organizations that apply the concepts presented in this paper should experience the following benefits:
a. Shared understanding of Model-Based Design within the organization
b. Application of a quality model adapted to Model-Based Design projects and compatible with industry software
quality and safety standards
c. Assessment of model quality at different phases of projects
The organizations that also collaborate with partners to execute Model-Based Design projects should experience the
following benefits when applying the concepts presented in this paper:
a. Easiest split of responsibility between parties at the beginning of projects
b. Common understanding of model quality
c. Common expectation on model quality when sharing models
4
Model Quality Objectives | Version 1.0
5
Model Quality Objectives | Version 1.0
1.6 References
Ref Description
[1] Patrick Briand (Valeo), Martin Brochet (MathWorks), Thierry Cambois (PSA Peugeot
Citroën), Emmanuel Coutenceau (Valeo), Olivier Guetta (Renault SAS), Daniel
Mainberte (PSA Peugeot Citroën), Frederic Mondot (Renault SAS), Patrick Munier
(MathWorks), Loic Noury (MathWorks), Philippe Spozio (Renault SAS), Frederic
Retailleau (Delphi Diesel System), Software Quality Objectives for Source Code, ERTS
2010-Conference, 2010.
[2] S. Louvet, Robert Bosch (France) SAS, Dr. U. Niebling, Dr. M. Tanimou, Robert Bosch
GmbH Model Sharing to leverage customer cooperation in the ECU software devel-
opment; Toulouse, ERTS 2014-Conference, 2014.
[3] ISO 26262 International standard for functional safety of electrical and/or electronic
systems in production automobiles defined by the International Organization for
Standardization (ISO) in 2011.
[4] RTCA/Eurocae, Software Considerations in Airborne Systems and Equipment
Certification, RTCA DO-331 / Eurocae ED-218, December 13, 2011.
[5] Automotive SPICE Process Assessment / Reference Model from VDA QMC Working
Group 13 / Automotive SIG
[7] Hersteller Initiative Software (HIS)is an initiative from German automotive manufactur-
ers whose goal is the production of agreed standards within the area of standard
software modules for networks, development of process maturity, software test, soft-
ware tools and programming of ECU’s. HIS specifies a fundamental set of Software
Metrics to be used in the evaluation of software.
[8] Modeling guidelines for MATLAB, Simulink and Stateflow (MAAB) to develop control
algorithms and defined by the MathWorks Automotive Advisory Board.
[9] MISRA C - Set of software development guidelines for the C programming language
developed by MISRA (Motor Industry Software Reliability Association). Its aims are to
facilitate code safety, security, portability and reliability in the context of embedded
systems, specifically those systems programmed in ISO C / C90 / C99.
6
Model Quality Objectives | Version 1.0
1.7 Terminology
Term Definition
Design model A model developed with MATLAB, Simulink and Stateflow to design software
architecture and algorithms for signal processing, communication or control
software. In the context of MQO, four types of design models are defined: the
functional model, the architecture model, the component design model, and the
component implementation model.
Model higher level A requirement satisfied by a design model.
requirement
Model-Based Design A process that systematically relies on the use of models at different phases of the
system and software development process.
Model Quality Objective A quality objective that applies to a type of design model.
1.8 Abbreviations
7
Model Quality Objectives | Version 1.0
1.9 Template
The following template is used to specify MQR in section 3.2.
1.10 Authors
This document was prepared by the MQO working group composed of representatives from MathWorks, automotive
OEMs and suppliers.
8
Model Quality Objectives | Version 1.0
2.1 Overview
This document defines a development approach based on four types of design models supporting the left-hand side
of the V-cycle.
The Model-Based Design/MQO software development lifecycle involves five specific phases marked as 1 to 5 in
Figure 1 Sections 3.1 to 3.5 will provide greater details on the phases.
Figure 2 shows how the Model-Based Design/MQO software development lifecycle maps to other software develop-
ment lifecycles from the industry. The phases supported by design models are highlighted with a dark background,
and Model-Based Design is referred to as MBD.
9
Model Quality Objectives | Version 1.0
Figure 2: Model-Based Design / MQO software phases versus other industry standards [3], [4], [5], [6]
10
Model Quality Objectives | Version 1.0
11
Model Quality Objectives | Version 1.0
12
Model Quality Objectives | Version 1.0
The architecture model directly contributes to the design activities and is therefore subject to conformance with
industry quality standards, safety standards, and/or architecture standards (e.g. traceability to requirements, com-
patibility with architecture standard).
Next figure shows an example of an architecture model that references component models represented by model
references.
13
Model Quality Objectives | Version 1.0
The component model directly contributes to the development activities and is therefore subject to conformance
with industry quality standards, safety standards, and/or design standards (e.g. conformance to modeling standard,
traceability to requirements).
Figure 5 shows an example of a component design model with fully defined interfaces and sub-functions implement-
ed with state machines.
14
Model Quality Objectives | Version 1.0
Figure 6: Example of code generation configuration for the component implementation model
15
Model Quality Objectives | Version 1.0
Figure 7: Design model relationships and contribution to prototyping and production development
The functional model shall have structured algorithms that can contribute to the validation of the software require-
ments with modeling and simulation. A model’s code generation configuration for rapid-prototyping can be useful
to validate the software requirements with a real-time environment. The development focus shall be on the software
requirement (not represented on the figure). The entire model shall be considered a prototype.
The architecture model shall define the component interface and scheduling of the software architectural design.
The architectural design aspect of the functional model can serve as a baseline to initiate the development of the
software architecture for production (1a). The prototype algorithms of the functional model can populate the archi-
tecture model to enable early dynamic verification of the model in simulation to evaluate the impact of the architec-
ture on the functional behavior (2a). A prototype code generation configuration representative of the software
architecture standard (e.g. AUTOSAR) can be created to achieve early verification of the impact of the functional
behavior in real time and its integration with software and hardware (e.g. AUTOSAR RTE).
The component design model shall fully define the software component design with its structure, scheduling, and
algorithms. The interface of the model shall be consistent with, and can be reused from, the architecture model (1b).
The prototype algorithms developed for the functional model can serve as a baseline to define the production algo-
rithms (2b). A prototype code generation configuration can be used for early verification of the non-trivial impacts
of the design model on the generated code (e.g. compliance with the coding standard, level of code coverage versus
model coverage, code expansion).
The component implementation model shall define both the software component design and implementation. The
structure, scheduling, and algorithms shall be reused from the software component design model (1c, 2c). The way
algorithms are implemented can be adapted to address non-functional requirements (e.g. optimization, safety). The
code generation configuration shall be used for production code generation and shall then be compatible with the
software coding standard and the target hardware.
16
Model Quality Objectives | Version 1.0
3.1 Overview
As design models are critical for software development using Model-Based Design, their quality must be carefully
assessed. Design models can automatically transform into other design artifacts such as documentation, source code,
or executables. Therefore, the quality objectives defined on the design models shall impact the models themselves as
well as their derived products. A specific quality objective is defined for each type of design model to account for
their specific role.
17
Model Quality Objectives | Version 1.0
Table 2 below provides the list of Model Quality Requirement (MQR) applicable to achieve the quality objective of
each type of design models. The details of each MQR are specified in section 3.2.
M: Mandatory
R: Recommended for early verification
Note: An additional MQR to verify the generated source code against the model can be required in
the context of DO-331.
18
Model Quality Objectives | Version 1.0
The model shall define Simulink and Stateflow ® diagrams that are completely visible on
Description
A4 paper size.
Fit to view with a zoom ratio smaller than 80% is harder to read on screen and likely not
Notes to be readable on A4 paper size.
The model zoom ratio is visible at the center of the model status bar below the diagram.
• Simulink subsystems
References /Examples • Stateflow sub-charts
of techniques • Simulink bus
The model comments shall provide a description of the model itself and the following
types of elements:
• Simulink subsystem
Description
• Simulink function and S-function mask
• Stateflow chart, sub-chart, truth table, state transition table, and flowchart
• Simulink and MATLAB function blocks and sub-functions
Like code, a model without comments is harder to understand by peers. Lack of descrip-
Rationale tion can negatively impact the efficiency of the peer review activity and maintenance
activities.
19
Model Quality Objectives | Version 1.0
The model elements that specify algorithms and calculations shall trace to the model
higher level requirements.
Description
The design model elements that specify interface shall trace to the software interface
requirements or software component interface requirements.
A model element is implicitly traced to a model higher level requirement if one of its par-
ents is traced (e.g. its parent subsystem).
The model shall trace to the right level of requirements:
• Functional model and architecture model shall trace to software requirements
• Component design model and component implementation model shall trace to soft-
Notes
ware component requirements
The correctness of the links to model higher level requirements is not in the scope of this
requirement and shall be assessed by peers during the model review.
When model references are used inside component design and implementation models,
each referenced model shall trace to its own model higher level requirements.
The model tests shall be derived from and traced to all model higher level requirements
which verification strategy is testing.
Each test shall have a defined procedure, stimuli, and expected outputs.
Notes
The model test environment shall not impact the behavior of the model under test.
The correctness of the tests and links to model higher level requirements are not in the
scope of this requirement and shall be assessed by peers during the tests review.
• Stimuli and expected outputs time series
References /Examples • Test sequences and test oracles
of techniques • Automation of test procedure, execution, and reporting
The simulation of the design model enables the discovery of design errors at design [Link]
Rationale can also contribute to refining model higher level requirements or correcting and validat-
ing requirement-based tests.
20
Model Quality Objectives | Version 1.0
The modeling standard shall be defined during the project software planning phase and
shall be compatible with the software safety standard, software design standard, coding
standard, and targeted hardware (e.g. floating-point support).
Notes Model compilation warnings and errors reported by Simulink diagnostics are considered
modeling standard violations.
The modeling standard could be adapted to software architectural design modeling and
software component design modeling.
• MathWorks modeling guidelines for high-integrity systems
References /Examples (Include compatibility with MISRA C® compliance)
of techniques • MathWorks Automotive Advisory Board Control Algorithm Modeling Guidelines
Using MATLAB, Simulink, and Stateflow [8]
The model standard can enforce best practices and define a subset of the modeling lan-
Rationale
guage that limits the possibility of incorrect use of the language.
The compute method is necessary for data coming from external software, driver, or com-
munication network.
Notes An initial value or safe value can be added for output and safety critical data.
Memory storage only needs to be defined in the component implementation model.
Display format for measured signal and calibration for floating point is recommended.
• Simulink data objects
Examples of techniques • Simulink data dictionary
Model data are part of the design and need to be fully defined. For instance, incorrect or
Rationale unknown data integrity level or data design min/max can impact the model and software
reliability and robustness.
21
Model Quality Objectives | Version 1.0
Local complexity is the cyclomatic complexity for objects at their hierarchical level.
Aggregated cyclomatic complexity is the cyclomatic complexity of an object
and its descendants.
Notes
The threshold of 30 for local cyclomatic complexity is a recommendation and can be
adapted on a project basis. The number 30 for cyclomatic complexity has been derived
from the HIS [7] code metric and adapted to Model-Based Design.
Cyclomatic complexity is a measure of the structural complexity of a model. It approxi-
mates the McCabe complexity measure for code generated from the model. The McCabe
complexity measure is slightly higher on the generated code due to error checks that the
model coverage analysis does not consider.
To compute the cyclomatic complexity of an object, such as a block, chart, or state,
model coverage uses the following formula:
Examples of techniques
N is the number of decision points that the object represents and on is the number of out-
comes for the nth decision point. The tool adds one to the complexity number for atomic
subsystems and Stateflow charts.
Cyclomatic complexity is a leading testability metric. Test harness can be created for
Rationale
simulation at model, subsystem, chart, and MATLAB function level.
22
Model Quality Objectives | Version 1.0
The structural coverage criteria chosen shall be at least conformant to the structural cover-
Notes
age criteria imposed by the software safety integrity level.
Types of coverage analysis available on Simulink model:
• Execution Coverage (EC)
• Decision Coverage (DC)
References /Examples • Condition Coverage (CC)
of techniques • Modified Condition/Decision Coverage (MCDC)
EC, DC, CC, MCDC, saturation on integer overflow coverage, and relational boundary
coverage can be used to measure the model structural coverage.
Description The model shall be robust in normal and abnormal operating conditions.
In normal operating condition, inputs and tunable parameters values are within their
design ranges.
In abnormal operating condition, inputs, and tunable parameters values are outside their
design ranges.
Robustness shall prevent errors such as:
Notes
• Divisions by zero
• Integer overflows
• Out of design range
• Out of bound array
The level of robustness shall be compliant with the software safety integrity level.
• Test generation based on relational boundary coverage
Examples of techniques • Formally-based verification technique with abstract interpretation
• Defensive programming
Model robustness verification prevents edge case or incorrect use of model, which can
Rationale
cause unexpected results or simulation errors.
23
Model Quality Objectives | Version 1.0
Code testing is required to verify the output of the code generator and compiler
or cross-compiler, linker, load, and flash utilities.
Rationale
For MQO-3, code testing in software-in-the-loop increases confidence in the
code generator.
Description The generated code shall be compliant with the coding standard.
The coding standard shall be defined during the project software planning phase and
shall be compatible with the software safety standard, software architecture standard,
Notes and targeted hardware (e.g. floating-point support).
The modeling standard shall anticipate the compliance with the coding standard.
The project coding standard can be tailored for generated code.
• MISRA C 2012 for safety
Examples of techniques • CERT C for cyber security
Rationale Coding standard verification is required to verify the output of the code generator.
24
Model Quality Objectives | Version 1.0
The structural coverage criteria shall be at least conformant to the structure coverage crite-
ria imposed by the software safety integrity level.
The model tests shall be reused to cover the structure of the generated code.
Notes
The code coverage can be different than the model coverage depending on the blocks
used (e.g. look-up table interpolation algorithm) or code generation optimization options
(e.g. for loop unrolling).
Types of coverage analysis available on the generated code:
• Statement Coverage for Code Coverage
References /Examples
• Condition Coverage for Code Coverage
of techniques
• Decision Coverage for Code Coverage
• Modified Condition/Decision Coverage (MCDC) for Code Coverage
Code coverage is required in addition to model coverage to verify that the code genera-
Rationale tor do not add unintended functionalities.
Description The model generated code shall be robust in normal and abnormal operating conditions.
In normal operating condition, inputs and tunable parameter values are within their
design ranges.
In abnormal operating condition, inputs and tunable parameter values are outside their
design ranges.
Robustness shall prevent errors such as:
Notes
• Divisions by zero
• Integer overflows
• Out of design range
• Out of bound array
The level of robustness shall be compliant with the software safety integrity level.
• Test generation based on relational boundary coverage
Examples of techniques • Formally-based verification technique with abstract interpretation
• Defensive programming
Rationale Code robustness verification is required to verify the output of the code generator
25
Model Quality Objectives | Version 1.0
Worst case execution time shall be specified during software architectural design phase.
The execution time shall include the generated code and its calling functions (e.g. basic
software services).
Notes
The production target can be an emulator or a representative hardware.
The model tests can be reused on the generated code running on the production target
(aka processor-in-the-loop) and the expected outputs shall still be obtained.
Description The model generated code memory footprint shall be measured and verified.
Memory footprint, such as RAM, ROM, and stack, shall be specified during software
Notes architectural design phase. The memory footprint shall include the generated code and its
calling functions.
• Stack estimation tool
Examples of techniques
The component software memory footprint shall be measured prior the component inte-
Rationale gration to verify compatibility with architecture requirements, avoid shortage of hardware
resource, and enable reuse of component on different architecture.
© 2018 The MathWorks, Inc. MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See [Link]/trademarks for a list of additional trademarks.
Other product or brand names may be trademarks or registered trademarks of their respective holders.
26