Вы находитесь на странице: 1из 23

DO Qualification Kit

Simulink® Code Inspector™


Tool Operational Requirements

R2015a, March 2015


How to Contact MathWorks
Latest news: www.mathworks.com
Sales and services: www.mathworks.com/sales_and_services
User community: www.mathworks.com/matlabcentral
Technical support: www.mathworks.com/support/contact_us
Phone: 508-647-7000

The MathWorks, Inc.


3 Apple Hill Drive
Natick, MA 01760-2098
DO Qualification Kit: Simulink® Code Inspector™ Tool Operational Requirements
© COPYRIGHT 2012–2015 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under
the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written
consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the
federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees
that this software or documentation qualifies as commercial computer software or commercial computer software documentation
as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modification,
reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or
other entity acquiring for or through the federal government)and shall supersede any conflicting contractual terms or conditions.
If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the
government agrees to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a
list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective
holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more
information.
Revision History
March 2012 New for Version 1.6 (Applies to Release 2012a)
September 2012 Revised for Version 2.0 (Applies to Release 2012b)
March 2013 Revised for Version 2.1 (Applies to Release 2013a)
September 2013 Revised for Version 2.2 (Applies to Release 2013b)
March 2014 Revised for Version 2.3 (Applies to Release 2014a)
October 2014 Revised for Version 2.4 (Applies to Release 2014b)
March 2015 Revised for Version 2.5 (Applies to Release 2015a)
Contents
1 Introduction ...................................................................................................................................... 1-1
1.1 Simulink Code Inspector Product Description ........................................................................ 1-2
2 Operational Requirements ................................................................................................................ 2-1
2.1 Code Inspector Report Operational Requirements .................................................................. 2-2
2.2 Code Inspection User Information ........................................................................................ 2-10
3 Installation ........................................................................................................................................ 3-1
4 Operational Environment ................................................................................................................. 4-1

v
vi
1 Introduction

This document comprises the Tool Operational Requirements (Reference DO-330 Section
10.3.1) for the following capabilities of the Simulink® Code Inspector™ verification product:

 Code inspection report

The document identifies:

 Features of the Simulink Code Inspector product.


 The environment in which the Simulink Code Inspector product is installed (Reference
DO-330, Sections 10.2.4 and 10.3.2).

This document is intended for use in the DO-330 tool qualification process for TQL-4 tools. The
applicant needs to:

 Review the Tool Operational Requirements for applicability in the project or program
under consideration.
 Configure the Tool Operational Requirements in the project or program’s configuration
management system.
 Complete the Tool Operational Requirements and make the document available for review.

For more information about the following products, see the MathWorks® Documentation
Center, R2015a:

 Simulink Code Inspector


 Simulink®
1.1 Simulink Code Inspector Product Description
Automate source code reviews for safety standards
Simulink® Code Inspector automatically compares generated code with its source model to
satisfy code-review objectives in DO-178 and other high-integrity standards. The code inspector
systematically examines blocks, state diagrams, parameters, and settings in a model to determine
whether they are structurally equivalent to operations, operators, and data in the generated code.
Simulink Code Inspector provides detailed model-to-code and code-to-model traceability
analysis. It generates structural equivalence and traceability reports that you can submit to
certification authorities to satisfy DO-178 software coding verification objectives.

Key Features
 Structural equivalence analysis and reports
 Bidirectional traceability analysis and reports
 Compatibility checker to restrict model, block, state diagrams, and coder usage to operations
typically used in high-integrity applications
 Tool independence from Simulink® code generators

Simulink Code Inspector carries out translation validation. Inputs to the Code Inspector are a
Simulink model and the C source code generated by the Embedded Coder® code generator for
the model. To be compatible with code inspection, the code generated by Embedded Coder
must comply with either the ANSI C89/C90 or ISO/IEC 9899:1990 standard.

The code inspector processes these two inputs into internal representations (IRs), called model
IR and code IR. These IRs are transformed into normalized representation’s to facilitate further
analysis. In this process, the model IR represents the expected pattern, and the code IR
constitutes the actual pattern to be verified. To verify the generated code, the Code Inspector
attempts to match the normalized model IR with the normalized code IR.

1-2
Figure 1 shows the architecture of Simulink Code Inspector.

Figure 1: Simulink Code Inspector Architecture

