51
ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version: 1.1

ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

Embed Size (px)

Citation preview

Page 1: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation

Christopher Myers

Director of Software Development

12 October 2010

Version: 1.1

Page 2: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

2

Christopher Myers [email protected]

Director of Software Development Responsible for designing and managing development

of SimuQuest product lines

Lead Developer of QuantiPhi, a line of code generation tools that bring a hardware interface into the Simulink modeling environment.

PREVIOUS EXPERIENCE:

Working in the area of model-based development using MATLAB / Simulink since 2003.

Production automotive and consumer electronics experience at Motorola since 2000.

Designed high-performance network appliances designed to provide unparalleled visibility into network usage while at Arbor Networks, Inc.

MS, BS from the University of Michigan

Page 3: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

3

Renesas Technology and Solution Portfolio

Microcontrollers& Microprocessors

#1 Market shareworldwide *

Analog andPower Devices#1 Market share

in low-voltageMOSFET**

Solutionsfor

Innovation

Solutionsfor

InnovationASIC, ASSP& Memory

Advanced and proven technologies

* MCU: 31% revenue basis from Gartner "Semiconductor Applications Worldwide Annual Market Share: Database" 25 March 2010

** Power MOSFET: 17.1% on unit basis from Marketing Eye 2009 (17.1% on unit basis).

Page 4: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

44

Renesas Technology and Solution Portfolio

Microcontrollers& Microprocessors

#1 Market shareworldwide *

Analog andPower Devices#1 Market share

in low-voltageMOSFET**

ASIC, ASSP& Memory

Advanced and proven technologies

* MCU: 31% revenue basis from Gartner "Semiconductor Applications Worldwide Annual Market Share: Database" 25 March 2010

** Power MOSFET: 17.1% on unit basis from Marketing Eye 2009 (17.1% on unit basis).

Solutionsfor

Innovation

Solutionsfor

Innovation

Page 5: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

55

Microcontroller and Microprocessor Line-up

Superscalar, MMU, Multimedia Up to 1200 DMIPS, 45, 65 & 90nm process Video and audio processing on Linux Server, Industrial & Automotive

Up to 500 DMIPS, 150 & 90nm process 600uA/MHz, 1.5 uA standby Medical, Automotive & Industrial

Legacy Cores Next-generation migration to RX

High Performance CPU, FPU, DSC

Embedded Security

Up to 10 DMIPS, 130nm process350 uA/MHz, 1uA standbyCapacitive touch

Up to 25 DMIPS, 150nm process190 uA/MHz, 0.3uA standbyApplication-specific integration

Up to 25 DMIPS, 180, 90nm process 1mA/MHz, 100uA standby Crypto engine, Hardware security

Up to 165 DMIPS, 90nm process 500uA/MHz, 2.5 uA standby Ethernet, CAN, USB, Motor Control, TFT Display

High Performance CPU, Low Power

Ultra Low PowerGeneral Purpose

Page 6: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

66

Microcontroller and Microprocessor Line-up

Superscalar, MMU, Multimedia Up to 1200 DMIPS, 45, 65 & 90nm process Video and audio processing on Linux Server, Industrial & Automotive

Up to 500 DMIPS, 150 & 90nm process 600uA/MHz, 1.5 uA standby Medical, Automotive & Industrial

Legacy Cores Next-generation migration to RX

High Performance CPU, FPU, DSC

Embedded Security

Up to 10 DMIPS, 130nm process350 uA/MHz, 1uA standbyCapacitive touch

Up to 25 DMIPS, 150nm process190 uA/MHz, 0.3uA standbyApplication-specific integration

Up to 25 DMIPS, 180, 90nm process 1mA/MHz, 100uA standby Crypto engine, Hardware security

Up to 165 DMIPS, 90nm process 500uA/MHz, 2.5 uA standby Ethernet, CAN, USB, Motor Control, TFT Display

High Performance CPU, Low Power

Ultra Low PowerGeneral Purpose

Page 7: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

7

Innovation: Innovate Faster

Page 8: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

8

Model-Based Design

Model-Based Design and Automatic Code Generation is the

future of embedded controls. SimuQuest believes that as

companies across all industries realize the innovation

advantage that it provides, it will play a part in the design of

nearly all embedded systems worldwide.

Page 9: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

9

Agenda

Introduction to modeling and auto-code

Examples of Simulink / Stateflow

Exploration of design concerns

Fixed-point vs. floating point

Integrating hand code with auto-code

Modeling an entire application: One-Touch code generation

Q&A

Page 10: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

10

Agenda (in other words)

Make the case for modeling and auto-code

Show you what modeling and auto-code is all about

Show you just how far it can be taken

Answer questions

Page 11: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

11

Key Takeaways

Models helps define requirements

Models can be auto-coded

You can use that C code flexibly

Auto-coding is powerful

Auto-coding saves you time

Page 12: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

12

Auto-Code Generation: Why

Software PerspectiveControls Perspective

Page 13: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

13

Modeling: A Software Perspective

Software PerspectiveControls Perspective

Page 14: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

14

Typical Project

