cyberphysical systems & embedded processors een 417 fall 2013 8/27/13, dr. eric rozier, v1.0,...

73
CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Upload: keith-matthys

Post on 14-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

CYBERPHYSICAL SYSTEMS&EMBEDDED PROCESSORS

EEN 417Fall 2013

8/27/13, Dr. Eric Rozier, V1.0, ECE

Page 2: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

CYBERPHYSICAL SYSTEMS

Page 3: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Model-Based Design

Page 4: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Cyber Physical Systems:Computational +

Physical

CPS is Multidisciplinary

Computer Science:

Carefully abstracts the physical world

System Theory:

Deals directly with physical quantities

Page 5: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Challenge

Page 6: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What this course is about

• A principled and scientific approach to engineering embedded systems– Modeling, Design, Implementation, Testing,

Analysis– Not just hacking!

Page 7: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Traditionally, embedded systems has been an industrial (not academic) problem, about resource limitations.

small memory small data word sizes relatively slow clocks

•When these are the key problems, emphasize efficiency: write software at a low level (in assembly code or C) avoid operating systems with a rich suite of services develop specialized computer architectures:

– programmable DSPs– network processors

develop specialized networks– Can, FlexRay, TTP/C, MOST, etc.

•This is how embedded SW has been designed for 30 years

Page 8: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

But embedded systems do have more fundamental differences from general-purpose computation:

•time matters– “as fast as possible” is not good enough

•concurrency is intrinsic– it’s not an illusion (as in time sharing), and– it’s not (necessarily) about exploiting parallelism

•processor requirements can be specialized– predictable, repeatable timing– support for common operations (e.g. FIR filters)– need for specialized data types (fixed point, bit vectors)

•programs need to run (essentially) forever– memory usage has to be bounded (no leaks!!)– rebooting is not acceptable

Page 9: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What about “real time”?

Make it faster!What if you need “absolutely positively on time”?

Today, most embedded software engineers write code, build your system, and test for timing. Model-based design seeks to specify dynamic behavior (including timing) and “compile” implementations that meet the behavior.

Page 10: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Prioritize and Pray!

Real-Time Multitasking?

All too often, real-time operating systems (RTOSs) are used in a rather ad hoc way. Without any particular principles, engineers tweak priorities until the prototype works under test.

The resulting system is brittle, meaning the small changes in the operating conditions (or in the design of the system) can cause big changes in behavior. For example, replacing the processor with a faster one can cause real-time failures.

Page 11: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

An engineer’s responsibility

Korean Air 747 in Guam, 200 deaths (1997) 30,000 deaths and 600,000 injuries from medical devices (1985-2005)

– perhaps 8% due to software?

•source: D. Jackson, M. Thomas, L. I. Millett, and the Committee on Certifiably Dependable Software Systems, "Software for Dependable Systems: Sufficient Evidence?," National Academies Press, May 9 2007.

Page 12: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

A Story

•A “fly by wire” aircraft, expected to be made for 50 years, requires a 50-year stockpile of the hardware components that execute the software.

•All must be made from the same mask set on the same production line. Even a slight change or “improvement” might affect timing and require the software to be re-certified.

Page 13: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Abstraction Layers•The purpose for an abstraction is to hide details of the implementation below and provide a platform for design from above.

Page 14: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Abstraction Layers•Every abstraction layer has failed for time-sensitive applications.

Page 15: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Is the problem intrinsic in the technology?

•Electronics technology delivers highly repeatable and precise timing…•… and the overlaying software abstractions discard it.

20.000 MHz (± 100 ppm)

Page 16: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

EMBEDDED PROCESSORS

Page 17: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Typical PC Architecture• Single processor

• (plus GPU)• Not a lot of concurrency

• Market is dominated by a single architecture and instruction set

• x86

Image courtesy of Wikimedia Commons GPL

Page 18: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

Images courtesy of iFixit © 2012, CC-BY-NC-SA

Page 19: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Images courtesy of iFixit © 2012, CC-BY-NC-SA

Page 20: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Barely begun to examine this system!

Page 21: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Barely begun to examine this system!

Four different embedded processors!

Page 22: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Barely begun to examine this system!

Four different embedded processors!

Four different manufacturers!

Page 23: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Barely begun to examine this system!

Four different embedded processors!

Four different manufacturers!

Four different architectures!

Page 24: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Lots of concurrency!

Page 25: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Lots of concurrency!

Different instruction sets!

Page 26: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Example Embedded System: Apple iPhone• A5 Processor• Qualcomm DSP

• Texas Instruments touchscreen microcontroller

• Cirrus Logic DSP

Highly Specialized!

Page 27: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What advantages might there be to specialization?

Page 28: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What advantages might there be to specialization?

Energy consumption, specialized hardware, efficiency, etc

Page 29: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

ATMEGA328,

AVR PROCESSORS,

& ARDUINO

Page 30: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Dueling Architectures

Page 31: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Dueling Architectures

Page 32: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Advantages/Disadvantagesto each?

Page 33: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Complexity, dedicated buses

Von Neumann bottleneck

Advantages/Disadvantagesto each?

Page 34: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

ATmega328

Page 35: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

ATmega328• CPU

• (Details later)

Page 36: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

ATmega328• Flash – program

memory• 32K

• SRAM – data memory• 2K

• EEPROM• 1K• Nonvolatile memory

Page 37: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What kind of architecture?

Page 38: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

What kind of architecture?

Page 39: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPU

Page 40: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPU

Instruction fetch and decode

Page 41: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPU

ALU instructions

Page 42: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPU

I/O and special functions

Page 43: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPU32 8-bit general purpose registersPart of SRAM memory space

Page 44: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR CPUX, Y, and Z registers16-bit registers made using registers 26-31Support indirect addressing

Page 45: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR Memory

FLASH

BOOT SECTION

32 registers

64 I/O registers

160 Ext I/O Registers

Internal SRAM

EEPROM

Page 46: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR Architecture• Three timers• Flexible

• Choose clock rate• Choose “roll-over”• Generate interrupts• Generate PWM

signals

Page 47: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR Architecture• Interface to pins• Each pin directly

programmable• Program direction (I/O)• Program value• Program pull-ups

• Some special pins• Analog/Digital• Clocks• Reset

Page 48: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

AVR Architecture• 3 8-bit ports (B, C, D)• Each port controlled by

3 8-bit registers• Each bit controls one I/O pin• DDRx – direction register

• Defines Input(0) or Output(1)

• PINx – Pin input value• Reading this “register” returns

value of the pin

• PORTx – Pin output value• Writing to this register sets

value of pin

Page 49: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pin Circuitry

Page 50: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pin Input

PINx

DDRx=0

PORTx

Page 51: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Synchronization and Timing

Takes a clock cycle for data output to be reflected on the input

Page 52: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Why is this necessary?

Page 53: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Why is this necessary?What if the pin changes value near the falling edge of a clock cycle?

Page 54: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Why is this necessary?What if the pin changes value near the falling edge of a clock cycle?

Metastability

Page 55: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pin Output

PINx

DDRx=1

PORTx

Page 56: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pin Input – PORT controls pullup

PINx

DDRx=0

PORTx

Page 57: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pullups

• Pullups– If a pin is an input (DDRxi = 0)

• PORTxi = 0 – Pin is floating• PORTxi = 1 – connects pullup to the pin

– Keeps pin from floating if noone is driving– Llows wired-OR bus

– Individual bits can be set cleared using bit-ops– A bit can be toggled by writing I to PINxi

Page 58: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Arduino Uno

ATmega328

Page 59: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Arduino Uno

ATmega328ATmega16U2

Page 60: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Arduino Digital and Analog I/O Pins

• Digital pins– Pins 0-7: PORT D– Pins 8-13: PORT B– Pins 14-19: PORT C

• Named A0 – A5• Arduino analog

– Pins 0 and 1 are RX and TX for serial comms

– Pin 13 connected to base board LED

Page 61: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

More Info

• Too much to cover!

• See data sheets for Arduino and ATmega328– http

://www.atmel.com/Images/8271s.pdf

– http://www.atmel.com/images/doc0856.pdf

– http://arduino.cc/en/Main/ArduinoBoardUno

Page 62: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

PARALLELISM

Page 63: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Parallelism vs. Concurrency

• What’s the difference?

Page 64: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Parallelism vs. Concurrency

• Concurrency is central to embedded systems!

– Concurrency – different parts of the program conceptually execute simultaneously

– Parallel – different parts physically execute simultaneously

Page 65: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pipelining

Page 66: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Sample five stage pipeline

What’s going on here?

Page 67: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Reservation Table

Page 68: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pipeline hazards represented by dashed lines

Pipeline Hazards!

Page 69: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Pipeline Interlock to prevent hazard

Page 70: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Other types of parallelism

• CISC vs. RISC• Superscalar processors• Hyperthreading• Multicore

Page 71: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

WRAP UP

Page 72: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

Industrial Connection

• Mr. Tony Kaap– Motion Picture Industry: Motion Capture

• Mr. Robert Zeh– Financial Industry: Real-time systems

• Stanford University– Tagging of Pelagic Predators

• MBARI– Deep sea embedded systems

and data collection• Dr. Kristin Rozier

– NASA: Safety Critical Systems

Page 73: CYBERPHYSICAL SYSTEMS & EMBEDDED PROCESSORS EEN 417 Fall 2013 8/27/13, Dr. Eric Rozier, V1.0, ECE

For next time

• Read Chapter 2 (Continuous Dynamics)

• Assignment 1: Problems 1, 2, and 3 of Chapter 7.