1-3
1-4
2 Operational Requirements
2.1 Code Inspector Report Operational Requirements
The Simulink® Code Inspector™ product includes the capability to generate a code inspection
report for a Simulink® model and its generated code. The report provides detailed analysis of
structural equivalence and bidirectional traceability between the model and the code generated
from the model.

The code inspection report contains the following major sections:

 Code Verification Results — Summary and detailed reports on verification of structural


equivalence between model and code elements. Categories include:

 Function Interface Verification


 Model To Code Verification
 Code To Model Verification
 Temporary Variable Usage
 Traceability Results — Summary and detailed reports on

 Model To Code Traceability


 Code To Model Traceability
Code inspection automatically compares generated code with its source model to satisfy code-
review objectives in DO-178C/DO-331 and other high-integrity standards. The code inspection
process builds an in-memory representation of the model that is independent of the code
generation process. The Simulink Code Inspector systematically examines blocks, parameters,
and settings in a model to determine whether they are structurally equivalent to operations,
operators, and data in the generated code, and generates reports that can be used to support
software certification.

2-2
Prior to code inspection, the Simulink Code Inspector provides compatibility checks to verify
model compatibility with code inspection. The model incompatibilities are either fatal or
nonfatal.

 Code generated from models with fatal incompatibilities cannot be verified. The user
is notified with a message and code inspection terminates.

 Code generated from models with nonfatal incompatibilities can be partially verified.
Although it might not be possible to fully verify the generated code, code inspection
continues.

The aspects of a Simulink model that are analyzed by code inspection include the following:

 Model and code compatibility


 Model interface
 Block behavior
 Stateflow® behavior
 MATLAB Function block behavior
 Block connectivity and execution order
 Data and file packaging
 Local variables
 Configuration parameters

The following table lists the Simulink Code Inspector capabilities that are supported by the DO
Qualification Kit. To claim certification credit, the user is responsible for determining the
applicability of the Simulink Code Inspector capabilities supported by the DO Qualification Kit
to their project.

2-3
Simulink Code Inspector — Operational Requirements Summary

Requirement ID Requirement Example of Limitations


Detectable Condition
Model and Code Compatibility
MDLCOMPILE If a model does not compile, If a model does not compile, code None
Simulink Code Inspector shall inspection terminates with an error
consider the model invalid and post message.
an error message.
INVSRCCODE If the source code cannot be parsed, If source code cannot be parsed, code None
Simulink Code Inspector shall inspection terminates with an error
consider the code invalid and post an message.
error message.
MDLFATAL Simulink Code Inspector shall detect Code inspection terminates when the None
if the model is fatally incompatible model does not use an ert-based
with code inspection and terminate system target file.
the inspection.
MDLNONFATAL Simulink Code Inspector shall detect Code inspection continues when Sum None
if the model is nonfatally block input and output ports do not
incompatible with code inspection have the same data type.
and, by default, continue the
inspection.
NONFATALCHOICE Simulink Code Inspector shall allow Code inspection terminates for a None
the user to terminate code inspection nonfatally incompatible model and
for nonfatal incompatibilities. user has speceted the option to
terminate inspection for a nonfatally
incompatible model.
Model Interface
MDLINTFUNCGEN Simulink Code Inspector shall verify Model step function is missing. None
that the model interface functions are
implemented in the generated code.
MDLINTDATAGEN Simulink Code Inspector shall verify Root input data structure for a bus is Arrays and built-in types
that the model interface data missing. are supported for
structures are implemented in the inspection. For structures,
generated code. the name or tag is verified,
but not the structure fields.
MDLINTFUNCSIG Simulink Code Inspector shall verify Model step function argument None
that the model interface functions sequence differs from function
have the expected signatures prototype control specification.
MDLINTIOGEN Simulink Code Inspector shall verify External input for initialization Arrays and built-in types
that the expected input and output function was not initialized as are supported for
data structures are implemented in expected. inspection. For structures,
the generated code. the name or tag is verified,
but not the structure fields.
Block Behavior