Kick-Off Delivery

Eff

ort

Time

Page 15: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

15

Ideal Project

Kick-Off Delivery

Eff

ort

Time

Page 16: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

16

Dollars and Cents Advantage

SOFTWARE DEFECT COSTS

Page 17: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

17

Why Typical Approaches Don’t Work!

Req 1.6.5.9.1.2.3 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut orci nulla. Aenean nulla metus, blandit eget blandit vitae, commodo sit amet metus. Mauris lacinia varius dui, quis dictum nisi aliquet vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nisi nunc, blandit vitae porta vitae, faucibus sit amet neque…

Use Case 1

Use Case n

Or…

Page 18: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

18

A Model-Based Approach

Understand the system we’ll be interacting with. Model it. Develop executable models of system requirements Integrate early and often Bring pre-tested hardware drivers into the modeling environment Auto-generate code

Page 19: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

19

Modeling: A Controls Perspective

Software PerspectiveControls Perspective

Page 20: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

20

Why Auto-Code Generation: R&D

Page 21: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

21

Modeling: Auto-Coding

Software PerspectiveControls Perspective

Page 22: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

22

Our Auto-Coding Toolbox

MATLAB

QuantiPhiRTW Embedded Coder

Simulink & Stateflow

Base computing platform

Modeling platform

Auto-code generation Provides MCU configuration and device drivers.

Page 23: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

23

Building Block: The Feature

Feature

Determine a set point

Condition a user input

Detect a faultDetect a fault

Compute value for an actuator

inputs outputs

triggers

Page 24: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

24

An Example Feature Model

[In Simulink]

Page 25: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

25

What About Integrating the Code?

FeatureData Types

Variables

File Naming

Legacy Code

Target

New Concerns!

Page 26: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

26

What About Integrating the Code?

FeatureData Types

Variables

File Naming

Legacy Code

Target

Page 27: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

27

C to Simulink Mappings

C Typesunsigned charunsigned charcharunsigned short intshort intunsigned long intlong intfloatdouble

Simulink Typesbooleanuint8int8uint16int16uint32int32singledouble

+ additional fixed-point types available

Page 28: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

28

Data Types: Floating and Fixed Point

float my_var = 3.57; float my_var = 3.57;

FPU No FPU

Page 29: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

29

Data Types: Floating and Fixed Point

*IEEE754

1

float*

uint16 0 0 1110000000000

Artificial binary point

ufix16_En4

1 1 0 01010111100011 1 0 0 10

00000001

0

0

Value to represent: 3.57

uint16 3 57

Artificial decimal point(understood that number is 100x higher than real value)

ufix16_Sp01

3 . (0.5 + 0.0625)

Page 30: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

30

Data Types (+Fixed Point) in Simulink

[In Simulink]

Page 31: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

31

Auto-Coding for Different-Sized Targets

FeatureData Types

Variables

File Naming

Legacy Code

Target

Page 32: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

32

More Control Over Generated Code

FeatureData Types

Variables

File Naming

Legacy Code

Target

Page 33: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

33

More Control Over Generated Code

Simple: Can control variable’s: Placement in RAM / ROM Class (const, volatile, etc) Naming Scope (global vs. local)

Advanced: Can control variable’s: Declaration Definition Code needed to read Code needed to write

Page 34: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

34

More Control Over Generated Code (Cont’d)

Simple: Can control subsystem’s: Name of the file containing its code Name of the generated function

Advanced: Can control subsystem’s: Placement in memory (near vs. far for example) RAM / ROM variable placement in memory

Page 35: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

35

Legacy Code

FeatureData Types

Variables

File Naming

Legacy Code

Target

Page 36: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

36

Legacy Code

Feature BackedBy Legacy Code

inputs outputs

triggers

[Go to Simulink]

Step 1:Simulation Behavior

Step 2:Code Generation Behavior

Page 37: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

37

Typical Auto-Coding Methodologies

Feature Effort =

Page 38: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

38

Typical Auto-Coding Methodologies

Feature 1

Feature n

“Application Layer”

Effort =

Page 39: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

39

Typical Auto-Coding Methodologies

Feature 1

Feature n

HardwareInterface

Effort =

Page 40: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

40

Convinced?

Page 41: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

41

The Next Step

Feature 1

Feature n

HardwareInterface

Page 42: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

42

A

B C

Interfacing With Hardware

Page 43: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

43

Interfacing With Hardware

A

B C

PA0

RPM

pwm0

QuantiPhi

Page 44: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

44

Hardware Abstraction Layer

Example of a digital debounce:

Page 45: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

45

Another Hardware Abstraction Layer Example

Example of analog counts to engineering units:

Page 46: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

46

A “One Touch” Example Using QuantiPhi

[In Simulink]

Page 47: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

47

Innovation: Innovate Faster

Page 48: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

48

Related Lab

[In Simulink]

021L: Model Based Control Design and Auto Code Generation using the R8C

Page 49: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

49

Questions?

Page 50: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version:

50

Thank You!

Page 51: ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation Christopher Myers Director of Software Development 12 October 2010 Version: