Top Banner
1 © 2017 The MathWorks, Inc. Increasing Design Confidence Model and Code Verification
43

Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

Jul 25, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

1© 2017 The MathWorks, Inc.

Increasing Design Confidence

Model and Code Verification

Page 2: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

2

The Cost of Failure…

$7,500,000,000

Ariane 5

Rocket & payload lost

Page 3: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

3

The Cost of Failure…

0 KnotsTop speed

0

USS Yorktown

Page 4: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

4

The Cost of Failure…

Casualtiesdue to radiation overdose

6

Therac-25

Page 5: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

5

Motivation

It is easier and less expensive to fix design errors

early in the process when they happen.

Model-Based Design enables:

1. Early testing to increase confidence in your design

2. Delivery of higher quality software throughout the workflow

Page 6: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

6

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Model & code equivalence checks

Code integration analysis

Page 7: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

7

Application: Cruise Control

50 km/h

Control speed according to setpoint

Page 8: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

8

System

Inputs OutputsFuel Rate Control

Module

Shift Logic

Control Module

ECU

system

Le

ga

cy c

od

e

ECU

Application: Cruise Control

2Cruise Control

Module (MBD)

1

Page 9: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

9

System

Inputs OutputsFuel Rate Control

Module

Shift Logic

Control Module

ECU

system

Le

ga

cy c

od

e

ECU

Application: Cruise Control

Cruise Control

Module (MBD)

Page 10: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

10

Application: Cruise Control

Cruise_onoff

Brake

Speed

Coast set

Accel reset

Inputs

Engaged

Target speed

Outputs

Cruise Control

Module (MBD)

Page 11: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

11

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling & coding standards

Code equiv. & integration checks

Page 12: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

12

Ad-hoc Tests

Dashboard blocks facilitate

early ad-hoc testing

Page 13: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

13

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling & coding standards

Code equiv. & integration checks

Page 14: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

14

Finding Design Errors: Dead Logic

Page 15: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

15

Finding Unintended Behavior

Dead logic due to “uint8” operation on incdec/holdrate*10

Fix change the order of operation 10*incdec/holdrate

Condition can never be false

Page 16: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

16

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling & coding standards

Code equiv. & integration checks

Page 17: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

17

Simulation Testing Workflow

Structural coverage

report

Did we completely

test our model?

Did we meet

requirements?

Review functional

behavior

Design

Requirements

Page 18: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

18

Did We Completely Test our Model?

Model Coverage

Analysis

Potential causes of less

than 100% coverage:

Missing requirements

Over-specified design

Design errors

Missing tests

Page 19: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

19

Requirements Based Functional Testing with Coverage Analysis

All 14 requirements based test cases pass

By analyzing model coverage results we find:

– Missing test cases for vehicle speed exit conditions, and

– Missing requirements (and test cases) for “hold” or

continuous speed button input

Page 20: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

20

Functional Testing with Added Requirements & Test Cases

Page 21: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

21

Functional Testing with Added Requirements & Test Cases

Added 2 new requirements for the “hold” case for speed setting input buttons

Added 5 test cases to the original 14 requirements based test cases

– 3 test cases for the 2 new requirements

– 2 test cases for the missing test cases for the vehicle speed exist conditions

4/5 new functional test cases pass

– Failed test case showed overshoot beyond target speed limits

– Coverage analysis highlighted transitions with design errors

– Fixed comparison operators, (<) (<=), and (>) (>=)

Now all (19) functional test cases pass with 100% model coverage!

Page 22: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

22

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Code equiv. & integration checks

Page 23: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

23

Model Advisor – Model Standards Checking

Page 24: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

24

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Model & code equivalence checks

Page 25: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

25

Equivalence Testing:

Model vs SIL or PIL Mode Testing

Model

Testing

SIL or PIL

Mode Testing

Coverage 100%

Page 26: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

26

Code Generation with Model-to-Code Traceability

Page 27: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

27