2-4
Requirement ID Requirement Example of Limitations
Detectable Condition
BLKCOMPS Simulink Code Inspector shall verify Code for a Unit Delay block does not None for blocks supported
that code generated for a block include code for updating its state for inspection.*
includes all components of variable.
functionality.
BLKCOMPSEXP Simulink Code Inspector shall verify Code includes two independent None for blocks supported
that code generated for a block addition operations that trace to the for inspection.*
includes only expected instances of same Sum block.
component functionality.
BLKCOMPSTRACE Simulink Code Inspector shall verify A segment of code exists that does None for blocks supported
that code segments trace back to not trace back to a block source. for inspection.*
block component functionality and
that system logic code traces back to
system functionality.
BLKCOMPSCONFIG Simulink Code Inspector shall verify A Relational Operator block is None for blocks supported
that code for block component configured for an equal (==) for inspection.*
functionality represents the current operation, but it traces to code that
block configuration. applies a not equal (!=) operation.
BLKCOMPSSYSFUNC Simulink Code Inspector shall verify The output code for a Unit Delay None for blocks supported
that code for block component block is in the start function of the for inspection.*
functionality is in the corresponding parent system.
system function.
BLKCOMPSPROPS Simulink Code Inspector shall verify A Gain block with an output data None for blocks supported
that property settings in the code are type of double traces to code that for inspection.*
compliant with settings for assigns the block output to variable of
corresponding source blocks. type real32_T.
BLKCRL Simulink Code Inspector shall verify Code for Sqrt block does not use a For a list of functions and
that code generated for a block uses function or operation supported for operations supported for
functions and operations supported code inspection in the CRL. code inspection, see
for code inspection in the Code “Supported Functions and
Replacement Libraries (CRLs). Operations in Code
Replacement Libraries” in
the Simulink Code
Inspector Tool
Requirements, R2015a.
* For a list of blocks supported for code inspection, see “Supported Block Constraints” in the Simulink Code Inspector Tool
Requirements, R2015a.
Stateflow Behavior
SFFLOWGRAPH Simulink Code Inspector shall verify Stateflow does not generate a control See “Stateflow Charts” in
that the generated code execution flow with more than 1 default the Simulink Code
order and execution paths represent transition. Inspector Tool
the execution order and execution Requirements, R2015a.
paths in the Stateflow Chart.

2-5
Requirement ID Requirement Example of Limitations
Detectable Condition
SFSTATES Simulink Code Inspector shall verify Stateflow does not generate a control See “Stateflow States” in
that the code generated for a state flow with more than 1 default the Simulink Code
represents the corresponding state in transition. Inspector Tool
the model, including entry, during, Requirements, R2015a.
and exit actions.
SFTRANSITION Simulink Code Inspector shall verify A condition action uses operator cos See “Stateflow
that the code generated for a and the generated code has operator Transitions” in the
transition represents the sin. Simulink Code Inspector
corresponding transition in the Tool Requirements,
model, including conditions and R2015a.
actions.
SFJUNCTION Simulink Code Inspector shall verify An unconditional transition executing See “Stateflow Junctions”
that the code generated for a junction last in the chart is executed first in the in the Simulink Code
represents the corresponding generated code. Inspector Tool
junction in the model and includes Requirements, R2015a.
all transition paths into and out of
the junction.
SFDATA Simulink Code Inspector shall verify Output of Stateflow block with data See “Stateflow Data and
that the Stateflow data in the type uint32_T traces to code that Events” in the Simulink
generated code represents the model assigns the block output to variable of Code Inspector Tool
data. data type int8_T. Requirements, R2015a.
SFEVENT Simulink Code Inspector shall verify Output trigger type is Either edge See “Stateflow Data and
that the code generated for instead of function-call. Events” in the Simulink
function-call event represents Code Inspector Tool
the function-call event in the Requirements, R2015a.
model.
SFGRAPHFUNC Simulink Code Inspector shall verify Stateflow graphical function property See “Stateflow Graphical
that the code generated for a InlineOption is set to Inline Functions” in the Simulink
graphical function represents the but the generated code has a Code Inspector Tool
graphical function in the model, function. Requirements, R2015a.
including the control flow.
SFSLFUNC Simulink Code Inspector shall verify Generated code does not inline the See “Stateflow Simulink
that the code generated for a correct Simulink function when Functions” in the Simulink
Simulink function represents the Simulink functions exist in both a Code Inspector Tool
Simulink function in the model. chart and a state within the chart. Requirements, R2015a.
MATLAB Function block behavior
MLFUNCFLOW Simulink Code Inspector shall verify In a MATLAB Function block, a See “Code in MATLAB
that the generated code execution variable is updated after it is Functions” in the Simulink
order and execution paths represent consumed. However, in the generated Code Inspector Tool
the execution order and execution code, it is updated before it is Requirements, R2015a.
paths in the MATLAB function. consumed.

