From Design to Production An integrated approach Paolo Fabbri Senior Engineer 2014 The MathWorks, Inc. 1
Do you know what it is? Requirements System Test Functional Spec Integration Test Detailed Design Unit Test Implementation 2
Is the industry still using this approach for Embedded Software Development? 3
For Sure! But it s more about Modeling and Simulation Requirements System Test Functional Model Design Spec Integration HIL Simulation Test Detailed Model Design V&V Code Unit Test V&V Code Implementation Generation 4
Case Study: Vehicle Speed Limiter 74 Speed limiter 72 X: 10.9 Y: 71.1 Requirements System Test 70 68 Model Design HIL Simulation m/h 66 Actual speed Setpoint 64 Model V&V Code V&V 62 Code Generation 60 0 10 20 30 40 50 60 Time 5
Project Management in Simulink 6
Simulink Project Collaborative development Source Control Integration Support for svn and git Model compare/merge Data compare/merge Files Management Dependencies Analysis Impact Analysis 7
Source Control Integration 8
Model Comparison 9
Data Dictionary Comparison 10
Dependency and Impact Analysis 11
Manage Complexity in Simulink 12
Typical challenges with large projects Reuse models among different teams and projects Manage multiple design options in a single-model workflow Share models outside the team protecting IP Ensure proper modeling rules and configuration Ensure data consistency across models...what else? 13
Component-Based Modeling Reuse models among different teams and projects Modular Architecture Reusable Models Plant Expert Variants Management IP Protection Control Designer Control Designer 14
Model and Subsystem Variants 15
Protected Models for IP Protection Read-Only View Support Simulation Support Code Generation Support 16
Model Advisor Technology Ensure proper modeling rules and configuration Modeling Standards MISRA-C:2004 MAAB Style Guidelines IEC-61508/ISO-26262 EN-50128 DO-178C/DO-331 Specialized Advisor Upgrade Advisor Performance Advisor Code Generation Advisor 17
Simulink Data Dictionary Ensure data consistency across models Design Data Configuration Sets Change tracking Data partitioning Scalability and performance Simulink Projects Integration 18
Simulink Data Management System Simulink Project + Define 101 010 Collaborate Store Model Explorer Simulink Data Dictionary + Manage Partition 101 010 Simulink Data Objects Access 19
Model Verification and Validation 20
Early Model Verification and Validation Simulation, simulation, simulation... Simulation Data Inspection Simulation Comparison Coverage Analysis Requirements Model Design HIL Simulation System Test Model V&V Code V&V Code Generation 21
Analyze Simulation Data with Simulation Data Inspector 22
Simulation Comparison 23
Model Coverage Analysis 24
Embedded Code Generation and Verification 25
Embedded Code Generation Unified Code Generation Objective-Based Workflow Code Report and Code Metrics Requirements Model Design HIL Simulation System Test Model V&V Code V&V Code Generation 26
Unified Code Generation Capabilities Simulink Unified Code Generation C Code C++ Code HDL Code PLC Code MATLAB Stateflow 27
BLACK BOX P O W E R V R C S I N P U T B L U E G R E E N R E D Algorithm Export Controller Model Communication Interfaces Comm Drivers Generated Algorithm Code Output Drivers M Actuators Sensors A B C Input Drivers Included Target Optimized Code Included Legacy Code Special Device Drivers RGBSplit-4 Scheduler/Operating System and Support Utilities Special Interfaces 28
BLACK BOX P O W E R V R C S I N P U T B L U E G R E E N R E D Full Executable Controller Model Driver Blocks Scheduler Communication Interfaces Comm Drivers Generated Algorithm Code Output Drivers M Actuators Sensors A B C Input Drivers Included Target Optimized Code Included Legacy Code Special Device Drivers RGBSplit-4 Scheduler/Operating System and Support Utilities Special Interfaces 29
Code Integration Approaches Purpose Algorithm Export Mass Production Full Executable On-Target Rapid Prototyping Low Volume Production Usage Systems and software engineers Systems engineers Hardware Any processor Specific Hardware Kits or Boards Flexibility Higher Lower Ease of Use (Turnkey) Works after one-time customization Works out-of-the-box 30
Objective-Based Code Generation 31
Code Report and Code Metrics 32
Embedded C Code Verification In-the-Loop Simulations Code Execution Profiling Source Level Debugging Code Coverage Analysis Requirements Model Design Model V&V Code V&V HIL Simulation System Test Run-Time Error Detection Code Generation 33
«In-the-Loop» Simulations 34
MIL/SIL/PIL Simulation Comparison 35
Code Execution Profiling 36
Source Level Debugging in SIL 37
Code Coverage Analysis 38
Polyspace Technology Finds bugs Checks coding rule conformance (MISRA/JSF/Custom) Provides metrics (Cyclomatic complexity etc) Proves the existence and absence of run-time errors Certification help for Functional Safety standards 39
Run-time checks proven by Code Prover C run-time checks Unreachable Code Out of Bounds Array Index Division by Zero Non-Initialized Variable Scalar and Float Overflow (left shift on signed variables, float underflow versus values near zero) Initialized Return Value Shift Operations (shift amount in 0..31/0..63, left operand of left shift is negative) Illegal Dereferenced Pointer (illegal pointer access to variable of structure field, pointer within bounds) Correctness Condition (array conversion must not extend range, function pointer does not point to a valid function) Non-Initialized Pointer User Assertion Non-Termination of Call (non-termination of calls and loops, arithmetic expressions) Known Non-Termination of Call Non-Termination of Loop Standard Library Function Call Absolute Address Inspection Points Green: reliable safe pointer access Red: faulty out of bounds error Gray: dead unreachable code Orange: unproven may be unsafe for some conditions static void pointer_arithmetic (void) { int array[100]; int *p = array; int i; for (i = 0; i < 100; i++) { *p = 0; p++; } if (get_bus_status() > 0) { if (get_oil_pressure() > 0) { *p = 5; } else { i++; } } i = get_bus_status(); if (i >= 0) { *(p - i) = 10; } } 40
That s Model-Based Design Requirements System Test Model Design HIL Simulation Model V&V Code V&V Code Generation 41
What is the current industry maturity in the adoption of Model-Based Design? 42
Model-Based Design Maturity Framework 43
Profile of the industries in the benchmark OEMs and Suppliers from all regions of the world Automotive: Passenger, Commercial, Off-Highway Aerospace: Commercial, Military, Space Other: Industrial Automation, Medical, Transportation, Electronics 44
Automotive vs. Aerospace: Leaders Modeling 100 80 Enterprise Management 60 40 Simulation and Analysis 20 0 Aero Auto Process, Tools and Infrastructure Implementation Verification and Validation 45
Thank you! 46