Code Generation with Model-to-Code Traceability

Page 28: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

28

Code Equivalence Check Results:

Model vs Code

Page 29: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

29

Code Equivalence Check Results:

Model vs Code

Page 30: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

30

Code Equivalence Check Results:

Model vs Code Code Coverage

Page 31: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

31

Code Equivalence Check Results:

Model vs Code Code Coverage

Re-used full coverage test vectors and harnesses from Model Verification testing

Ran test vectors on generated code using Model Reference SIL mode

Equivalence test performed in Simulink Test, including test execution, evaluation

and presentation of the results

Compared Model Coverage to Code Coverage using the SIL Code Coverage

Report

Successfully demonstrated code behavior matches model behavior!

Page 32: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

32

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Model & code equivalence checks

Code integration analysis

Page 33: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

33

System

Inputs OutputsFuel Rate Control

Module

Shift Logic

Control Module

ECU

system

Le

ga

cy c

od

e

ECU

2Cruise Control

Module (MBD)

1

Code Integration Analysis

Page 34: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

34

Fuel Rate Control

Module

Shift Logic

Control Module

ECU

system

Le

ga

cy c

od

e

ECU

Code Integration Analysis

2

Cruise_onoff

Brake

Speed

Coast set

Accel reset

EGO Sensor

MAP Sensor

Inputs

Gear

Engaged

Target speed

Fuel Rate

OutputsCruise Control

Module (MBD)

Page 35: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

35

Fuel Rate Control

Module

Shift Logic

Control Module

ECU

system

Le

ga

cy c

od

e

ECU

Cruise_onoff

Brake

Speed

Coast set

Accel reset

EGO Sensor

MAP Sensor

Inputs

Gear

Engaged

Target speed

Fuel Rate

Outputs

Inaccurate

scaling for

speed

Finding Dead Code During Integration

Dead c

ode

Cruise Control

Module (MBD)

2

Page 36: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

36

Finding Dead Code with Polyspace

Dead code

Maximum target speed = 90Target speed parameter

propagated to “Cruise_ctrl.c”

[0 … 40]

Page 37: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

37

Root Cause for Dead Code: Speed Sensor Input Hand Code

Changing analog-to-digital converter from 14 to 12-bit results in dead code

MASK – accounts for scaling

down for new ADC from 14-bit to

12-bit

CONV_FACTOR – accounts for

translating sensor input counts to

mph

Overlooked changing

CONV_FACTOR for new ADC

Page 38: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

38

Polyspace Code Analysis

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;

}

}

Start with C/C++ source code

Page 39: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

39

Polyspace Code Analysis

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;

}

}

Source code painted in green, red, gray, orange

Green: reliablesafe pointer access

Red: faultyout of bounds error

Gray: deadunreachable code

Orange: unprovenmay be unsafe for some

conditions

Purple: violationMISRA-C/C++ or JSF++

code rules

variable ‘I’ (int32): [0 .. 99]

assignment of ‘I’ (int32): [1 .. 100]

Range datatool tip

Page 40: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

40

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Model & code equivalence checks

Code integration analysis

Gaining Confidence in our Design

Page 41: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

41

Conclusion: Model-Based Design Verification Workflow

Model VerificationDiscover design errors at design time

Code VerificationGain confidence in the generated code

Workflow approved by TÜV SÜD for development of safety-critical software in accordance with

ISO 26262 (automotive), IEC 61508 (industrial), EN 50128 (railway), IEC 62304 (medical devices)

Page 42: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

42

Conclusion

It is easier and less expensive to fix design errors

early in the process when they happen.

Model-Based Design enables:

1. Early testing to increase confidence in your design

2. Delivery of higher quality software throughout the workflow

Page 43: Increasing Design Confidence · Gaining Confidence in our Design. 41 Conclusion: Model-Based Design Verification Workflow Model Verification Discover design errors at design time

43

Change the world by

Accelerating the paceof discovery, innovation, development, and learning

in engineering and science