2-6
Requirement ID Requirement Example of Limitations
Detectable Condition
MLFUNCDATA Simulink Code Inspector shall verify Output of MATLAB Function block See “Data in MATLAB
that the MATLAB function data in with data type uint32 traces to code Functions” in the Simulink
the generated code represents the that assigns the block output to Code Inspector Tool
model data. variable of data type int32. Requirements, R2015a.
MLFUNCOPER Simulink Code Inspector shall verify A statement in a MATLAB Function See “MATLAB Function
that the code generated for block using a plus (+) operator traces Blocks” in the Simulink
MATLAB function block operators to code that performs a subtraction (-) Code Inspector Tool
represents the current block operation. Requirements, R2015a.
functionality.
Block Connectivity and Execution Order
BLKDATADEPEND Simulink Code Inspector shall verify A Gain block generates a None
that the data dependency between multiplication operation with one
two block components is preserved operand as its parameter and another
in the generated code. operand as a variable not written to
by the source of the Gain block.
BLKDATADEFUSE Simulink Code Inspector shall verify A variable buffer is written to by the None
that the data definition and use operation of block A. It is written to
dependencies in the code reflect the again by the operation of block B
dependencies in the model. before a destination block for block A
has read the first value.
BLKINPUT Simulink Code Inspector shall verify A Gain block uses input from a None
that the block input sources in the muxed signal for input ports 1 and 2
code represent the block input (in that order). The generated
sources in the model. multiplication code for the Gain
block represents the block input
sources in a different order than
expected. For example,
[y1, y2] = [k2, k1] .* [u1 u2]
or
[y1, y2] = [k1, k2] .* [u2 u1]
instead of
[y1, y2] = [k1, k2] .* [u1 u2]
BLKINDEX Simulink Code Inspector shall verify A Gain block is fed by a Bus Selector None
that the data selection in the code that selects field f1 from bus foobus.
represents the data selection in the The multiplication operation in the
model. code is on foobus.
BLKEXEORDER Simulink Code Inspector shall verify Gain block A feeds a Unit Delay None
that the code execution order is block B. The update code of Unit
consistent with model element Delay block B appears before the
execution order. output code of Gain block A.
Data and File Packaging

2-7
Requirement ID Requirement Example of Limitations
Detectable Condition
SIGOBJAUTO Simulink Code Inspector shall verify Signal sig1 is specified with the None
that signal objects with auto storage auto storage class. In the code,
classes in the code represent signal sig1 is represented as a global
objects with auto storage classes in variable instead of an element of the
the model. output data structure.
SIGOBJGLOB Simulink Code Inspector shall verify Signal sig1 is specified with the Code inspection is
that signal objects that do not have ExportedGlobal storage class. In supported for Simulink
an storage class in the code the code, sig1 is represented as a global and other storage
represent signal objects that do not global variable. classes with Custom
have an auto storage class in the Storage Class types set to
model. Unstructured.
PARAMOBJAUTO Simulink Code Inspector shall verify Parameter K is specified with the None
that parameter objects with storage auto storage class. In the code, the
class auto in the code represent literal value of the parameter is
parameter objects with storage class represented as a global variable
auto in the model. instead of its literal value or an
element of the parameter data
structure.
PARAMOBJTUNA Simulink Code Inspector shall verify Parameter K is specified with the Code inspection is
that parameter objects that do not ExportedGlobal storage class. In supported for Simulink
have an auto storage class in the the code, the literal value of the global and other storage
code represent parameter objects that parameter is represented as a global classes with Custom
do not have an auto storage class in variable. Storage Class types set to
the model. (For example, Simulink Unstructured.
Code Inspector will verify that
tunable parameters in the code
represent tunable parameters in the
model.)
PARAMINLINE Simulink Code Inspector shall verify A Gain block has its Gain parameter None
that Inlined parameter values in the set to 3.0. The code uses the literal
code represent Inlined parameter value 4.0 in the multiplication
values in the model. operation.
Local Variables
LCLVARUSED Simulink Code Inspector shall Local variable tmp is defined but not None
verify that all local variables are used.
used.
LCLVARDEF Simulink Code Inspector shall Local variable tmp is used, but is not None
verify that all local variables are defined.
defined before initial use.
Configuration Parameters

