32
1 © 2015 The MathWorks, Inc. Increasing Design Confidence Paolo Bizzarri Principal Applications Engineer

Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

1© 2015 The MathWorks, Inc.

Increasing Design Confidence

Paolo Bizzarri

Principal Applications Engineer

Page 2: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

3

The Cost of Failure…

Page 3: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

4

Key Message

It is easier and less expensive to fix design

errors early in the process when they happen.

Model and code verification enable:

1. Early testing to increase confidence in your design

2. Delivery of higher quality software throughout the workflow

3. Greater safety!

Page 4: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

5

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

C/C++ CODEMODEL

Page 5: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

6

Application: Control of electromechanical systems

Page 6: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

7

System

Inputs OutputsDiagnostics

FIltering

Overall

Control

Unit

Le

ga

cy c

od

e

ECU / Control Unit

Application: Motor Control

2Motor Control

(MBD)

1

Page 7: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

8

System

Inputs OutputsDiagnostics

Filters

Le

ga

cy c

od

e

Application: Electromechanical Control System

Motor Control

(MBD)

Overall

Control

Unit

Page 8: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

9

Application: Motor Control

Systems Inputs

• Motor On

• Command Type

• Command Value

Sensor Inputs

• Currents, Voltages

• Encoders

Inputs

Engaged

Target speed

Outputs

Motor Control

(MBD)

Position

Speed

Torque

Page 9: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

10

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 10: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

11

Ad-hoc Tests New “Dashboard” blocks facilitate early ad-hoc testing

Page 11: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

12

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 - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

13

Finding Design Errors: Dead Logic

Page 13: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

14

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 - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

15

Simulation Testing Workflow

Design

Requirements

Did we meet

requirements?

Review functional

behavior

Page 15: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

16

Did We Completely Test our Model?

Model Coverage

Analysis

Potential causes of less than 100%

coverage:

Missing requirements

Over/Under-specified design

Design errors

Missing tests

Page 16: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

17

Requirements Based Functional Testing with Coverage Analysis

Sequence Test Editor

(Simulink Test)

Page 17: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

18

Functional Testing with Added Requirements & Test Cases

Page 18: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

19

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Code equiv. & integration checks

Found a major design problems thanks to Simulink

Design Verifier

– A positive number was always evaluated as less than zero

Functional test cases passed

– Simulink Test or Classic Signal Builder manage execution of

tests

Generated extra test cases for better understanding

how to pilot the control logic

– During test cases generation another defect was corrected

(% commented transition)

With some effort 100% model coverage was

reached!

Page 19: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

20

Model Advisor – Model Standards Checking

Page 20: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

21

Gaining Confidence in our Design

Effort / Time

Confidence

Ad-hoc testing

Design error detection

Functional& structural tests

Modeling standards

Model & code equivalence checks

Page 21: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

22

Code Generation with Model-to-Code Traceability

Page 22: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

23

Code Generation with Model-to-Code Traceability

CODESPECS MODEL

CONTROL AND MANAGE

COMPLEXITY

Page 23: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

24

Equivalence Testing:

Model vs SIL or PIL Mode Testing

Model

Testing

SIL or PIL

Mode Testing

Coverage 100%

Page 24: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

25

Code Equivalence Check Results:

Model vs CodeCode Coverage

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

Ran test vectors on generated code using Model Reference SIL mode

Model Coverage to Code Coverage using the SIL Code Coverage Report

Successfully demonstrated code behavior matches model behavior!

Page 25: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

26

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 26: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

32

CODE VERIFICATION TOOLS: Bug Finder and Code Prover

Polyspace Code Analysis is STATIC 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 27: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

33

RESULTS OF BUG FINDER: errors and MISRA rules

MISRA 2012

MISRA 2012

Page 28: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

34

RESULTS OF CODE PROVER: absolute absence of run time errors

NO RTE

(Run Time

Error

Code)

Page 29: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

35

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

Bug Finder finds only two MISRA violations

These violations can be addressed with another transition

OR could be addressed with a different style of code generation

In both cases the re-validation is automatized

Code Prover initially finds possible overflows

If we run analysis with correct input ranges the code is “all green” no RTE

Page 30: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

36

Polyspace Products proven on SOLAR IMPULSE

Visit me at the code verification demo booth …..

Page 31: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

38

Conclusion

It is easier and less expensive to fix design

errors early in the process when they happen.

Model and code verification enable:

1. Early testing to increase confidence in your design

2. Delivery of higher quality software throughout the workflow

3. Greater safety!

Page 32: Increasing Design Confidence - MathWorks · Gaining Confidence in our Design Bug Finder finds only two MISRA violations These violations can be addressed with another transition OR

39© 2015 The MathWorks, Inc.