2-8
Requirement ID Requirement Example of Limitations
Detectable Condition
SOLVERPANE Simulink Code Inspector shall detect Model specifies a single sample time, See “Configuration
configuration parameter settings on but the generated code has multirate Parameter Constraints” in
the Solver Pane that are not code. the Simulink Code
compatible with code inspection. Inspector Tool
Requirements, R2015a.
DATAPANE Simulink Code Inspector shall detect Configuration parameter See “Configuration
configuration parameter settings on InitialState is set to ‘’, but the Parameter Constraints” in
the Data Import/Export Pane that are generated code has code for initial the Simulink Code
not compatible with code inspection. state override. Inspector Tool
Requirements, R2015a.
OPTPANE Simulink Code Inspector shall detect Configuration parameter See “Configuration
configuration parameter settings on StateBitSets is set to off, but Parameter Constraints” in
the Optimization Pane that are not the generated code behaves as if this the Simulink Code
compatible with code inspection. parameter is on. Inspector Tool
Requirements, R2015a.
DIAGPANE Simulink Code Inspector shall detect Configuration parameter See “Configuration
configuration parameter settings on UnderspecifiedInitializat Parameter Constraints” in
the Diagnostics Pane that are not ionDetection is set to the Simulink Code
compatible with code inspection. Simplified, but the generated Inspector Tool
code has code for Classic mode. Requirements, R2015a.
HWPANE Simulink Code Inspector shall detect Configuration parameter See “Configuration
configuration parameter settings on ProdBitPerShort is set to 16, Parameter Constraints” in
the Hardware Implementation Pane but the generated code uses 32. the Simulink Code
that are not compatible with code Inspector Tool
inspection. Requirements, R2015a.
MODREFPANE Simulink Code Inspector shall detect A referenced model has None
configuration parameter settings on ModelReferenceNumInstance
the Model Referencing Pane that are sAllowed set to Multi, but the
not compatible with code inspection. generated code for it has single-
instance code.
CODEGENPANE Simulink Code Inspector shall detect On Code Generation: Interface > See “Configuration
configuration parameter settings on Data pane, configuration parameter Parameter Constraints” in
the Code Generation Pane that are Interface is set to None, but the the Simulink Code
not compatible with code inspection. generated code has initialization code Inspector Tool
for error C-API interface. Requirements, R2015a.

2-9
2.2 Code Inspection User Information
For information about code inspection reports, see “Code Inspection Reports” in the Simulink
Code Inspector User’s Guide, R2015a.

For a list of blocks supported for code inspection, see “Supported Block Constraints” in the
Simulink Code Inspector Tool Requirements, R2015a.

For information about model configuration, block, Stateflow, and MATLAB function
constraints when using the Simulink Code Inspector to inspect code, see the following sections
in the Simulink Code Inspector Tool Requirements, R2015a:

 “Model Configuration Constraints”


 “Block Constraints”
 “Stateflow Constraints”
 “MATLAB Function Block Constraints”

For traceability between the operational requirements and tool requirements, see

qualkitdo_slci_tor_tr_trace.xlsx

To access these documents, on the MATLAB command line, type qualkitdo to open the
Artifacts Explorer. The documents are in Simulink Code Inspector > r2015a.

2-10
3 Installation

To use the Simulink® Code Inspector™ product, install the following MathWorks® products:

 MATLAB®
 Simulink®
 Simulink Code Inspector

To generate model code for inspection, install the following MathWorks products:

 MATLAB® Coder™
 Simulink® Coder™
 Embedded Coder®

Instructions for installing the products are available at the MathWorks Documentation Center,
R2015a:

Installation
3-2
4 Operational Environment

The DO Qualification Kit product supports the following operating environments for the
Simulink® Code Inspector™ product:

 Personal computer
 One of the following operating systems:
 Microsoft® Windows®
 Linux®1
 MATLAB® Software
 Simulink® Software
 Simulink Code Inspector software

1
Linux® is a registered trademark of Linus Torvalds.

Вам также может понравиться